0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

rbenv | subtle relationship between global, local and .ruby-version

Last updated at Posted at 2019-04-16

$ rbenv global xxx

Specify the version of ruby to use throughout the system. But in fact, it is a command only to write out ~/.rbenv/version file.

 $ rbenv global 2.2.0 # => ~/.rbenv/version に 2.2.0 と書き出される 

So even if you create or delete ~/.rbenv/version in other ways. The ruby version changes.

$ rbenv local xxx

Specify the ruby version to use for each project. But in fact, the command only writes the .ruby-version file to the current directory.

 $ rbenv global 2.3.0 # => ./.ruby-version に 2.3.0 と書き出される 

So even if you create or delete .ruby-version in other ways. The ruby version changes.

Behavior of rbenv

As mentioned earlier, rbenv global / rbenv local only rbenv global / rbenv local files. In fact, the behavior of rbenv determines the version of ruby.

order

rbenv first looks at the .ruby-version current directory. If there is, use it.

If not, look at the .ruby-version in the .ruby-version directory. If there is, use it. Repeat this until you reach your home directory ~/ .

If you go to your home directory but don't have .ruby-version , look at ~/rbenv/version . If there is, use it.

That is, if you create .ruby-version in .ruby-version home directory, global will not be referenced from anywhere.

environment

  • rbenv 0.4.0
  • Mac OS X Yosemite

Original by

rbenv | global と local と .ruby-version の微妙な関係

About

About this translattion

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?