新手问题 Could not read gem at /Library/Ruby/Gems/2.0.0/ruby/2.0.0/cache/will_paginate-3.0.7.gem

mexiqq · 2015年05月28日 · 最后由 rei 回复于 2015年05月28日 · 2201 次阅读

Could not read gem at /Library/Ruby/Gems/2.0.0/ruby/2.0.0/cache/will_paginate-3.0.7.gem

Bundle Install 提示如下:

Bundler::GemspecError: Could not read gem at /Library/Ruby/Gems/2.0.0/ruby/2.0.0/cache/will_paginate-3.0.7.gem. It may be corrupted. An error occurred while installing will_paginate (3.0.7), and Bundler cannot continue. Make sure that gem install will_paginate -v '3.0.7' succeeds before bundling.

可是 will_paginate -v '3.0.7' 确认安装成功

前往 /Library/Ruby/Gems/2.0.0/ruby/2.0.0/cache/ 文件夹,will_paginate 已经存在

请解答?

$ rm -rf  /Library/Ruby/Gems/2.0.0/ruby/2.0.0/cache/will_paginate-3.0.7.gem
$ gem install will_paginate-3.0.7

#1 楼 @colorfulberry 试过了,但是问题依旧

执行一楼的命令的输出贴出来看看。

#3 楼 @rei gem 安装成功

bundle install 失败

发现 .gem 包已经存在

删除 .gem 包,可以看到,已找不到 / 我的 rm alias 到 rmtrash

执行哥们第一条命令 加了 版本号出问题

执行第一条命令,不加版本号 安装成功

Bundle install 仍然提示失败,找不到 gem 包

估计是权限问题,gem 是在系统目录,bundle 也要加 sudo。

不过我建议把 gem 目录改到用户目录,在 ~/.bashrc 或者 ~/.zsh(取决于你的 shell)添加以下配置:

export GEM_HOME="$(ruby -rubygems -e 'puts Gem.user_dir')"
export PATH=$GEM_HOME/bin:$PATH

这样 gem 和 bundle 都不用 sudo 了。

PS:一楼命令有错,应该是

gem install will_paginate -v 3.0.7

#5 楼 @rei 万分感谢,确实是权限问题,之所以没有使用 sudo 是因为之前有提醒,我就记住了 如下:

Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root users on this machine.

你的建议很重要,确实应该放到用户目录下,很感谢,不过有没有必要去掉 系统目录下的包,一次清掉,128 G 伤不起

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