[英]Why won't bundler install JSON gem?
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.重要的是要注意这个部署是有效的,而不是我升级到 Ruby 2.1.0 以消除编码错误。 I upgraded locally which worked fine.
我在本地升级,效果很好。 I ran
rvm install 2.1.0
and rvm use 2.1.0
then changed my .ruby-version
file to reflect this Ruby upgrade.我运行了
rvm install 2.1.0
和rvm use 2.1.0
然后更改了我的.ruby-version
文件以反映此 Ruby 升级。
The bundle install
command 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 list
I 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?所以看起来 gem 已经安装了,对吧? Why is this happening?
为什么会这样? How can I solve this?
我该如何解决这个问题? Any help would be greatly appreciated.
任何帮助将不胜感激。
$ bundle update json
$ bundle install
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'
解决方案是使用
gem install bundler -v '= 1.5.1'
更新到 bundler 1.5.1
运行这个命令然后一切都会好的
sudo apt-get install libgmp-dev
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'
This works for me!这对我有用!
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.然后我可以安装 gem 并继续。 Had one more problem that was fixed by:
还有一个问题已修复:
$ sudo apt-get install libsqlite3-dev
Hoping helps.希望有所帮助。
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 对我来说是个窍门。
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.我在尝试使用 Sinatra 和 Postgresql(通过 activerecord)在 rvm'd ruby 2.1 上运行一个项目时遇到了这个错误。 I found my answer here: https://github.com/wayneeseguin/rvm/issues/2511
我在这里找到了答案: 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 构建本机扩展时,我也遇到错误
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-binary
flag once I had done so.为了完整起见,我首先忘记更新 rvm (
rvm get head
),这产生了一些其他错误,但一旦我这样做了,仍然需要--disable-binary
标志。
bundle update json
. bundle update json
。 Helped to get through.帮助过关。
When I tried to install the json gem using gem install json
separate from just using bundle install
I got ERROR: Failed to build gem native extension.
当我尝试使用
gem install json
与仅使用bundle install
分开安装 json gem 时,出现ERROR: Failed to build gem native extension.
, looking that up I found using ,查找我发现使用
apt-get install ruby-dev
did the trick成功了
For OS X make sure you have coreutils对于 OS X 确保你有coreutils
$ brew install coreutils
$ bundle
This appears to be a bug in Bundler not recognizing the default gems installed along with ruby 2.x.这似乎是 Bundler 中的一个错误,无法识别与 ruby 2.x 一起安装的默认 gem。 I still experienced the problem even with the latest version of bundler (1.5.3).
即使使用最新版本的 bundler (1.5.3),我仍然遇到这个问题。
One solution is to simply delete json-1.8.1.gemspec from the default gemspec directory.一种解决方案是简单地从默认 gemspec 目录中删除 json-1.8.1.gemspec。
rm ~/.rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/specifications/default/json-1.8.1.gemspec
After doing this, bundler should have no problem locating the gem.这样做之后,bundler 定位 gem 应该没有问题。 Note that I am using chruby.
请注意,我正在使用 chruby。 If you're using some other ruby manager, you'll have to update your path accordingly.
如果您正在使用其他一些 ruby 管理器,则必须相应地更新您的路径。
I was missing C headers solution was to download it for Xcode, this is the best way.我缺少 C 头文件的解决方案是为 Xcode 下载它,这是最好的方法。
xcode-select --install
Hope it helps.希望能帮助到你。
Bundle 无法安装 json -v '1.8.1' 并删除我的 Gemfile.lock 并再次运行 bundle 为我解决了这个问题。
I installed the latest version of json:我安装了最新版本的json:
gem install json
Then deleted the line json(1.8.1) from the Gemfile.lock and did a然后从 Gemfile.lock 中删除了 json(1.8.1) 行并做了一个
bundle install
And then the Gemfile.lock file uses json(1.8.3) without erros然后 Gemfile.lock 文件使用 json(1.8.3) 没有错误
使用rvm将 ruby 版本从 1.9 切换到 2.2 为我完成了这项工作
For me, some of the answers mentioned earlier were helpful from understanding point of view, but those didn't solve my problem.对我来说,前面提到的一些答案从理解的角度来看是有帮助的,但那些并没有解决我的问题。
So this is what I did to solve issue.所以这就是我为解决问题所做的。
Bundler -v
command).Bundler -v
命令)。 I had version 1.12.5 installedgem install bundler -v '1.11.2'
)gem install bundler -v '1.11.2'
)For macOS Sierra:对于 macOS Sierra:
I ran into this error When i used bundler( v1.15.3
) in Rails( v4.2
) project.当我在 Rails(
v4.2
) 项目中使用 bundler( v1.15.3
) 时遇到了这个错误。 The solution for me is gem uninstall bundler -v '1.15.3'
and gem install bundler -v '1.14.6'
.我的解决方案是
gem uninstall bundler -v '1.15.3'
和gem install bundler -v '1.14.6'
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.