简体   繁体   English

无法安装json gem

[英]Cannot install json gem

I've had this problem several times and was able to get this fixed by running bundle update , but now I cannot get it working at all. 我已经多次遇到过这个问题了,并且能够通过运行bundle update来解决这个问题,但是现在我根本无法使用它。 I haven't touched my rails app in about 3 weeks and now I come back and have this issue. 我在大约3周内没有触及我的rails应用程序,现在我回来并遇到这个问题。

Here's the error that I'm getting: 这是我得到的错误:

[root:acd9066b01f9:~/inspinia]# bundle update json                                                                                                                                                                                                         7:10PM/04.22
Fetching gem metadata from https://rubygems.org/.............
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Using rake 10.4.2
Using i18n 0.7.0
Fetching json 1.8.6 (was 1.8.3)
Installing json 1.8.6 (was 1.8.3) with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/usr/local/rvm/gems/ruby-2.5.1/gems/json-1.8.6/ext/json/ext/generator
/usr/local/rvm/rubies/ruby-2.5.1/bin/ruby -r ./siteconf20190422-4608-t99jp9.rb
extconf.rb
Cannot allocate memory - /usr/local/rvm/rubies/ruby-2.5.1/bin/ruby -r
./siteconf20190422-4608-t99jp9.rb extconf.rb 2>&1

Gem files will remain installed in
/usr/local/rvm/gems/ruby-2.5.1/gems/json-1.8.6 for inspection.
Results logged to
/usr/local/rvm/gems/ruby-2.5.1/extensions/x86_64-linux/2.5.0/json-1.8.6/gem_make.out

An error occurred while installing json (1.8.6), and Bundler cannot
continue.
Make sure that `gem install json -v '1.8.6' --source 'https://rubygems.org/'`
succeeds before bundling.

In Gemfile:
  rails was resolved to 4.2.3, which depends on
    actionmailer was resolved to 4.2.3, which depends on
      actionpack was resolved to 4.2.3, which depends on
        actionview was resolved to 4.2.3, which depends on
          rails-dom-testing was resolved to 1.0.7, which depends on
            rails-deprecated_sanitizer was resolved to 1.0.3, which depends on
              activesupport was resolved to 4.2.3, which depends on
                json

So as shown above, I can't run bundle update . 如上所示,我无法运行bundle update I've tried adding other versions of Json into the Gemfile, but 1.8.0, 1.8.1 both gave me the same exact error. 我已经尝试将其他版本的Json添加到Gemfile中,但是1.8.0,1.8.1都给了我同样的错误。

I have tried to install other versions of bundler as well: 我也尝试过安装其他版本的bundler:

[root:acd9066b01f9:~/inspinia]# gem install bundler -v '= 1.5.1'                                                                                                                                                                                           7:10PM/04.22
Successfully installed bundler-1.5.1           
Parsing documentation for bundler-1.5.1                 
Done installing documentation for bundler after 0 seconds
1 gem installed    

Which doesn't help, as I run into the exact same problem. 这没有用,因为我遇到了完全相同的问题。

I've also tried some other suggestions mentioned in other posts, including libgmp-dev : 我还尝试了其他帖子中提到的其他一些建议,包括libgmp-dev

[root:acd9066b01f9:~/inspinia]# apt-get install libgmp-dev                                                                                                                                                                                                 7:12PM/04.22
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libgmp-dev is already the newest version (2:6.1.2+dfsg-2).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Any thoughts would be greatly appreciated. 任何想法将不胜感激。 This seems like a repetitive issue that I can never get away from for whatever reason. 这似乎是一个重复的问题,无论出于什么原因我都无法摆脱。

I met this problem many times ago. 我很多次遇到过这个问题。 For ubuntu environment, try to install libgmp3-dev 对于ubuntu环境,请尝试安装libgmp3-dev

sudo apt-get install libgmp3-dev

Then run bundle update json again. 然后再次运行bundle update json

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM