简体   繁体   English

在ruby 2.0升级上打破捆绑安装

[英]Bundle install broken on ruby 2.0 upgrade

Just upgraded to ruby 2.0/rails 4.0 and trying to run bundle install on a new rails project. 刚升级到ruby 2.0 / rails 4.0并尝试在新的rails项目上运行bundle install。 Whenever it hits something that's not already installed, it'll spit out: 每当它击中尚未安装的东西时,它都会吐出:

Installing coffee-rails (4.0.0.beta1) 
Errno::ENOENT: No such file or directory - /usr/lib/ruby/gems/2.0.0/build_info/coffee-rails-4.0.0.beta1.info
An error occurred while installing coffee-rails (4.0.0.beta1), and Bundler cannot continue.
Make sure that `gem install coffee-rails -v '4.0.0.beta1'` succeeds before bundling.

So then I then run 那么我就跑了

gem install coffee-rails -v '4.0.0.beta1'

And it installs fine, and I rerun bundle install and have to repeat this for every time it runs into a gem version I haven't installed yet. 它安装得很好,我重新运行捆绑安装,并且每次运行到我尚未安装的gem版本时都必须重复此操作。 What's the problem here? 这有什么问题?

In my case it turned out that bundle was trying to install gems into global location at /usr/lib/ruby/gems/2.0.0, but since I didn't invoke it through sudo it ended up with permission error. 在我的情况下,事实证明bundle正在尝试将gems安装到/usr/lib/ruby/gems/2.0.0的全局位置,但由于我没有通过sudo调用它,因此最终出现了权限错误。 I wanted to install to my home dir anyhow so it turned out that I can do: 无论如何我想安装到我家的目录所以事实证明我能做到:

GEM_HOME=~/.gem/ruby/2.0.0/ bundle

and live happily ever after. 从此过上幸福的生活。

The bundle executable is just a shell script, and it has a shebang line which will be pointing to a particular Ruby executable (or to /usr/bin/env ruby ). bundle可执行文件只是一个shell脚本,它有一个shebang行,它指向一个特定的Ruby可执行文件(或者指向/usr/bin/env ruby )。 It sounds like that shebang line is pointing to a different version of Ruby, not the 2.0 one, and not the one that the shebang line in your gem executable is pointing to. 听起来shebang line指的是Ruby的不同版本,而不是2.0版本,而不是gem可执行文件中的shebang行指向的版本。

Run this to see what it's pointing to: head -1 $(which bundle) 运行它以查看它指向的内容: head -1 $(which bundle)

Whatever line that shows you, strip off the #! 无论向您展示什么线路,都要脱掉#! prefix and run that line with the -v switch to see which version of Ruby it is (if it's not obvious). 前缀并使用-v开关运行该行以查看它的Ruby版本(如果它不明显)。 So if the shebang line was #!/usr/bin/ruby then run /usr/bin/ruby -v If my theory is correct then you'll get a non 2.0 version number there. 所以如果shebang行是#!/usr/bin/ruby然后运行/usr/bin/ruby -v如果我的理论是正确的那么你将获得一个非2.0版本号。

Based on what you said, your gem executable is pointing to the 2.0 Ruby, so the fix here is to just uninstall and then reinstalled the bundler gem. 根据你的说法,你的gem可执行文件指向2.0 Ruby,所以这里的修复只是卸载然后重新安装bundler gem。 That should put the right Ruby 2.0 shebang line into your bundle executable. 应该将正确的Ruby 2.0 shebang行放入您的bundle可执行文件中。

This solved it for me: 这解决了我:

sudo gem update --system --no-user-install

source: https://bbs.archlinux.org/viewtopic.php?id=138650 来源: https//bbs.archlinux.org/viewtopic.php?id = 138650

Put this in your Gemfile and then run bundle install. 将它放在您的Gemfile中,然后运行bundle install。

group :assets do
  gem 'coffee-rails', github: 'rails/coffee-rails'
end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM