2
votes

I have Ruby installed on my Mac, but when I try gem install rails I get the following error message:

Could not find a valid gem 'rails' (>= 0), here is why:
Unable to download data from https://rubygems.org/ - Errno::ENOMEM: Cannot allocate memory - connect(2) (https://rubygems.org/latest_specs.4.8.gz)

I've tried several other gems and get the same message. I'm not sure what this means, can anyone suggest anything?

Output of gem env:

RubyGems Environment:

  • RUBYGEMS VERSION: 2.0.3
  • RUBY VERSION: 2.0.0 (2013-06-27 patchlevel 247) [universal.x86_64-darwin13]
  • INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.0.0
  • RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
  • EXECUTABLE DIRECTORY: /usr/bin
  • RUBYGEMS PLATFORMS:
    • ruby
    • universal-darwin-13
  • GEM PATHS:
    • /Library/Ruby/Gems/2.0.0
    • /Users/brent/.gem/ruby/2.0.0
    • /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/ 2.0.0
  • GEM CONFIGURATION:
    • :update_sources => true
    • :verbose => true
    • :backtrace => false
    • :bulk_threshold => 1000
  • REMOTE SOURCES:
6
Also... I checked my gem install and it's up-to-date. just FYIbsuggs13
Run gem env at the command-line and add its output to your question by editing it.the Tin Man
It says you're out of memory. Are you out of memory?Michael Hampton
I am seeing this same problem too and have no idea what is wrong. At best this is a really poor error message; my system is not out of memory.Kevin Borders

6 Answers

5
votes

I had this problem, and it was due to Norton Firewall. Apparently, the firewall is never prompting for application blocking when sudo is called in this way. Consequently, the network access is blocked. Temporarily disabling the firewall fixed the error.

This also may explain why other solutions work, including other terminal apps-- they may have been previously granted network access.

0
votes

It looks like "Ruby" isn't installed or working properly.

I recommend using "RVM (Ruby Version Manager)", but, if you need to go the other way, then make sure Ruby is installed in your system. List your gems and grep for Ruby. Then install Rails.

I'm assuming other stuff like bundler or permissions are going to be dealt with.

0
votes

Don't use system ruby. You're going to need to install a ruby-manager like RVM or rbenv.

I really like this shell script from thoughtbot - https://github.com/thoughtbot/laptop

You're going to have to install Xcode and the additional developer tools and command-line tools from Xcode.

Afterward run the thoughtbot script. It will take a while once you get it going. So go make some coffee. This will install homebrew, rbenv and setup everything.

0
votes

Since there seems to be no working answer, if you guys are still stuck with the issue, I suggest the following workaround (which works for me on OS X Mavericks): 1) This seems to be a Terminal related issue. 2) Therefore, please try your commands ("gem install rails" or "gem install compass") in an iTerm2 (http://www.iterm2.com) console.

0
votes

I too got the same error and it was my network that was causing the error. Check your network connections and proxy settings.

-2
votes

You should really use Bundler.

"test-rails" is an example of a really simple Rails app that installs the Rails gem via bundler.

You don't need to have Rails installed as a system-level gem. Save yourself the future headache and start right away with Bundler - you won't regret it.