I have Ruby installed, but I still need to add it to the PATH variable. I found something online for how to manually add it using the command line:
set PATH=
Fear nothing, What you are doing is prepend C:\Ruby200-x64\bin
to the existing %PATH%
, this is what the command you posted does.
The path is a list of directories, separated by ;
, in which the system will look for the command you execute.
In your case it's:
C:\Ruby200-x64\bin
%PATH%
, if you print it on the command line, you'll find it's itself a list of directories separated by ;
.In case you want to make your change permanent, you have to change your PATH sytemwide.
Add or modify the path lines with the paths you want the computer to access. For ruby it will be:
;YOUR_RUBY_INSTALLATION_PATH\bin;
The operation with set PATH=C:\Ruby200-x64\bin;%PATH%
is probably only temporary until you restart your computer.
For CLI, as noted elsewhere calling SET on the path variable only acts on the current window and closing it or restarting windows voids the change.
Example the transient Version selected as the answer:
set "PATH=%PATH%;C:\Ruby200-x64\bin"
To correctly set the path permanently in CLI use the path command:
PATH %PATH%;C:\Ruby200-x64\bin
This will persist between CMD windows and after reboots.
Yes, this is correct. In your example %PATH%
will be expanded to the current value of the PATH variable, so this command is effectively adding a new entry to the beginning of the PATH.
Note that calling set PATH
will only affect the current shell. If you want to make this change permanent for all shells, the simplest option is to set it as a user variable using the Environment Variables dialog box.
On Windows 8 you can open this dialog by hitting Win+s and searching for 'environment variables'. On earlier versions of Windows you can right-click 'My Computer', choose Properties, then Advanced system settings, then Environment variables. You can create (or update) a PATH variable in the user variables section and add whatever entries you need. These will be appended to the existing system path. If you take this approach you will need to open a new cmd shell after updating the variables.
I just wanted to let everyone know that when you install rubyinstaller
on Windows and follow its steps, there is no option to 'add to path variables' because it automatically adds it.
Rubyinstaller
trolled me hard because it said gem
not found when I did gem install sass
immediately after install.
Your path variable is probably already set if you used
rubyinstaller
.The trick is to open CMD or I would imagine, PowerShell, ConEMU, etc, git bash, and type
gem
.
- Press WINKEY and type
cmd
- Type
gem install sass
(or whatever else that is in the bin folder for Ruby)
I just went to add the PATH variable, and it was already set, so my problem was the garbage command line tool that opened after installing rubyinstaller
.
You can also do these steps to add to the PATH variables:
view advanced system settings
Environment Variables
Path
in the listEdit
C:\Ruby24-x64\bin
is already there, if so, doneNew
and type in C:\Ruby24-x64\bin
I know this is questions has the Windows tag, however it is one of the first DuckDuckGo results for "ruby gems add to path" so I just wanted to add this.
On Linux you can add this line to the end of your .bashrc
in order to add it to your path:
export PATH=$PATH:~/.gem/ruby/2.6.0/bin