postmodern / chruby

Changes the current Ruby
MIT License
2.86k stars 190 forks source link

chruby: unknown Ruby: ruby-2.2.0 #315

Closed dt1973 closed 9 years ago

dt1973 commented 9 years ago

Why won't ruby-2.2.0 in .ruby-version work, whereas chruby ruby-2.2.0 will?

% whoami
whoareyou
% sudo su myapp
% cd /home/www/myapp/
% whoami
chruby: unknown Ruby: ruby-2.2.0
myapp
% cat .ruby-version
ruby-2.2.0
% which ruby
/usr/local/bin/ruby
% chruby ruby-2.2.0
% which ruby
/home/www/myapp/.rubies/ruby-2.2.0/bin/ruby 

Full transcript of deployment:

https://gist.github.com/dt1973/7b99dfb75bd26e1e5ed7

postmodern commented 9 years ago

Is /home/www/myapp/ the $HOME and did you check echo ${RUBIES[@]}? Also, it is far simpler to not use chruby in production, but instead install ruby via brightbox or into /usr/local via ruby-install.

dt1973 commented 9 years ago

Yup:

% env
HOME=/home/www/myapp
% echo ${RUBIES[@]}
/home/www/myapp/.rubies/ruby-2.2.0

Basically I'm using chruby because installing Ruby locally seems to be the only way I can use my Rails app without Bundler, Rake etc. complaining about the lack of /usr/local permissions.

postmodern commented 9 years ago

@dt1973 that is what bundle install --deployment is for. It will install all gems into $app/vendor/gems/.

Double check your shell configuration. I'm guessing you're loading chruby only for interactive shells, but not for uninteractive shells.

dt1973 commented 9 years ago

I was under the impression that bundle install --deployment was to be avoided due to the whole:

You are trying to install in deployment mode after changing your Gemfile. Run bundle install elsewhere and add the updated Gemfile.lock to version control.

thing. Came across http://stackoverflow.com/questions/6785626/unable-to-update-gems-on-production-server with no real solution, just a quick fix:

bundle install --no-deployment && bundle update && bundle install --deployment
postmodern commented 9 years ago

--deployment is designed for production and when you have a committed Gemfile.lock. It also does not require sudo access, which is a must for production.

dt1973 commented 9 years ago

Cool, fair enough. Thanks man!

Close it if you wish.

postmodern commented 9 years ago

Closing for now, but I suspect there might be whitespace in .ruby-version. Try running hexdump -C .ruby-version.