【问题标题】:Psych error on Capistrano deploymentCapistrano 部署的心理错误
【发布时间】:2013-07-22 07:47:52
【问题描述】:

我有一个 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 并假设此警告实际上是导致 Psych 崩溃的原因。但我无法摆脱它,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 脚本中添加了一个带有“使用 rvm”的钩子,它返回给我“RVM 不是函数”。似乎它没有加载 bashrc/其他初始化脚本。

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

【问题讨论】:

    标签: linux ruby-on-rails-3 ubuntu deployment capistrano


    【解决方案1】:

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

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

    然后将 RVM 加载脚本从 .bash_profile 移动到 .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*
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-05
      • 2015-07-22
      • 1970-01-01
      • 1970-01-01
      • 2016-10-08
      • 1970-01-01
      相关资源
      最近更新 更多