Search code examples
rubyshellrvmcd

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


when you have something like..

given inside projectx an .rvmrc file specifying ruby 1.9.2 and having two rubies on my system (ree-1.8.7 and ruby1.9.2)

#!/bin/bash

cd applications/projectx
which ruby
ruby -v

the last two lines output ree-1.8.7 and its path which was not I intended to use.


Solution

  • 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.