0

I am trying to install Rails on Mac OS (Mavericks) but for some reason it won't let me. I already have Ruby installed. Here is the error and set of gems I already have:

[~] ruby-2.2.1 $ sudo gem install rails
Password:
ERROR:  Error installing rails:
invalid gem: package is corrupt, exception while verifying: undefined method `size' for nil:NilClass (NoMethodError) in /Users/garrettgalvin/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/cache/nokogiri-1.6.6.2.gem

actionview (4.2.3)
activesupport (4.2.3)
bigdecimal (1.2.6)
builder (3.2.2)
bundler (1.10.5)
bundler-unload (1.0.2)
erubis (2.7.0)
executable-hooks (1.3.2)
gem-wrappers (1.2.7)
i18n (0.7.0)
io-console (0.4.3)
json (1.8.1)
loofah (2.0.2)
mini_portile (0.6.2)
minitest (5.7.0)
psych (2.0.8)
rails-deprecated_sanitizer (1.0.3)
rails-dom-testing (1.0.6)
rails-html-sanitizer (1.0.2)
rake (10.4.2)
rdoc (4.2.0)
rubygems-bundler (1.4.4)
rubygems-update (2.4.8)
rvm (1.11.3.9)
thread_safe (0.3.5)
tzinfo (1.2.2)

Any ideas?

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Garrettg
  • 9
  • 1
  • If the package is corrupt you may need to install it again. Does it always do this? Are you able to visit [Rubygems](https://rubygems.org/) without it being redirected somewhere? – tadman Jul 09 '15 at 21:51
  • 2
    Also, you shouldn't use sudo when installing gems. – nil Jul 09 '15 at 22:03
  • possible duplicate of [Install Rails Error "invalid gem: package is corrupt"](http://stackoverflow.com/questions/20850737/install-rails-error-invalid-gem-package-is-corrupt) – Brad Werth Jul 09 '15 at 22:25
  • 2
    Don't do `sudo gem install rails`. That will install Rails into Apple's installed Ruby, which is there for their use. Instead, use RVM or rbenv to install Ruby in a sandbox, then install Rails there using `gem install rails`. – the Tin Man Jul 09 '15 at 23:18
  • @theTinMan actually this depends on the setup, it may install in the correct location, but mess up the file permissions – Vasfed Feb 06 '16 at 13:05
  • The OP is using RVM to manage Ruby. The RVM authors specifically say to NOT use `sudo` when installing gems. – the Tin Man Feb 06 '16 at 20:09

1 Answers1

0

You should never install gems using sudo.

If, while installing your package, you get any gem corruption errors, then you have to do the installation again and make sure you delete the respective gem in the .rvm file. (Search and delete all of the gems with that name.)

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Sk. Irfan
  • 299
  • 3
  • 15