Search code examples
ruby-on-railsrubybundler

Can't Install Bundler, no permissions


Im using Ubuntu 15.10. This is the code I write in the terminal

gem install bundler
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /var/lib/gems/2.1.0 directory.

Why is it trying to install it there? of course it doesn't have permissions to install it in the root directory. If I try the same command like this sudo gem install bundler it works. But it is not supposed to be installed as sudo, it gives me problems when creating a new Rails app. What should I do?


Solution

  • You should probably start by running gem env and look at your default environment.

    You can change the default installation directory by exporting a different GEM_HOME:

    export GEM_HOME=$HOME/.gem/