Reputation: 1861
I am getting error while deploying my rails4 app to VPS. The error I'm getting is
rbenv: version `2.0.0' is not installed
But using "ruby -v" I get
ruby 2.0.0p0 (2013-02-24 revision 39474) [i686-linux]
And in my gemfile I have
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '4.0.0'
This error appears after bundle install recipe
2013-08-04 23:23:56 executing `bundle:install'
* executing "cd /home/yasinishyn/apps/kaiser/releases/20130804202355 && bundle install --gemfile /home/yasinishyn/apps/kaiser/releases/20130804202355/Gemfile --path /home/yasinishyn/apps/kaiser/shared/bundle --deployment --quiet --without development test"
servers: ["xxx.xxx.xxx.xxx"]
[198.211.125.183] executing command
** [out :: xxx.xxx.xxx.xxx] rbenv: version `2.0.0' is not installed
** [out :: xxx.xxx.xxx.xxx]
command finished in 355ms
*** [deploy:update_code] rolling back
* executing "rm -rf /home/yasinishyn/apps/kaiser/releases/20130804202355; true"
servers: ["xxx.xxx.xxx.xxx"]
[xxx.xxx.xxx.xxx] executing command
command finished in 342ms
Please help me to figure out this.
Upvotes: 7
Views: 3135
Reputation: 1861
Thank you Benjamin, but the error was realy stupid )). Localy I use ruby 2.0.0-p195 which was installed by rvm. On my server I user ruby 2.0.0-p0 which was installed by rbenv, because rbenv don't have ruby package 2.0.0-p195.
So while I was creating new rails4 app by rails-composer, I don't noticed that it was created with .ruby-version file inside of which was a line with ruby version ruby 2.0.0-p195, so I simply * git rm .ruby-version*, and everything is working.
Upvotes: 6
Reputation: 13181
That's most certainly a PATH problem, capistrano will send commands through ssh without opening a console session and the profile files are not loaded the same way if you open a ssh console session. That may explain why through ssh console you can get a correct rbenv environment but not through capistrano.
The following works with debian / ubuntu, and need to be adjusted for other distro
I suppose you added some export
instruction in one of your profile file. In ~/.profile or ~/.bashrc perhaps.
The export
instruction I use are the following, but they may be different in your configuration, so if rbenv is properly working when you open a ssh console then you can keep your set of export
commands. The trick I'm going to detail is just to place them at the right place.
My export
instructions are:
echo 'export RBENV_ROOT=/opt/rbenv'
echo 'export PATH=/opt/rbenv/bin:$PATH'
echo 'eval "$(rbenv init -)"'
1-
Remove them from any files where you previously included them and place them in the file /etc/profile.d/rbenv
2-
Edit the file /root/.bashrc (or /home/your_user/.bashrc if you do access your server with another user than "root") and add the line source /etc/profile.d/rbenv
just before the line [ -z "$PS1" ] && return
3-
Edit the file /home/deployer/.bashrc (assuming you are using "deployer" user for capistrano, otherwise adapt the path) and add the line
source /etc/profile.d/rbenv
just before the line [ -z "$PS1" ] && return
4-
Verify it's working by opening another ssh console session and trying ruby -v
. Then capistrano should work correctly
Other possibility
rbenv need rehash after you manually install gems, so run on your server rbenv rehash
just to be sure
Upvotes: 4