English 中文(简体)
Why does it take a long time to change directories after installing RVM
原标题:
  • 时间:2009-12-30 23:57:02
  •  标签:
  • ruby
  • rvm

I just installed RVM and it seems the cd command is taking an extra couple of seconds, why is this happening? Is there any way to fix this?

最佳回答

This has been resolved in 0.1.39 and later versions of RVM. The behavior now only sources the .rvmrc file when you enter a projects directory tree for the first time. Subsequent cd s within that directory tree do not source the .rvmrc file. If you find yourself constantly jumping into and out of your projects directory tree, I would recommend using multiple terminals :)

One side benefit of this is you can now put more time-consuming actions, such as ensuring all your gems in your gemset are up to date, in .rvmrc to keep your project current without costing you time each time you cd.

To get the latest version of rvm, run: rvm update --head

Once that is installed, all new shells will have the improved behaviour -- for existing shells that you don t want to close, you can run rvm reload to provide the new behaviour.

Cheers, -Dennis

问题回答

This happens because it sources a file that intercepts the cd operation.

prompt:$ cat ~/.rvm/scripts/cd
#!/usr/bin/env bash

# Source a .rvmrc file in a directory after changing to it, if it exists.
 cd() {
   builtin cd "$@"
   if [[ "$rvm_project_rvmrc" != 0 ]] ; then
     local cwd ; cwd=$(pwd)
     while : ; do
       if [[ -z "$cwd" ]] || [[ "$HOME" = "$cwd" ]] || [[ "/" = "$cwd" ]] ; then
         if [[ "$rvm_project_rvmrc_default" != 0 ]] ; then
           rvm default 1>/dev/null 2>&1
         fi
         break
       else
         if [[ -f "$cwd/.rvmrc" ]] ; then
           source "$cwd/.rvmrc"
           break
         else
           cwd=$(dirname "$cwd")
         fi
       fi
     done
   fi
 }

This file checks for a .rvmrc file in the directory you are changing to, and set up an environment. That way you can have dir A run under ruby 1.8 and dir B run under ruby 1.9.

If you are happy to do away with this convenience you can comment out this file and be done with slow directory switching.

Alternatively you could contribute a patch that performs some caching so this is fast.





相关问题
Ruby parser in Java

The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...

rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

multiple ruby extension modules under one directory

Can sources for discrete ruby extension modules live in the same directory, controlled by the same extconf.rb script? Background: I ve a project with two extension modules, foo.so and bar.so which ...

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

热门标签