how to use 2 versions on windows 8.1

Issue #69 resolved
Former user created an issue

I have installed two different version of ruby installer on my system running ruby 1.9.3 and ~>2.0 . I just want the commands that will allow me to switch between any of this two versions. Is it that I will have to add "uru" in front of any command like "uru gem install rails " or what exactly. The wiki is bit ambiguous.

Comments (2)

  1. Jon repo owner

    Once you've installed rubies, the next step is to register those rubies with uru.

    For example, assume you've installed rubies and not added any of them to your system PATH environment variable by default, i.e. you do not have a "system" ruby always on PATH.

    First, register your installed rubies similar to

    C:\>uru admin add C:\Apps\rubies\ruby-2.0.0\bin
    ---> Registered ruby at `C:\Apps\rubies\ruby-2.0.0\bin` as `200p617`
    

    Once you've registered all your rubies with uru, you can confirm uru knows about the rubies using uru ls. On my win8.1 x64 system I have

    # basic listing of all rubies registered with uru, showing any that are currently active on PATH
    C:\>uru ls
        1718        : jruby 1.7.18 (1.9.3p551) 2014-12-22 625381c on Java HotSpot(TM) ...
        200p617     : ruby 2.0.0p617 (2015-01-22 revision 49382) [i386-mingw32]
        215p285-x32 : ruby 2.1.5p285 (2015-01-22 revision 49383) [i386-mingw32]
        220p36-x32  : ruby 2.2.0p36 (2015-01-22 revision 49375) [i386-mingw32]
    
    # verbose listing of rubies registered with uru
    C:\>uru ls --verbose
        1718        : jruby 1.7.18 (1.9.3p551) 2014-12-22 625381c on Java HotSpot(TM) ...
                      ID: 1.7.18
                      Home: C:\Apps\rubies\jruby\bin
                      GemHome:
    
        200p617     : ruby 2.0.0p617 (2015-01-22 revision 49382) [i386-mingw32]
                      ID: 2.0.0-p617
                      Home: C:\Apps\rubies\ruby-2.0.0\bin
                      GemHome:
    
        215p285-x32 : ruby 2.1.5p285 (2015-01-22 revision 49383) [i386-mingw32]
                      ID: 2.1.5-p285
                      Home: C:\Apps\rubies\ruby-2.1\bin
                      GemHome:
    
        220p36-x32  : ruby 2.2.0p36 (2015-01-22 revision 49375) [i386-mingw32]
                      ID: 2.2.0-p36
                      Home: C:\Apps\rubies\ruby-2.2\bin
                      GemHome:
    

    You can then tell uru to use any of your registered rubies. The simplest way is to "activate" (aka put a specific ruby on your PATH) rubies and use similar to

    # activate a registered ruby with a tag name matching 200
    C:\>uru 200
    ---> Now using ruby 2.0.0-p617 tagged as `200p617`
    
    # confirm the ruby is activated, meaning, the ruby is active on your PATH
    C:\>uru ls
        1718        : jruby 1.7.18 (1.9.3p551) 2014-12-22 625381c on Java HotSpot(TM) ...
     => 200p617     : ruby 2.0.0p617 (2015-01-22 revision 49382) [i386-mingw32]
        215p285-x32 : ruby 2.1.5p285 (2015-01-22 revision 49383) [i386-mingw32]
        220p36-x32  : ruby 2.2.0p36 (2015-01-22 revision 49375) [i386-mingw32]
    
    # use the activated ruby
    C:\>ruby -ve "puts %Q[Hello from #{RUBY_VERSION} and uru]"
    ruby 2.0.0p617 (2015-01-22 revision 49382) [i386-mingw32]
    Hello from 2.0.0 and uru
    
    # switch to another registered ruby, confirm it is active, and use it
    C:\>uru 215
    ---> Now using ruby 2.1.5-p285 tagged as `215p285-x32`
    
    C:\>uru ls
        1718        : jruby 1.7.18 (1.9.3p551) 2014-12-22 625381c on Java HotSpot(TM) ...
        200p617     : ruby 2.0.0p617 (2015-01-22 revision 49382) [i386-mingw32]
     => 215p285-x32 : ruby 2.1.5p285 (2015-01-22 revision 49383) [i386-mingw32]
        220p36-x32  : ruby 2.2.0p36 (2015-01-22 revision 49375) [i386-mingw32]
    
    C:\>ruby -ve "puts %Q[Hello from #{RUBY_VERSION} and uru]"
    ruby 2.1.5p285 (2015-01-22 revision 49383) [i386-mingw32]
    Hello from 2.1.5 and uru
    
    # deactivate all rubies, i.e. remove all rubies from PATH
    C:\>uru nil
    ---> removing non-system ruby from current environment
    
    C:\>uru ls
        1718        : jruby 1.7.18 (1.9.3p551) 2014-12-22 625381c on Java HotSpot(TM) ...
        200p617     : ruby 2.0.0p617 (2015-01-22 revision 49382) [i386-mingw32]
        215p285-x32 : ruby 2.1.5p285 (2015-01-22 revision 49383) [i386-mingw32]
        220p36-x32  : ruby 2.2.0p36 (2015-01-22 revision 49375) [i386-mingw32]
    

    Regarding your uru gem ... comment, both uru gem ... and uru ruby ... run the specific gem or ruby command for all registered rubies. For example, to install the bundler gem into all rubies registered with ruby you would use uru gem install bundler.

    Similarly, to run a command with all rubies registered with ruby, you would do something like

    C:\>uru ruby -e "puts 'Hello from Ruby'"
    
    ruby 2.0.0p617 (2015-01-22 revision 49382) [i386-mingw32]
    
    Hello from Ruby
    
    
    ruby 2.2.0p36 (2015-01-22 revision 49375) [i386-mingw32]
    
    Hello from Ruby
    
    
    jruby 1.7.18 (1.9.3p551) 2014-12-22 625381c on Java HotSpot(TM) 64-Bit Server VM 1.8.0_31-b13
    +jit [Windows 8.1-amd64]
    
    Hello from Ruby
    
    
    ruby 2.1.5p285 (2015-01-22 revision 49383) [i386-mingw32]
    
    Hello from Ruby
    

    There's more interesting things you can do and the examples wiki page will get you pointed in the right direction.

  2. Log in to comment