Gem 请教下 bundle install 出错的问题

jiyinyiyong · 2013年06月12日 · 最后由 hpyhacking 回复于 2013年06月12日 · 4287 次阅读

想跑个 Rails 后台的项目,Gemfile 是这样的:https://github.com/paulmillr/ostio-api/blob/master/Gemfile 我看到有 Gemfile, 于是用 bundle install 来安装依赖. 环境是 Archlinux, Ruby 是通过 yaourt 直接安装的,bundle 通过 gem install 安装 修改了 source 到镜像,然后跑命令出错了

➤➤ ruby -v
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-linux]
➤➤ gem -v
2.0.0
➤➤ bundle install
Fetching source index from http://ruby.taobao.org/
Using rake (10.0.3) 
Using i18n (0.6.1) 
Using multi_json (1.5.0) 
Using activesupport (3.2.11) 
Using builder (3.0.4) 
Using activemodel (3.2.11) 
Using erubis (2.7.0) 
Using journey (1.0.4) 
Using rack (1.4.3) 
Using rack-cache (1.2) 
Using rack-test (0.6.2) 
Using hike (1.2.1) 
Using tilt (1.3.3) 
Using sprockets (2.2.2) 
Using actionpack (3.2.11) 
Installing mime-types (1.19) 
Errno::ENOENT: No such file or directory - /usr/lib/ruby/gems/2.0.0/build_info/mime-types-1.19.info
An error occurred while installing mime-types (1.19), and Bundler cannot continue.
Make sure that `gem install mime-types -v '1.19'` succeeds before bundling.

第一次是在 rake 的安装过程出错.. 然后是按顺序那些包 我依照提示手动 gem install rake 了几个包.. 结果数量好大.. 比如 gem install actionpack -v 3.2.11 安装是能成功的, 但在 bundle install 的时候就是会出错,, 大概像上边这样 -V 的 log: https://gist.github.com/jiyinyiyong/5762608 为什么前者正常而 bundle 会出错呢?

我也遇到过几次。。不懂为什么。。

从 rubygems 上下载mime-types,然后gem install mime-types-1.19.gem从本地安装一下吧。

#2 楼 @ericguogem install 可安装,bundle iinstall 失败. 考虑到数量上太痛苦还是想弄明白怎么让 bundle install 正常工作

Gemfile 里面换http://rubygems.org/试试?

看一眼 /etc/gemrc 的内容,是不是有 --user-install 之类的设置,如果有,那么这会把 gem 安装到 ~/.gem/ruby, 在 /usr/lib/ruby/gems/ 自然就找不到。目测 bundler 对 --user-install 是不太友好的。

Archlinux 希望通过 pacman 安装的 rubygems 包与用户自己通过 gem install 安装的包互不冲突,所以把这个配置写死在 /etc/gemrc 里。

解决办法是... 我也说不好。干脆直接用 rvm / rbenv 可能是个比较彻底的方案吧。

#4 楼 @ericguo 默认就是,所以有试过的,一样,就是更慢

#5 楼 @5long 有.. 编译一遍工夫不够了呀.. 啊啊啊.. 过几天再折腾一遍

#3 楼 @jiyinyiyong 可以试试 path 参数,让所有的 gem 都装到一个特定目录,例如./.gems

强烈推荐还是应该搞个 RVM 的,从长远来看会让你省心。

需要 登录 后方可回复, 如果你还没有账号请 注册新账号