Cannot change RVM gemset from shell script via `rvm gemset use`

前端 未结 2 1983
挽巷
挽巷 2021-02-03 10:10

(See update at bottom)


I feel like I\'m missing something terribly obvious here, but I can\'t change gemsets from within a shell script. This minimal script demons

相关标签:
2条回答
  • 2021-02-03 10:45

    I ended up implementing the functionality I wanted as a function instead of a shell script.

    function rvmrc {
      rvm gemset create $1
      rvm gemset use $1
      echo "rvm gemset use $1" > .rvmrc
      rvm rvmrc trust
    }
    
    0 讨论(0)
  • 2021-02-03 10:47

    Had exactly the same problem, and here's the solution:

    #!/bin/bash
    
    # IMPORTANT: Source RVM as a function into local environment.
    #            Otherwise switching gemsets won't work.
    [ -s "$HOME/.rvm/scripts/rvm" ] && . "$HOME/.rvm/scripts/rvm"
    
    # Enable shell debugging.
    set -x
    
    rvm 1.9.2@gemset_a
    rvm gemdir
    gem env gemdir
    
    rvm 1.9.2@gemset_b
    rvm gemdir
    gem env gemdir
    

    What I've found out is that your interactive shell has got rvm() and its helpers, whereas script's environment has not got them. rvm binary is executed instead, partially working and thus causing some confusion.

    0 讨论(0)
提交回复
热议问题