Fish Shell support

Issue #93 closed
Former user created an issue

Fish shell badly needs a proper ruby manager. Most current solutions are half-baked jury-rigged solutions based on rvm/rbenv/chruby etc. They are all highly brittle, don't work well with third party tools such as editors etc.

Comments (9)

  1. Jon repo owner

    While I don't currently use fish, I'm fine with adding support if it doesn't add too much complexity.

    1. You're now the QA team for this issue.
    2. What distro do you primarily use fish on?
    3. What fish blog should I read to spin up the quickest?
    4. In *nix environments I inject the uru shell function by having the user append echo 'eval "$(uru_rt admin install)"' into the relevant shell startup file. What fish startup file should this be injected into so that both graphical and non-graphical environments get the uru cmd?
  2. Jon repo owner

    Initial fish support is working except for this one showstopper issue.

    Fish returns error (i.e. - $status == 1) for the first set -x PATH in ~/.uru/uru_lackee.fish because the /_U1_ and /_U2_ canaries are nonexistent dirs.

    # autogenerated by uru
    set -x PATH /_U1_ /home/jon/.gem/ruby/2.3.0/bin /home/jon/.rubies/ruby-2.3.0/bin /_U2_ /opt/git/bin /home/jon/godev/mygo/bin /usr/local/go/bin /home/jon/bin /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/games /usr/local/games ^/dev/null
    set -x GEM_HOME /home/jon/.gem/ruby/2.3.0
    

    Oddly, fish warns the user and sets PATH even though it returns error. This error appears to prevent the second set -x GEM_HOME from running.

    Need a clean way of having fish ignore the error code from the first set so that GEM_HOME can be set when a ruby is activated.

    UPDATE: when run from an interactive shell via source uru_lackee.fish, both PATH and GEM_HOME are set properly. Why is it not working (i.e PATH set, but GEM_HOME not set) when sourced from within the uru function? TODO...look into function scoping issues with setting a new envar (GEM_HOME) vs. updating an existing envar (PATH).

  3. Jon repo owner

    Using set -gx ... solves the missing GEM_HOME issue. uru and fish now appear to play well together.

    Try the new rc2 downloads and let me know how things work.

    After putting uru_rt on your PATH, install uru in fish via echo 'uru_rt admin install | source' >> ~/.config/fish/config.fish

    /home/jon
    $ functions uru
    function uru --description 'Manage your ruby versions'
            set -x URU_INVOKER fish
    
      # uru_rt must already be on PATH
      uru_rt $argv
    
      if test -d "$URU_HOME" -a -f "$URU_HOME/uru_lackee.fish"
        source "$URU_HOME/uru_lackee.fish"
      else if test -f "$HOME/.uru/uru_lackee.fish"
        source "$HOME/.uru/uru_lackee.fish"
      end
    end
    
    /home/jon
    $ uname -sorvp
    Linux 4.8.0-27-generic #29-Ubuntu SMP Thu Oct 20 21:03:13 UTC 2016 x86_64 GNU/Linux
    
    /home/jon
    $ echo $SHELL
    /usr/bin/fish
    
    /home/jon
    $ fish --version
    fish, version 2.3.1
    
    /home/jon
    $ uru ls --verbose
        232p212-x64 : ruby 2.3.2p212 (2016-11-12 revision 56722) [x86_64-linux]
                      ID: 2.3.2-p212
                      Home: /home/jon/.rubies/ruby-2.3.0/bin
                      GemHome: /home/jon/.gem/ruby/2.3.0
    
    /home/jon
    $ uru 23
    ---> now using ruby 2.3.2-p212 tagged as `232p212-x64`
    
    /home/jon
    $ uru ls
     => 232p212-x64 : ruby 2.3.2p212 (2016-11-12 revision 56722) [x86_64-linux]
    
    /home/jon
    $ env | egrep '^GEM_HOME|^PATH'
    GEM_HOME=/home/jon/.gem/ruby/2.3.0
    PATH=/_U1_:/home/jon/.gem/ruby/2.3.0/bin:/home/jon/.rubies/ruby-2.3.0/bin:/_U2_:/opt/git/bin:/home/jon/godev/mygo/bin:/usr/local/go/bin:/home/jon/bin:/opt/git/bin:/home/jon/godev/mygo/bin:/usr/local/go/bin:/home/jon/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
    
    /home/jon
    $ ruby --version
    ruby 2.3.2p212 (2016-11-12 revision 56722) [x86_64-linux]
    
    /home/jon
    $ gem --version
    2.6.8
    
    /home/jon
    $ uru nil
    ---> removing non-system ruby from current environment
    
    /home/jon
    $ uru ls
        232p212-x64 : ruby 2.3.2p212 (2016-11-12 revision 56722) [x86_64-linux]
    
    /home/jon
    $ env | egrep '^GEM_HOME|^PATH'
    PATH=/opt/git/bin:/home/jon/godev/mygo/bin:/usr/local/go/bin:/home/jon/bin:/opt/git/bin:/home/jon/godev/mygo/bin:/usr/local/go/bin:/home/jon/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
    
  4. Jon repo owner

    The rc3 downloads now support fish in msys2 and cygwin in windows environments.

    Jon@BLACK ~> uname -a
    MSYS_NT-6.3 BLACK 2.6.0(0.304/5/3) 2016-09-07 20:45 x86_64 Msys
    
    Jon@BLACK ~> fish --version
    fish, version 2.4.0
    
    Jon@BLACK ~> cat ~/.config/fish/config.fish
    set -x PATH /c/tools $PATH
    set -x SHELL /usr/bin/fish
    set -x URU_HOME /c/Users/Jon/.uru
    
    # infect shell with uru function
    uru_rt admin install | source
    
    
    Jon@BLACK ~> functions uru
    function uru --description 'Manage your ruby versions'
            set -x URU_INVOKER fish
    
      # uru_rt must already be on PATH
      uru_rt $argv
    
      if test -d "$URU_HOME" -a -f "$URU_HOME/uru_lackee.fish"
        source "$URU_HOME/uru_lackee.fish"
      else if test -f "$HOME/.uru/uru_lackee.fish"
        source "$HOME/.uru/uru_lackee.fish"
      end
    end
    
    
    Jon@BLACK ~> uru ver
    uru v0.8.3.rc3 [windows/386 go1.7.3]
    
    Jon@BLACK ~> uru ls
        226p384-x32 : ruby 2.2.6p384 (2016-10-27 revision 56505) [i386-mingw32]
        232p212-x32 : ruby 2.3.2p212 (2016-11-12 revision 56722) [i386-mingw32]
        jruby       : jruby 9.1.5.0 (2.3.1) 2016-09-07 036ce39 Java HotSpot(TM) 64-Bit...
    
    Jon@BLACK ~> uru 23
    ---> now using ruby 2.3.2-p212 tagged as `232p212-x32`
    
    Jon@BLACK ~> uru ls
        226p384-x32 : ruby 2.2.6p384 (2016-10-27 revision 56505) [i386-mingw32]
     => 232p212-x32 : ruby 2.3.2p212 (2016-11-12 revision 56722) [i386-mingw32]
        jruby       : jruby 9.1.5.0 (2.3.1) 2016-09-07 036ce39 Java HotSpot(TM) 64-Bit...
    
    Jon@BLACK ~> ruby --version
    ruby 2.3.2p212 (2016-11-12 revision 56722) [i386-mingw32]
    
    Jon@BLACK ~> gem --version
    2.6.8
    
    Jon@BLACK ~> env | egrep '^GEM_HOME|^PATH'
    PATH=/U/_U1_:/C/Apps/rubies/ruby-2.3/bin:/U/_U2_:/C/tools:/C/Apps/DevTools/msys64/usr/local/bin:...
    PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
    
    Jon@BLACK ~> uru nil
    ---> removing non-system ruby from current environment
    
    Jon@BLACK ~> uru ls
        226p384-x32 : ruby 2.2.6p384 (2016-10-27 revision 56505) [i386-mingw32]
        232p212-x32 : ruby 2.3.2p212 (2016-11-12 revision 56722) [i386-mingw32]
        jruby       : jruby 9.1.5.0 (2.3.1) 2016-09-07 036ce39 Java HotSpot(TM) 64-Bit...
    
  5. Lin

    You should create a landing page so more people will know about uru. It is a much better alternative than the other shell switchers, a blogpost about using it with chruby may also encourage adoption.

  6. Jon repo owner

    Support Fish on *nix and Cygwin/MSYS2. Closes #93

    Install the uru function in the Fish shell via

    echo 'uru_rt admin install | source' >> ~/.config/fish/config.fish

    The above method is preferred as it allows the uru function to be dynamically updated with minimal or no inconvenience to the user.

    Another method to install uru is to create a persistent function via

    echo 'uru_rt admin install | source' > ~/.config/fish/functions/uru.fish

    → <<cset 534ffc463b22>>

  7. Log in to comment