I'm a NOVICE user of Linux and using Linux mint 17.1

I've reinstalled Linux Mint 20 time in last 3 days for that issue but could not fix it

I'm trying to install ruby on rails using rvm what happened is if start a new Linux installation and try installing gems and ruby and stuff in one terminal session it installed successfully as soon as I close the terminal session I can't get those gems.

By reinstalling it over 20 times in last 3 days I've searched on the web too. I've been told to put environment variable in /etc/environment I echoed path in that session and pasted that in /etc/environment file.

even now I don't get my installed gems

when I typed rvm -v I get the following errors

Warning: PATH set to RVM ruby but GEM_HOME and/or GEM_PATH not set, see:

Warning! PATH is not properly set up, $GEM_HOME is not set,
         usually this is caused by shell initialization files - check them for 'PATH=...' entries,
         it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
         to fix temporarily in this shell session run: 'rvm use ruby-2.2.2'.
rvm 1.26.11 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

I'm a very novice person when it comes to working with terminal I can run few basic commands to work with ruby.

I would like to know

  1. How to set PATH
  2. How to set GEM_HOME
  3. How to set GEM_PATH

Below is my full path

echo $PATH

6 Answers 6


Sounds like you want the command export for setting environment variables:

export PATH=$PATH':/path/to/add'
export GEM_HOME=$HOME/.gem
export GEM_PATH=$HOME/.gem

That will only take effect for the current session, though. To make them more permanent, add those lines to your ~/.bashrc.


Usually this means that rvm is not setup correctly. The usual mistake is that you didn't modify your .bashrc correctly (or similar) or you did not reload your terminal.

You should not set GEM_HOME or GEM_PATH manually when using rvm.

You can try source ~/.rvm/scripts/rvm and see if that works.

It could also be that you have not built a gemset yet. Do not use rvm and sudo. Rvm works best when installed in your account ant not system wide.

  • You can also add source ~/.rvm/scripts/rvm to your ~/.bashrc to make sure it is loaded every time you start a new shell. Oct 19, 2016 at 4:57

Here's what I learned and how I resolved this seemingly common problem of GEM_HOME and GEM_PATH environment variables not set error.


RVM install is supposed to create GEM_HOME and GEM_PATH env vars for each RVM that is setup and it does that. But there's a bug apparently such that in some cases the env vars are only set temporarily, and to set them again you have to set them with the command line. I found a workaround to make the env vars persist for an RVM.


  1. Find your active (in the RVM) Ruby version: On your production server go to your app directory and type $rvm list. This will result in a list of the Ruby versions installed and which one is active for the RVM. Example of the response:

    rvm rubies ruby-1.9.3-p547 [ x86_64 ] => ruby-1.9.3-p551 [ x86_64 ]

So, I know that the RVM is currently using version ruby-1.9.3-p551. You need this info for the next step.

  1. Get the paths for GEM_PATH and GEM_HOME: You do this by executing from the command line $rvm use ruby-1.9.3-p551. Then still from the comman line show all the environment settings using the commandenv. Search for GEM_PATH and GEM_HOME and copy those in their entirety to a workspace.

    GEM_PATH=/usr/local/rvm/gems/ruby-1.9.3-p551:/usr/local/rvm/gems/ruby-1.9.3-p551@global GEM_HOME=/usr/local/rvm/gems/ruby-1.9.3-p551

  2. Set the GEM_HOME and GEM_PATH environment variables: Now set these environment variables in one of the many profile files. I wanted to maintain the RVM version isolation structure, so I updated the /profile.d/appspecific.sh with these two lines:

    export GEM_PATH=/usr/local/rvm/gems/ruby-1.9.3-p551:/usr/local/rvm/gems/ruby-1.9.3-p551@global export GEM_HOME=/usr/local/rvm/gems/ruby-1.9.3-p551

  • apparently GEM_HOME and GEM_PATH are not specific to RVM?
    – barlop
    Aug 10, 2019 at 15:41

I found that .profile gets loaded last and that puts ~/.local/bin and ~/bin in the front of the path. I moved /etc/profile.d/rvm.sh to ~/.rvm and at the very end of .profile I added "source ~/.rvm/rvm.sh" and the error is gone. I'm on Linux Mint 18.3. I have pyenv, rvm and sdkman installed and they all want to be last. They're all working fine now. :)

If it's a shared system just move rvm.sh somewhere out of the path and any other user can source it, like from /opt/rvm/rvm.sh for instance.


Like @coteyr mentioned, you shouldn't manually set GEM_HOME and GEM_PATH when using rvm. If you check your PATH environment variable, by running $ echo $PATH and $HOME/.rvm/bin is part of it, then you need to make sure your terminal runs commands as a login shell. For example if you are on an Ubuntu machine, you open up your terminal then go to: menu > Edit > Profile Preferences > Command then select "Run command as a login shell"

This appears to be an old issue with rvm which I assume is not trivial to fix since it has been around for a while.


For populating $GEM_PATH with my system (Manjaro / Arch) gems I added to my .bashrc:

for _entry in /usr/lib/ruby/gems/*; do
  if [[ -d $_entry ]]; then
    # TODO: Add only if not there already
    export GEM_PATH=$_entry:$GEM_PATH
unset _entry

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.