开发者

Set rvm default interpreter in user's .rvmrc?

开发者 https://www.devze.com 2023-03-16 10:07 出处:网络
I\'m curious if it\'s possible to set my default开发者_C百科 Ruby interpreter within my $HOME/.rvmrc file (i.e. the equivalent of a rvm --default use 1.9.2).

I'm curious if it's possible to set my default开发者_C百科 Ruby interpreter within my $HOME/.rvmrc file (i.e. the equivalent of a rvm --default use 1.9.2).

I tried setting rvm_ruby_interpreter and rvm_ruby_version, but no luck.


Just cleaning out my unanswered questions... I ended up basically taking Phrogz's suggestion and adding this to my .zprofile:

RVM_DEFAULT=ruby-1.9.3-p194@home
if [ -x ~/.rvm/bin/rvm-prompt ] && [ "$(~/.rvm/bin/rvm-prompt)" != $RVM_DEFAULT ] ; then
  rvm use $RVM_DEFAULT
fi

Looking back it's kind of a weird question, probably due to the fact that I was new to rvm and relatively new to Ruby (but familiar with Unix and dotfiles).


You can't in the $HOME/.rvmrc or /etc/rvmrc file, but you can in project .rvmrc files by typing in rvm <interpreter>. So if you want 1.9.2 for one project, but ree for a different, type in rvm 1.9.2 in the first project's .rvmrc file, and rvm ree in the other project's .rvmrc file. You can also automatically activate gemsets this way.

Source: https://rvm.beginrescueend.com/workflow/rvmrc/


If you have projects using .rvmrc (or .ruby-version / .ruby-gemset), and want to be sure your home directory sets those envars to something else (no matter how many times you cd here and there), try this in ~/.bashrc:

PROMPT_COMMAND='[[ $PWD = $HOME ]] && (rvm use default; rvm gemset use global) > /dev/null'

Substituting your favorite flavors for default and global, of course.

0

精彩评论

暂无评论...
验证码 换一张
取 消