Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Psych error on Capistrano deployment

I have a Capistrano deployment script which have work for some time, but now it throw such error on deployment:

/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'
...

It also throws several warnings during the deployment:

 ** [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'.

I have found similar problem here and assume this warning is actually the cause of Psych crash. But I can't get rid of it, the PATH actually looks good for me, and rvm is in the first place when I connect via ssh and check it:

$ 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

I'm not so proficient in *nix so I probably miss something - but can't find what exactly.

I know it is probably fixable by YAML parser engine change, or by deleting YAML file somewhere so Psych wouldn't start, but I would prefer to fix this issue in the right way.

UPD1: I have add a hook with 'use rvm' into Capistrano script, and it return me 'RVM is not a function'. Seems it doesn't load bashrc/other init scripts.

UPD2: Yes, it does not load bash, but when I enable bash it become even worse. As a temporary solution I disabled capistrano/assets. Seems all I need is to wipe the copy-pasted capistrano script and rewrite it from scratch.

like image 722
lifecoder Avatar asked Nov 12 '22 01:11

lifecoder


1 Answers

When Capistrano logs in - it uses non-interactive shell — it does not load .bash_profile So, I've load a bash as a default shell in the deployment.rb:

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

and then move RVM load script from .bash_profile to .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*
like image 115
lifecoder Avatar answered Nov 14 '22 14:11

lifecoder