0

I am working through learn ruby the hard way, and I am stuck at the first bit, as it says type ruby -v into power shell and the version number will come up. This doesn't work, what I have to do is navigate to the directory the ruby.exe file is in, and then type ./ruby -v Then it works. How do I make this work when I just type ruby and I don't have to be in the specific directory that ruby is installed in?

1 Answers1

0

Try adding the directory that the ruby.exe file is in to your path variable.

Samir Jha
  • 16
  • 2
  • sorry i don't know much about powershell, I am just a beginner. How do I do that? – Ethan Gascoigne Jul 28 '17 at 16:57
  • @ethan-gascoigne: Check if this helps - [link](https://stackoverflow.com/questions/9546324/adding-directory-to-path-environment-variable-in-windows) – Samir Jha Jul 28 '17 at 17:03
  • The best way is simply through the windows U.I. Control Panel->All Control Panel Items->System->Advanced System Setttings->Environment Variables Scroll down to Path Edit – Samir Jha Jul 28 '17 at 17:06
  • I typed set PATH=%PATH%;C:\Ruby21\bin into powershell, is that it? – Ethan Gascoigne Jul 28 '17 at 17:08
  • @EthanGascoigne No, that was for `cmd.exe` not PowerShell. Doing it through the GUI is probably best if you don't know what you are doing. But if you wanted to do it through PowerShell you could do this in an elevated PowerShell Window: `[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Ruby21\bin", [EnvironmentVariableTarget]::Machine)` which would be persistent or you if just wanted it for the PowerShell session you could do `$ENV:PATH = $env:Path + ";C:\Ruby21\bin"` – BenH Jul 28 '17 at 17:13