如何使用RoR和主管和rbenv的乘客

时间:2015-01-29 03:15:43

标签: ruby-on-rails passenger rbenv supervisord

我正试图与主管一起使用乘客。

这是我得到的错误:

cannot load such file -- bundler/setup (LoadError)
  /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
  /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:263:in `block in run_load_path_setup_code'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:366:in `running_bundler'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:261:in `run_load_path_setup_code'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:100:in `preload_app'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:158:in `<module:App>'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:28:in `<main>'

但是我在这里使用带有ruby 2.1.5的捆绑器路径的rbenv而不是1.9.1:

BUNDLER_HOME='/opt/rbenv/shims/bundler'

我甚至设置了.bashrc和主管。但是我得到了那个错误?

[program:passenger]

directory=/var/etl-rails
environment=RAILS_ENV="development", BUNDLER_HOME='/opt/rbenv/shims/bundler'
command = /usr/bin/passenger start
autostart=true
autorestart=true

stopsignal=KILL
stopasgroup = true
killasgroup = true

stdout_logfile=/tmp/passenger.log
stdout_logfile_maxbytes=100MB
stdout_logfile_backups=10

stderr_logfile = /tmp/passenger.err
stderr_logfile_maxbytes=10MB
stderr_logfile_backups=10

所以....主管正试图使用​​1.9.1。我可以从命令行启动乘客,但我必须运行以下命令:

rbenv global 2.1.5
/usr/bin/passenger start

1 个答案:

答案 0 :(得分:0)

首先:默认情况下,supervisor以root身份运行。如果您在特定用户(典型情况)下配置了rbenv,您应该告诉主管在该用户下运行Rails:

~/.profile

您还需要初始化rbenv(其初始化脚本通常位于用户的environment=或其他文件中)。您可以在bash上重现配置,但我通常只在登录(`-l)模式下在command = bash -lc "/usr/bin/passenger start" 内运行Rails,这将适当地初始化此用户的上下文,即:

{{1}}