Ruby-on-rails 为什么 bundler 不安装 JSON gem?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21095098/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why won't bundler install JSON gem?
提问by Thomas
I get the following error when attempting to run cap production deploy.
尝试运行时出现以下错误cap production deploy。
DEBUG [dc362284] Bundler::GemNotFound: Could not find json-1.8.1.gem for installation
DEBUG [dc362284] An error occurred while installing json (1.8.1), and Bundler cannot continue.
DEBUG [dc362284] Make sure that `gem install json -v '1.8.1'` succeeds before bundling.
It may be important to note that this deployment was working, than I upgraded to Ruby 2.1.0 to remove an encoding error. I upgraded locally which worked fine. I ran rvm install 2.1.0and rvm use 2.1.0then changed my .ruby-versionfile to reflect this Ruby upgrade.
重要的是要注意这个部署是有效的,而不是我升级到 Ruby 2.1.0 以消除编码错误。我在本地升级,效果很好。我跑rvm install 2.1.0,并rvm use 2.1.0随后改变了我的.ruby-version文件,以反映该红宝石升级。
The bundle installcommand works locally, but produces the same above error when I ssh onto the destination server and run this command.
该bundle install命令在本地工作,但是当我通过 ssh 连接到目标服务器并运行此命令时,会产生上述相同的错误。
If I run gem listI can see this in the list of gems.
如果我运行,gem list我可以在 gems 列表中看到它。
...
jquery-rails (3.0.4)
json (1.8.1)
less (2.3.2)
...
If I try the recommended solution gem install json -v '1.8.1'Locally and on the destination server I get the following output:
如果我在gem install json -v '1.8.1'本地和目标服务器上尝试推荐的解决方案,我会得到以下输出:
Building native extensions. This could take a while...
Successfully installed json-1.8.1
Parsing documentation for json-1.8.1
Done installing documentation for json after 0 seconds
1 gem installed
So it appears the gem is installed, right? Why is this happening? How can I solve this? Any help would be greatly appreciated.
所以看起来 gem 已经安装了,对吧?为什么会这样?我该如何解决这个问题?任何帮助将不胜感激。
采纳答案by Thomas
So after a half day on this and almost immediately after posting my question I found the answer. Bundler 1.5.0 has a bug where it doesn't recognize default gems as referenced here
因此,在对此进行了半天之后,几乎在发布我的问题后,我几乎立即找到了答案。Bundler 1.5.0 有一个错误,它无法识别此处引用的默认 gem
The solution was to update to bundler 1.5.1 using gem install bundler -v '= 1.5.1'
解决方案是使用更新到 bundler 1.5.1 gem install bundler -v '= 1.5.1'
回答by dnvtrn
$ bundle update json
$ bundle install
回答by Jameel Grand
Run this command then everything will be ok
运行这个命令然后一切都会好的
sudo apt-get install libgmp-dev
回答by Juice007
if you are in MacOS Sierra and your ruby version is 2.4.0.The ruby version is not compatible with json 1.8.3.
如果您在 MacOS Sierra 中并且您的 ruby 版本是 2.4.0。The ruby 版本与 json 1.8.3 不兼容。
You can try add this line in your Gemfile:
您可以尝试在 Gemfile 中添加这一行:
gem 'json', github: 'flori/json', branch: 'v1.8'
gem 'json', github: 'flori/json', branch: 'v1.8'
This works for me!
这对我有用!
回答by Rohini Choudhary
回答by Ajeet Khan
回答by Lucas
You should try
你应该试试
$ sudo gem install json -v '1.8.2'
in my case (Ubuntu 14.04) that didn't work directly and I had to do this:
在我的情况下(Ubuntu 14.04)不能直接工作,我必须这样做:
$ sudo apt-get install ruby-dev
and then I could install the gem and continue. Had one more problem that was fixed by:
然后我可以安装 gem 并继续。还有一个问题已修复:
$ sudo apt-get install libsqlite3-dev
Hoping helps.
希望有所帮助。
回答by Adam
If the recommended answer didn't help because you are already using a newer version of bundler. Try the solution that worked for me.
如果推荐的答案没有帮助,因为您已经在使用更新版本的捆绑程序。尝试对我有用的解决方案。
Delete everything inside your vendor folder. Add a line to your gemfile
删除供应商文件夹中的所有内容。在您的 gemfile 中添加一行
gem 'json', '1.8.0'
Then run - bundle update json.
然后运行 - bundle update json。
It seems to be an issue with 1.8.1 so going back to 1.8.0 did the trick for me.
这似乎是 1.8.1 的问题,所以回到 1.8.0 对我来说是个窍门。
回答by Matthias
I ran into this error while trying to get a project to run on my local dev box (OSX 10.6), using Sinatra and Postgresql (through activerecord), running on an rvm'd ruby 2.1. I found my answer here: https://github.com/wayneeseguin/rvm/issues/2511
我在尝试使用 Sinatra 和 Postgresql(通过 activerecord)在 rvm'd ruby 2.1 上运行一个项目时遇到了这个错误。我在这里找到了答案:https: //github.com/wayneeseguin/rvm/issues/2511
My exact problem(after the first block of log entries):
我的确切问题(在第一个日志条目块之后):
I also get an error when trying to build native extensions for gems
尝试为 gems 构建本机扩展时,我也遇到错误
The answer:
的回答:
rvm reinstall 2.1.0 --disable-binary
rvm 重新安装 2.1.0 --disable-binary
The explanation:
的解释:
OSX does not have a package manager so all libraries have to be installed manually by user, this makes it virtually impossible to link the binary dynamically, and as you can see there are problems with the (pseudo)statically linked binary.
OSX 没有包管理器,因此所有库都必须由用户手动安装,这使得动态链接二进制文件几乎不可能,并且如您所见,(伪)静态链接二进制文件存在问题。
For the sake of completeness, I had first forgotten to update rvm (rvm get head), which yielded some other errors, but still needed the --disable-binaryflag once I had done so.
为了完整起见,我首先忘记更新 rvm ( rvm get head),这会产生一些其他错误,但是--disable-binary一旦我这样做了仍然需要标志。
回答by anti-k
bundle update json. Helped to get through.
bundle update json. 帮助过关。

