Salah Saleh
Salah Saleh

Reputation: 811

Rubygems issue when runnuing rails new

Sorry this might be a basic question but I am new to rails. I wanted to start a new rails project by the command rails new projName. In the middle of the process I got this message:

run  bundle install

Your user account isn't allowed to install to the system Rubygems.
You can cancel this installation and run:

bundle install --path vendor/bundle

to install the gems into ./vendor/bundle/, or you can enter your password
and install the bundled gems to Rubygems using sudo.

Password:

I wasn't so sure whether I should give my password but I searched and I found that it is safe to do that (or at least that what I understood).

At the end I got this warning:

Warning: You're using Rubygems 2.0.14 with Spring. Upgrade to at least Rubygems 2.1.0 and run `gem pristine --all` for better startup performance.
* bin/rake: spring inserted
* bin/rails: spring inserted

so I tried to run gem install Rubygems and I got:

ERROR:  Could not find a valid gem 'Rubygems' (>= 0) in any repository
ERROR:  Possible alternatives: ruby_gem, ruby_gem_eg, ruby-rets, ruby-gen, rubyless

I tried gem install rubygems-update and I got:

ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

I have already installed rails through RVM, and I am not sure why I am having those permission issues. As I am not experienced with gems I am stuck and don't know how to fix these issues.

Upvotes: 4

Views: 5928

Answers (3)

Andrea Salicetti
Andrea Salicetti

Reputation: 2483

It should be sufficient to run a:

gem update --system

to upgrade Rubygem to the latest version.

Upvotes: 9

Salah Saleh
Salah Saleh

Reputation: 811

Ok, here is how I solved it for reference. I saw the a similar issue in this thread

A step by step solution would be:

  1. Run gem env. You should see a list of paths like so under GEM PATHS:

    /Library/Ruby/Gems/2.0.0

    /Users/sam/.gem/ruby/2.0.0

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0

  2. Open your ~/.bashrc file and add the paths as follows:

    export GEM_HOME=/Library/Ruby/Gems/2.0.0

    export PATH=$PATH:$GEM_HOME:/Users/sam/.gem/ruby/2.0.0:/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0

  3. Open a new shell and run the gem install rubygems-update. Everything should run fine now without sudo.

Upvotes: 4

sansarp
sansarp

Reputation: 1466

Try sudo gem install rubygems-update

Upvotes: 4

Related Questions