简体   繁体   中英

Capistrano Using Old Ruby Version

I'm trying to get Capistrano to work on my MacBook (OSX Mountain Lion) but am having a lot of difficulties. It started with it throwing an error:

cillosis:myapp macbook$ cap deploy
/Library/Ruby/Gems/1.8/gems/sshkit-1.2.0/lib/sshkit.rb:32: undefined method `require_relative' for main:Object (NoMethodError)
from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:55:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/1.8/gems/capistrano-3.0.1/lib/capistrano/all.rb:2
from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:55:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/1.8/gems/capistrano-3.0.1/bin/cap:2
from /usr/bin/cap:19:in `load'
from /usr/bin/cap:19

It seemed I had Ruby 1.8 installed and it doesn't work correctly with Capistrano (found this Googling around).

So I installed Ruby 2.0 using rvm. RVM starting throwing a bunch of errors so I got rid of it using rvm implode and found that the 2.0 version was still on my computer. I checked my $PATH and the locations it pointed at contained the Ruby 1.8. So I renamed that to *ruby_old* and copied the new ruby to that folder ( /usr/bin ). Then when I did a ruby -v it came back as version 2.0. So I thought, great, now we can finally run Capistrano.

Just to be sure, I did a gem update which came back as having updated the sshkit gem which was throwing the error before. So I go to deploy, and get the same exact error as I started with.

I know the deploy.rb script is correct because I use it all the time on another Mac.

TL;DR; After some fumbling, when I type ruby -v it comes back as using version 2.0 but when I do a cap deploy with Capistrano, it tries to use version 1.8 of ruby. How do I fix this?

The dumb, but simple way out would be to completely remove RVM and both ruby versions, then install again from scratch. I would recommend 1.9.x over 2.0 due to some gems not being up to speed yet, but that's up to you.

Another option would be to specify the ruby version in your gemfile (as heroku does it), then do a "bundle exec cap deploy". Again, no guarantees - but it might force capistrano to behave the way you want until you find a proper solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM