linux – Capistrano部署的精神错误

我有一个Capistrano部署脚本已经工作了一段时间,但现在它在部署时抛出了这样的错误:

/Users/lifecoder/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/psych.rb:203:in `parse': (<unknown>): control characters are not allowed at line 1 column 1 (Psych::SyntaxError)
    from /Users/lifecoder/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/psych.rb:203:in `parse_stream'
    from /Users/lifecoder/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/psych.rb:151:in `parse'
    from /Users/lifecoder/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/psych.rb:127:in `load'
...

它在部署期间还会抛出几个警告:

** [out :: test.domain] Warning! PATH is not properly set up,'/home/lifecoder/.rvm/gems/ruby-1.9.3-p448/bin' is not at first place,** [out :: test.domain]
 ** [out :: test.domain] usually this is caused by shell initialization files - check them for 'PATH=...' entries,** [out :: test.domain]
 ** [out :: test.domain] to fix run: 'rvm use ruby-1.9.3-p448'.

我发现类似问题here并假设这个警告实际上是心理崩溃的原因.但我无法摆脱它,PATH实际上对我来说很好,当我通过ssh连接并检查它时,rvm是第一位的:

$echo $PATH
/home/lifecoder/.rvm/gems/ruby-1.9.3-p448/bin:/home/lifecoder/.rvm/gems/ruby-1.9.3-p448@global/bin:/home/lifecoder/.rvm/rubies/ruby-1.9.3-p448/bin:/home/lifecoder/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

我对* nix不太熟练,所以我可能会错过一些东西 – 但是找不到确切的东西.

我知道它可能通过YAML解析器引擎更改或通过删除某处的YAML文件来修复,因此Psych无法启动,但我更愿意以正确的方式解决此问题.

UPD1:我在Capistrano脚本中添加了一个带有’use rvm’的钩子,然后它返回’RVM不是函数’.似乎它没有加载bashrc /其他init脚本.

UPD2:是的,它不会加载bash,但是当我启用bash时它变得更糟.作为临时解决方案,我禁用了capistrano / assets.似乎我只需要擦除复制粘贴的capistrano脚本并从头开始重写它.

解决方法

当Capistrano登录时 – 它使用非交互式shell – 它不会加载.bash_profile
所以,我在deployment.rb中加载了一个bash作为默认shell:

default_run_options[:shell] = '/bin/bash'

然后将.bash_profile的RVM加载脚本移动到.bashrc

#.bash_profile
source ~/.bashrc



#.bashrc
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

相关文章

linux常用进程通信方式包括管道(pipe)、有名管道(FIFO)、...
Linux性能观测工具按类别可分为系统级别和进程级别,系统级别...
本文详细介绍了curl命令基础和高级用法,包括跳过https的证书...
本文包含作者工作中常用到的一些命令,用于诊断网络、磁盘占满...
linux的平均负载表示运行态和就绪态及不可中断状态(正在io)的...
CPU上下文频繁切换会导致系统性能下降,切换分为进程切换、线...