问题
I have a problem with setting Ruby version in a unicorn start script. When I run start script in debug mode I have the following output.
vagrant@vagrant-ubuntu-trusty-64:~$ sudo sh -x /etc/init.d/unicorn start
+ set -e
+ USAGE=Usage: /etc/init.d/unicorn <start|stop|restart|upgrade|rotate|force-stop>
+ USER=vagrant
+ APP_NAME=my_app
+ APP_ROOT=/vagrant
+ RAILS_ENV=production
+ export RBENV_ROOT=/home/vagrant/.rbenv
+ export PATH=/home/vagrant/.rbenv/bin:/home/vagrant/.rbenv/shims:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+ SET_RUBY=cd /vagrant && rbenv rehash && rbenv local 2.2.0
+ CMD=cd /vagrant && rbenv rehash && rbenv local 2.2.0;bundle exec unicorn -c config/unicorn.rb -E production -D
+ PID=/vagrant/tmp/pids/unicorn.pid
+ OLD_PID=/vagrant/tmp/pids/unicorn.pid.oldbin
+ cd /vagrant
+ sig 0
+ test -s /vagrant/tmp/pids/unicorn.pid
+ echo Starting my_app
Starting my_app
+ su - vagrant -c cd /vagrant && rbenv rehash && rbenv local 2.2.0;bundle exec unicorn -c config/unicorn.rb -E production -D
-su: rbenv: command not found
Your Ruby version is 1.9.3, but your Gemfile specified 2.2.0
I guess the problem is with su - vagrant -c ...
section. That is originally su - $USER -m -c "$CMD"
.
How can I fix this? Thank you.
来源:https://stackoverflow.com/questions/27888348/rbenv-issue-your-ruby-version-is-1-9-3-but-your-gemfile-specified-2-2-0