Information listed in GEM PATHS

The Ruby environment can be seen with

gem env

Where are the paths (listed under GEM PATHS) stored, so that “gem env” can display them?

I’m asking, because I would like to remove one of the paths. The picture above shows the environment on my private computer. On my business computer, the second path is a network path, where I do not have write permission. Before contacting the IT I would like to change the path to a location where I have permission.

By the way: I’m using the portable version of ruby 2.6.6 on Windows.

They appear to be stored in the environment variables GEM_HOME and GEM_PATH.


$ gem help env

Includes the following:

RubyGems’ default local repository can be overridden with the GEM_PATH and GEM_HOME environment variables. GEM_HOME sets the default repository to install into. GEM_PATH allows multiple local repositories to be searched for gems.

They appear to be stored in the environment variables GEM_HOME and GEM_PATH .

What exactly do you mean with "environment variables’? In my windows environment there are no variables GEM_HOME and GEM_PATH.

Calling ENV inside irb leads to:

So, the question is still valid: How does the command gem env know what do list under “GEM PATHS”?

The first item is c:/PortableApps/Ruby/Ruby26/lib/ruby/gems/2.6.0, which is the default folder of my Ruby.

But how is the second item C:/Users/ped/.gem/ruby/2.6.0 created? Probably by doing on the fly this:

File.join(ENV['HOMEDRIVE'], ENV['HOMEPATH'], '.gem/ruby/2.6.0'])

I mean
When using windows at work, I can access them through the control panel.

They are what ENV is accessing:
So your ‘HOMEPATH’, ‘HOMEDRIVE’ are (windows) environment variables.

What is the value of ENV['GEM_PATH']

The value of ENV[‘GEM_PATH’] is nil:


This makes sence, because the object ENV has no key GEM_PATH.

I tried to illustrate my question with several screenshots, but unfortunately as a new user I am only allowed to insert one picture in an answer. So i have to move on with only text instead of screenshots.

IT has mapped my HOMEDRIVE (usually c:) to a network directory.

ap ENV leads to:

“HOME” => “H:/”
“HOMEPATH” => “\”

But directly on this HOMEDRIVE I don’t have write access. In HOMEDRIVE they created a directory Documents where I have write access. On H itself I have no write permissions.

gem env leads to:


  • <path/to/my/ruby/>/lib/ruby/gems/2.6.0
  • H:/.gem/ruby/2.6.0

But there is no directory H:/.gem/ruby/2.6.0. For this reason I wondered how the directory gets into GEM PATHS. It would be great if I could tell ruby to use instead H:/Documents/.gem/...

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs