rubymacoschruby

Setting ruby version separately with different app on Mac


I have just started working on a ruby project and I notice that I have to specify the ruby version to use globally. For instance, I am using chruby to change the ruby version to use and I can set it directly at this file called .zshrc.

But if I have a multiple apps with different ruby version, then how do I handle it? It doesn't make sense if I keep changing the version to use at .zshrc file every time I want to run the other app.

Since it's a shared project so I cannot just change the version used in the app. Thank you.


Solution

  • In chruby, this feature is called "Auto-switching".

    If you want chruby to auto-switch the current version of Ruby when you cd between your different projects, simply load auto.sh in ~/.bashrc or ~/.zshrc:

    ..

    chruby will check the current and parent directories for a .ruby-version file.

    https://github.com/postmodern/chruby#auto-switching