I'm on a Windows machine, so unfortunately I can't use RVM, which would make this super easy.
I previously downloaded Rails and Ruby on a new Windows machine. Rails 4.0.3
and Ruby 1.9.3
. For some reason, the package I installed didn't install the new version of ruby. So I just went to http://rubyinstaller.org/downloads/ and downloaded Ruby 2.0.0. If I browse to my Apps to access the Start Command Prompt with Ruby, the version is 2.0.0 (ruby -v
). But I use Git Bash, http://git-scm.com/downloads, as my Command Line. Right now, the current ruby version is still 1.9.3
in my Git Bash window. How do I update it to use the newly downloaded Ruby 2.0.0
???
Thanks for the help.
Issuing
$ which ruby
will tell you which of the two ruby executables GIT Bash wants to use.
For situations where it is necessary to have two versions of Ruby, it's possible to select one or other for general use using the PATH environment variable.
The order of paths in the Bash $PATH environment variable is important - if the path for your ruby 1.9.3 executable appears before the path for your ruby 2.0.0 executable, then the interpreter will use the 1.9.3. So, for example;
And your PATH variable is as follows;
$ echo $PATH
/c/GIT/bin:.:/c/Software/Ruby/1.9.3/:/c/Program Files/Ruby/2.0.0/
Then you would need to re-order your PATH variable so that the 2.0.0 path comes before the 1.9.3 path. Find your .bashrc file (by default in your home directory) and examine any PATH definitions, e.g.;
PATH=$PATH:/c/Program Files/Ruby/2.0.0/
And modify so that your 2.0.0 path has precedence
PATH=/c/Program Files/Ruby/2.0.0/:$PATH
You can issue this command on the command line also, making sure to do
$ export $PATH
once you've made your changes. Otherwise you'll need to source .bashrc or start a new shell. GIT Bash should then pick up the correct executable.
An alternative is to create aliases or symbolic links for each executable which specifies their version, such that typing ;
$ ruby193
Executes the 1.9.3 ruby and
$ ruby200
executes the 2.0.0 version.
Aliasing is as follows;
$ alias ruby193=/c/Software/Ruby/1.9.3/ruby.exe
Linking is as follows;
$ ln -s /c/Software/Ruby/1.9.3/ruby.exe /c/GIT/bin/ruby193
Aliases you use frequently should be put in .bashrc .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With