无法安装 JSON gem [英] Can't install JSON gem

查看:23
本文介绍了无法安装 JSON gem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要安装 json,因为我收到此错误:

I need to install json because I get this error:

在任何来源中都找不到 json-1.4.6

我运行了 gem install jsonbundle install 但我只能在需要 json-1.4.6 时安装 json-1.5.1

I ran gem install json and bundle install but I was only able to install json-1.5.1 when I need json-1.4.6

我的 gemfile 中有 gem 'json', '1.4.6',所以我不确定发生了什么...

I have gem 'json', '1.4.6' in my gemfile, so I'm not sure what's going on...

更新

我得到这个错误:

安装 json (1.4.6)/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/fileutils.rb:1216:in `chmod': 不允许操作 -/Library/Ruby/Gems/1.8/gems/json-1.4.6/CHANGES (Errno::EPERM)

Installing json (1.4.6) /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/fileutils.rb:1216:in `chmod': Operation not permitted - /Library/Ruby/Gems/1.8/gems/json-1.4.6/CHANGES (Errno::EPERM)

推荐答案

你为什么要运行 gem install json?Bundler 会为您解决这个问题,并确保安装每个 gem 的正确版本(因为有时依赖项需要旧版本).运行

Why did you run gem install json at all? Bundler takes care of that for you and will ensure that the correct version of each gem is installed (since sometimes dependencies require an older version). Run

gem uninstall json
bundle install

还要确保您的 Gemfile 顶部有 source 'https://rubygems.org'.

Also ensure you have source 'https://rubygems.org' at the top of your Gemfile.

至于权限信息,您可能需要使用 sudo 运行 gembundle 命令.

As for the permissions info, you may have to run gem and bundle commands with sudo.

顺便说一下,我强烈建议查看并使用 RVM,尤其是gemsets 功能.在开发 Ruby 应用程序时,它将让您的生活变得无限美好.如果您决定这样做,我还建议您通过运行 sudo rm -rf/Library/Ruby/Gems/1.8/ 来丢弃您使用系统 Ruby 安装的所有 gem.同样重要的是,在使用 RVM 时,您不必在运行 gem(或 bundle)时使用 sudo,这不仅更安全,而且打字也少.

By the way, I highly recommend taking a look at and using RVM, particularly the gemsets feature. It will make your life infinitely better when developing Ruby apps. If you decide to do so, I'd also suggest trashing all the gems you've install using the system Ruby by running sudo rm -rf /Library/Ruby/Gems/1.8/. It's also important that when using RVM you don't have to use sudo when running gem (or bundle), which is not only safer but less typing too.

这篇关于无法安装 JSON gem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆