【问题标题】:Can't install JSON gem无法安装 JSON gem
【发布时间】:2011-07-10 03:10:26
【问题描述】:

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

Could not find json-1.4.6 in any of the sources

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

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

更新

我得到这个错误:

安装 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)

【问题讨论】:

    标签: ruby gem bundler


    【解决方案1】:

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

    gem uninstall json
    bundle install
    

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

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

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

    【讨论】:

    • 好的,我做到了。我在顶部有source 'http://rubygems.org。我仍然收到此错误:Could not find json-1.4.6 in any of the sources
    • 您在运行bundle install 是否使用sudo
    • 同,再次检查问题,我添加了有关安装错误的更多信息
    • 好的,再次尝试运行sudo gem uninstall json,确保gem list 没有显示它正在安装。然后sudo rm -rf /Library/Ruby/Gems/1.8/gems/json-1.4.6/。然后再试sudo bundle install
    • 顺便说一句,如果你有时间,看看我的这个问题:stackoverflow.com/questions/5215552/…
    【解决方案2】:

    尝试: $ sudo apt-get install ruby​​1.8-dev

    【讨论】:

      【解决方案3】:

      请通过执行以下命令更新您的 ruby​​gems..

      gem update --system
      

      也许它会解决问题。更新您的宝石后。然后运行以下命令安装json

      gem install json
      

      现在您可以在系统中安装 json gem。

      【讨论】:

      • 为我完成了这项工作,谢谢
      【解决方案4】:

      通过运行 $ heroku logs 检查日志后

      我发现“安装 json (1.4.6) 时出错,Bundler 无法继续。 在捆绑之前确保 gem install json -v '1.4.6' 成功。”

      然后我从 Gemfile.lock 中删除了 2 个 json 条目并且没有其他问题。

      【讨论】:

      • 就是这样。谢谢
      【解决方案5】:

      从 Gemfile.lock 文件中删除 json 条目并尝试重新运行 bundle install..

      【讨论】:

        【解决方案6】:

        如果您使用的是 rbenv,请尝试rbenv rehash

        【讨论】:

          【解决方案7】:

          我在尝试使用 Jekyll 构建网站时遇到了这个问题。

          原来我没有按照https://jekyllrb.com/docs/installation/ubuntu/ 的所有说明进行操作

          我不知道是否是 ~/.bashrc 中缺少包或命令,但它解决了 WSL 中两个 Ubuntu 实例中的问题

          【讨论】:

            猜你喜欢
            • 2011-07-20
            • 1970-01-01
            • 1970-01-01
            • 2017-07-13
            • 1970-01-01
            • 2011-06-28
            • 2013-02-20
            • 2017-06-07
            • 2012-03-25
            相关资源
            最近更新 更多