How to have multiple versions of Ruby AND Rails, and their combinations on Windows?

前端 未结 4 1058
再見小時候
再見小時候 2020-12-07 11:34

Since Windows doesn\'t support rvm (Ruby version Manager), how do we have

  • Ruby 1.8.7, Rails 2.3.8
  • Ruby 1.8.7, Rails 3.0.0
  • Ruby 1.9.2, Rai
4条回答
  •  难免孤独
    2020-12-07 12:29

    I wrote myself a little batch file which creates a junction (aka symlinks) on the NTFS. The idea is to keep the PATH untouched. The path always contains c:\devkit\bin;c:\ruby\bin;.... The following Batch file changes the links to the actual directories.

    @echo off
    echo 1 - Ruby 1.9.3
    echo 2 - Ruby 2.0.0 (32 bit)
    echo 3 - Ruby 2.0.0 (64 bit)
    choice /C 123 /M "Which Ruby? "
    
    if errorlevel 255 goto confused
    if errorlevel 3 goto 3
    if errorlevel 2 goto 2
    if errorlevel 1 goto 1
    if errorlevel 0 goto 0
    goto confused
    
    :1
    if exist c:\ruby rmdir c:\ruby
    if exist c:\devkit rmdir c:\devkit
    mklink /j c:\ruby c:\ruby193
    mklink /j c:\devkit c:\devkit-4.5.2
    goto end
    
    :2
    if exist c:\ruby rmdir c:\ruby
    if exist c:\devkit rmdir c:\devkit
    mklink /j c:\ruby c:\ruby2-x86
    mklink /j c:\devkit c:\devkit-x64
    goto end
    
    :3
    if exist c:\ruby rmdir c:\ruby
    if exist c:\devkit rmdir c:\devkit
    mklink /j c:\ruby c:\ruby2-x64
    mklink /j c:\devkit c:\devkit-x64
    goto end
    
    :confused
    echo I'm confused ...
    
    :end
    ruby -v
    

提交回复
热议问题