LoadError: cannot load such file -- bundler/setup

LoadError: cannot load such file -- bundler/setup

我们正在升级到最新的 ruby 版本 (2.2.3) 和最新的 rails 版本 (4.2.4),我们无法通过此错误:

LoadError: cannot load such file -- bundler/setup
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
~/Documents/remsis/config/boot.rb:6:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
~/Documents/remsis/config/application.rb:1:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
~/Documents/remsis/config/environment.rb:2:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
~/Documents/remsis/config.ru:3:in `block in <main>'
~/Library/Application Support/Pow/Versions/0.5.0/node_modules/nack/lib/nack/builder.rb:4:in `instance_eval'
~/Library/Application Support/Pow/Versions/0.5.0/node_modules/nack/lib/nack/builder.rb:4:in `initialize'
~/Documents/remsis/config.ru:1:in `new'
~/Documents/remsis/config.ru:1:in `<main>'
~/Library/Application Support/Pow/Versions/0.5.0/node_modules/nack/lib/nack/server.rb:51:in `eval'
~/Library/Application Support/Pow/Versions/0.5.0/node_modules/nack/lib/nack/server.rb:51:in `load_config'
~/Library/Application Support/Pow/Versions/0.5.0/node_modules/nack/lib/nack/server.rb:42:in `initialize'
~/Library/Application Support/Pow/Versions/0.5.0/node_modules/nack/lib/nack/server.rb:12:in `new'
~/Library/Application Support/Pow/Versions/0.5.0/node_modules/nack/lib/nack/server.rb:12:in `run'
~/Library/Application Support/Pow/Versions/0.5.0/node_modules/nack/bin/nack_worker:4:in `<main>'

使用 RVM 创建 Gemset

rvm use 2.2.3@yourproject --create

之后安装捆绑器gem

gem install bundler

最后一步是捆绑安装

bundle install

该错误表明您正在使用系统 Ruby,而不是 RVM。您需要告诉 Pow 使用正确的 Ruby 版本。您需要创建一个 .rvmrc 文件指定要使用哪个 Ruby,还需要创建或编辑一个 .powrc.powenv 文件来告诉 Pow 加载 RVM。见 Pow docs on using RVM.

如果您正在使用/升级到捆绑器 2,请查看此文档:

https://bundler.io/guides/bundler_2_upgrade.html

根据我的经验,基本上,您需要使用 RubyGems v2.5.0 或更高版本,否则如果您有 require 'bundler/setup',您将看到 cannot load such file -- bundler/setup。如果您需要升级 ruby​​gems,您可以通过以下方式进行:

gem update --system

希望对您有所帮助。谢谢