LinuxmacOSWindows

Where Does RubyGems Install Gems?

Gems install into a versioned gem home plus a user dir. How gem env reveals the real paths on each OS.

Last updated

RubyGems installs each gem version into its own folder under a gem home. The system gem home lives inside the Ruby install and includes the ABI version, like gems/3.3.0. User installs go to ~/.gem/ruby/<version>, or ~/.local/share/gem when ~/.gem does not exist yet.

The command gem env settles every dispute. It prints the install dir, the user dir, executable dir, and full gem paths. GEM_HOME forces the install target, GEM_PATH forces the search list. Most confusion comes from mixing system Ruby with a manager Ruby.

Where RubyGems stores this, by platform

Linux
~/.gem/ruby

Run gem env gemdir to print the live install dir. System Rubies use unwritable prefixes, so plain users fall back to ~/.gem or ~/.local/share/gem automatically.

macOS
~/.gem/ruby

Homebrew Ruby nests gems under its Cellar prefix plus the user dir. gem env shows both. Manager installs (rbenv, mise, RVM) each get their own gem home per Ruby version.

Windows
%USERPROFILE%\.gem\ruby

RubyInstaller places the system gem home under the install dir, e.g. C:\Ruby33-x64\lib\ruby\gems. User installs use %USERPROFILE%\.gem. Check gem env since drive letters and versions vary.

Frequently asked questions

how do i find where gems install

Run gem env and read INSTALLATION DIRECTORY plus USER INSTALLATION DIRECTORY. gem env gemdir prints the install target alone. GEM_HOME and GEM_PATH override when set, so check env first if paths look odd.

should i use sudo gem install

Use gem install --user-install or a version manager instead. Sudo scatters root owned files through system Ruby dirs and breaks later updates. User installs land in ~/.gem/ruby/<version> or ~/.local/share/gem and stay on the load path.

Notice an outdated path? Let us know.