猜测是 gemsets 路径不统一导致的 cannot load such file -- bundler/setup (LoadError)
**gem env**
- GEM PATHS:
- /home/vagrant/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0
- /home/vagrant/.gem/ruby/2.2.0
运行 gem list 只有最基本几个 gem(/home/vagrant/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0),但是 bundle list 确有 rails 需要的所有 gem(/home/vagrant/.gem/ruby/2.2.0),执行 bundle install 也没有什么可安装了
浏览器访问,提示错误找不到 bundler/setup 需要怎么搞呢??在线等
执行命令的前面加 bundle exec
,例如 bundle exec rails c
,如果没有错误,那么 bundle 管理的 gem 安装到了独立目录,bundle config path
可以看到配置到了哪。
@rei
[vagrant@localhost ruby]$ bundle config path
Settings for path
in order of priority. The top value will be used
You have not configured a value for path
是 passenger 认为的 gems path 根 bundle install gempath 不同到导致出错的吗??
cannot load such file -- bundler/setup (LoadError)
/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/vagrant/.gem/ruby/gems/passenger-5.0.15/lib/phusion_passenger/loader_shared_helpers.rb:406:in `activate_gem'
/home/vagrant/.gem/ruby/gems/passenger-5.0.15/lib/phusion_passenger/loader_shared_helpers.rb:288:in `block in run_load_path_setup_code'
/home/vagrant/.gem/ruby/gems/passenger-5.0.15/lib/phusion_passenger/loader_shared_helpers.rb:411:in `running_bundler'
/home/vagrant/.gem/ruby/gems/passenger-5.0.15/lib/phusion_passenger/loader_shared_helpers.rb:287:in `run_load_path_setup_code'
/home/vagrant/.gem/ruby/gems/passenger-5.0.15/helper-scripts/rack-preloader.rb:99:in `preload_app'
/home/vagrant/.gem/ruby/gems/passenger-5.0.15/helper-scripts/rack-preloader.rb:153:in `<module:App>'
/home/vagrant/.gem/ruby/gems/passenger-5.0.15/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
/home/vagrant/.gem/ruby/gems/passenger-5.0.15/helper-scripts/rack-preloader.rb:28:in `<main>'
#4 楼 @kee 最后两行日志显示调用了系统 rubygems 的 require,似乎没有正确配置 passenger 告诉它 ruby 在哪里。
如果 passenger 是编译到 nginx,应该在 /etc/nginx/nginx.conf 有这一行配置:
passenger_ruby /home/vagrant/.rbenv/shims/ruby;
可以参考一篇写得很完善的 rbenv + passenger 部署文章 https://gorails.com/deploy/ubuntu/14.04
感谢 @rei 之前配置的是系统自带的 ruby(/usr/bin/ruby),改为 rvenv 安装的 ruby 后提示 bundle install 了😄
It looks like Bundler could not find a gem. Maybe you didn't install all the gems that this application needs. To install your gems, please run:
bundle install
有点疑问,passenger 是从哪里加载 gems 的呢?另外我查看 bundle(bin)也有两个
系统自带的 2.0.0,我用 rvm 安装 2.2 失败(提取文件有错误),就自己下载 ruby2.2.2 编译安装了,然后就出现上边的问题了 现在改用 rbenv 还是上边的问题,大概是什么原因呢?
bundle 也有两个,不知道执行 bundle install 有没有影响
bunle:[vagrant@localhost Internal]$ whereis bundle
bundle: /home/vagrant/.rbenv/shims/bundle /home/vagrant/bin/bundle
@rei 再次感谢,bundle install 后跑起来了😄 最后一个小问题 gem list 怎么看到的只有(bundle 安装的没有列出来)
*** LOCAL GEMS ***
bigdecimal (1.2.6)
bundle (0.0.1)
bundler (1.10.6)
io-console (0.4.3)
json (1.8.1)
lumberjack (1.0.9)
mini_portile (0.6.2)
minitest (5.4.3)
nokogiri (1.6.6.2)
power_assert (0.2.2)
psych (2.0.8)
rake (10.4.2)
rdoc (4.2.0)
test-unit (3.0.8)
问题如下:
» c [ruby-2.4.0][10:00:54]
/Users/dubing/.rvm/rubies/ruby-2.4.0/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- bundler/setup (LoadError)
from /Users/dubing/.rvm/rubies/ruby-2.4.0/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/dubing/workspace/vcooline/code_event_back_service/config/boot.rb:3:in `<top (required)>'
from bin/rails:3:in `require_relative'
from bin/rails:3:in `<main>'
重新安装bundler: gem install bundler
Fetching: bundler-1.16.2.gem (100%)
Successfully installed bundler-1.16.2
1 gem installed
然后bundle install
然后世界顺畅了。
» c [ruby-2.4.0][10:04:32]
Loading development environment (Rails 5.0.2)
gem install awesome_print # <-- highly recommended
2.4.0 (main):0 >