does cd command in a shell script load the rvmrc inside the destination directory?

混江龙づ霸主 提交于 2019-12-05 18:55:47

Yes


Rvm does define a wrapper around cd that looks like this:

cd () 
{ 
    builtin cd "$@";
    local result=$?;
    __rvm_project_rvmrc;
    __rvm_after_cd;
    return $result
}

It's difficult to tell why your .rvmrc isn't working. Rvm does support project-specific .rvmrc files, but you didn't post yours.

You need to source rvm inside your script, when you run a script it doesn't load your .bashrc. Simply add a line like

[[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm

to the start of your script.

Slobodan Kovacevic

If you are using RVM 1.7.0 or later you need to enable project specific .rvmrc files by adding this line to ~/.rvmrc (or system .rvmrc):

rvm_project_rvmrc=1

See: https://rvm.io/workflow/rvmrc/

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!