RVM after_cd hook

I am trying to use RVM hooks to run a command after I cd into a directory with my rail application.

The contents of my ~/.rvm/hooks/after_cd :

 echo "Now using $rvm_ruby_string" 

The contents of my ~/.rvm/hooks/after_use :

 echo "Now using $rvm_ruby_string" 

When I do $rmv use 1.9.2 , I see my echo, but when I cd to the rails root directory for my application, I don't get any echo.

Am I using hook after_cd ?

$rvm -v says:

 rvm 1.0.8 by Wayne E. Seguin ( wayneeseguin@gmail.com ) [http://rvm.beginrescueend.com/] 
+4
source share
1 answer

First you need to understand how rvm overwrites your default cd system command.

Here the answer explains it well.

In short, rvm defines such a function in .rvm / script / cd

 cd(){ builtin cd $* #run system cd source after_cd_hooks #run hook scripts } 

And you can find this line if you look how this cd () is defined.

__rvm_project_rvmrc && __rvm_after_cd || true

__rvm_project_rvmrc is a function to check if .rvmrc exists in the directory you enter.

This way, hook scripts will only be received if .rvmrc exists in the root of your project.

So create your .rvmrc and try cd again. Good luck

 > /path/to/app/root/.rvmrc cd /path/to/app/root 

My rvm version:

 rvm -v rvm 1.23.14 (stable) by Wayne E. Seguin < wayneeseguin@gmail.com >, Michal Papis < mpapis@gmail.com > [https://rvm.io/] 
+4
source

All Articles