Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails: Your user account isn't allowed to install to the system RubyGems

I am running the command

bundle install 

in a project folder. In some project folders it will produce an error and in other projects folders it will not produce an error. The error is:

Your user account isn't allowed to install to the system RubyGems

I know this can be fixed by following the recommended advice:

bundle install --path vendor/bundle 

My question is why is the behavior inconsistent?

like image 208
William Entriken Avatar asked Mar 16 '17 20:03

William Entriken


People also ask

How do I download RubyGems?

Open up the 'Software Center' app from your launcher and type in `RubyGems` without quotes into the application search box at the top right, and press [enter]. RubyGems then can be installed by just clicking on the button labeled 'Install', thats it.

Where are RubyGems installed?

When you use the --user-install option, RubyGems will install the gems to a directory inside your home directory, something like ~/. gem/ruby/1.9. 1 . The commands provided by the gems you installed will end up in ~/.


2 Answers

In my case, I solved doing just what the error message suggests:

 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/ 

So, instead of:

bundle install 

I ran:

bundle install --path vendor/bundle 

That was the solution for this guy.

The downside of that solution is that it creates a vendor folder inside the current folder, which can be added to .gitignore if it is to distribute the application through Git.

like image 179
Antônio Medeiros Avatar answered Oct 08 '22 09:10

Antônio Medeiros


Usually if you're using RVM, rbenv or chruby to install Ruby, all the gems will be installed in your home folder under ~/.rbenv/ruby-version/...

If you're using your system Ruby though (the one that is installed by default) the gems are installed alongside it in a location that you don't have access to without sudo.

My guess would be that your version manager defaults to the system Ruby but some of your projects have a .ruby-version file in them that tells it to use a different version of Ruby which you have access to.

like image 36
isaacsloan Avatar answered Oct 08 '22 09:10

isaacsloan