How do I use RVM with tcsh?

2019-07-26 18:08发布

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.

标签: ruby rvm tcsh
2条回答
做自己的国王
2楼-- · 2019-07-26 18:33

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.

查看更多
祖国的老花朵
3楼-- · 2019-07-26 18:44

This worked well for me on OS X Yosemite 10.10.2, though it adds about a 5-second delay to opening a Terminal window each time due to the RVM initialization.

Create this file:
https://gist.github.com/chetstone/1361149

I put it in ~/.rvm/rvm.rb

chmod +x rvm.rb

Add to your .cshrc/.tcshrc:

alias rvm 'eval `~/.rvm/rvm.rb \!*`'
rvm use ruby --default

ruby -v now returns the correct version.

查看更多
登录 后发表回答