Configuring Ruby

Configuring Ruby

A lot of information on this page is for both Linux and Windows. But, because it’s more complicated, the emphasis is on Windows.

Basics

RubyGems Manuals RubyGems Manuals

  • gemhome: location where your gems will be installed.

    Value will override the GEM_HOME environment variable. When not specified the first repository in the gem path will be used.

  • gempath: array of directories where you have gems installed

    The first entry will be used as the default gem installation directory (unless an explicit gemhome config setting or GEM_HOME environment setting is found. This value will override the value of the environment variable GEM_PATH.

File locations

It searches for the files in following order:

  1. /etc/gemrc or %PROGRAMDATA%\gemrc System wide. Note that there is no leading dot

  2. ~/.gemrc / %USERPROFILE%\.gemrc Per user. So this one overrides per system settings.

  3. GEMRC variable. I think this is still not supported. In Windows it’s not, at least for now. Per environment: gemrc files listed in the GEMRC environment variable.

  4. Command line: gem –config-file

Set config

( echo. && echo install: –no-ri –no-rdoc && echo update: –no-ri –no-rdoc ) » “%PROGRAMDATA%\gemrc”

Source

Set PATH’s

mkdir c:/tools/gems/bin
set PATH=c:\tools\gems\bin;%PATH%
ree -i -c -m PATH "c:\tools\gems\bin"

Variables

Both GEM_HOME (and maybe GEM_PATH) should be specified too. Almost every gem (bundler, rake, etc) reads only GEM_HOME variable (and nothing else). To fix it, use (this will set variables to a values from .gemrc):

for /f "tokens=*" %f in ('gem env gemhome') do @(set GEM_HOME=%f)
for /f "tokens=*" %f in ('gem env gempath') do @(set GEM_PATH=%f)

GEMRC: Very important variable

Default is:

set GEMRC=%PROGRAMDATA%\gemrc:%USERPROFILE%\.gemrc

Gists

Install Gems without documentation #ruby #windows Fix Vagrant about environment variables #vagrant

Notes

Example .gemrc file:

install: --no-ri --no-rdoc
update: --no-ri --no-rdoc

gemhome: c:/Tools/gems

gempath:
- c:/Tools/gems
- c:/Tools/ruby193/lib/ruby/gems
date 01. Jan 0001 | modified 10. Jun 2024
filename: Ruby - Configuring