Search code examples
rubyrvmtcsh

How do I use RVM with tcsh?


I would like to use RVM with tcsh; how do I do this?

As far as I can see, there are no "official" instructions for this. I followed the instructions on "Using RVM with tcsh", but this didn't work for me; in particular, I don't have access to the Ruby binaries ruby, bundle, irb, rspec, etc.


Solution

  • What I did was get all rvm-related environment variables from bash with env | grep -i rvm.

    I then copied them to my ~/.tcshrc, and substituted the ruby version with $ruby_version:

    if ( ! $?ruby_version ) then
        set ruby_version = `grep RUBY_VERSION ~/.rvm/environments/default | cut -d= -f2 | tr -d \' | sed 's/^ruby-//'`
    end
    
    setenv rvm_bin_path $HOME/.rvm/bin
    setenv GEM_HOME $HOME/.rvm/gems/ruby-$ruby_version
    setenv IRBRC $HOME/.rvm/rubies/ruby-$ruby_version/.irbrc
    setenv MY_RUBY_HOME $HOME/.rvm/rubies/ruby-$ruby_version
    setenv rvm_path $HOME/.rvm
    setenv rvm_prefix $HOME
    setenv PATH $HOME/.rvm/gems/ruby-$ruby_version/bin:$HOME/.rvm/gems/ruby-$ruby_version@global/bin:$HOME/.rvm/rubies/ruby-$ruby_version/bin:${PATH}:$HOME/.rvm/bin
    setenv GEM_PATH $HOME/.rvm/gems/ruby-${ruby_version}:$HOME/.rvm/gems/ruby-${ruby_version}@global
    

    $ruby_version will be set to the default; if it's empty; to use a different ruby version, I can do:

    % set ruby_version = 1.9.3-p547
    % source ~/.tcshrc
    

    Using (some) rvm commands, such as rvm install or rvm list also seem to work; but rvm use doesn't (you need to use the $ruby-version workaround). I didn't check all the other commands, though.