🖥

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

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オープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ

Twitter

https://twitter.com/YumaInaura

公開日時

2019-04-16

Discussion