大约 50% 的时间,当我运行bundle
(或bundle exec foo
) 时,我会收到如下错误:
> bundle
/usr/local/Cellar/ruby/1.9.3-p374/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': No such file or directory - /usr/local/lib/?y (Errno::ENOENT)
from /usr/local/Cellar/ruby/1.9.3-p374/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/Cellar/ruby/1.9.3-p374/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib/bundler.rb:8:in `<top (required)>'
from /usr/local/Cellar/ruby/1.9.3-p374/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/Cellar/ruby/1.9.3-p374/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/Cellar/ruby/1.9.3-p374/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/bin/bundle:2:in `<top (required)>'
from /usr/local/bin/bundle:23:in `load'
from /usr/local/bin/bundle:23:in `<main>'
在我看来,这像是在构建所需路径时发生了内存损坏,但我不知道为什么这种情况只在使用 Bundler 时发生,而不是使用 vanilla Ruby。我知道 Bundler 修补了,Kernel.require
但错误(根据上面的跟踪)似乎发生在路径传递给该方法之前。
我拥有的软件版本:
> ruby --version
ruby 1.9.3p374 (2013-01-15 revision 38858) [x86_64-darwin12.2.0]
> gem list bundler
*** LOCAL GEMS ***
bundler (1.2.3)
我没有安装 rvm/rbenv/etc,并且盒子上只有两个 ruby,一个是自制安装的,另一个是系统安装的。
答案1
我也遇到了这个问题。gem install bundler --pre
帮我解决了。