LoginSignup
6
7

More than 5 years have passed since last update.

環境変数 BUNDLE_PATH の怪

Posted at

BUNDLE_PATH

動作環境を確実なものにするために一役買っているBundler君

bundle install --path vendor/bundleはすでにイデオムと化しているくらいスタンダードな使い方です

上記コマンドによって .bundle/config 内に BUNDLE_PATH: vendor/bundle と設定されるわけですが、時には config ファイルを使わずに指定したいものです

幸いなことに、Bundlerには環境変数指定がサポートされているため

BUNDLE_PATH=vendor/bundle bundle exec ruby hoge.rb

... で成功しそうなものですが、残念なことに実行に失敗します

ここでは、この回避方法を書いておきます

Workaround

$ bundle install --path hoge/fuga

とインストールしたなら、

$ BUNDLE_PATH=hoge/fuga/ruby/2.2.0 bundle exec ruby hoge.rb

と実行しましよう

2.2.0 のところは、bundle install時に使ったRubyのABIバージョンに読み替えてください

解説

.bundle/config 内の BUNDLE_PATH と、環境変数の BUNDLE_PATH は挙動が違います

原因はBundler::Settings#pathにあります

どうやらIssueなのですが、Bundler 2.0でね :/というつれないお返事が入っています
※まぁ :/ って顔されちゃ、しょうがないですね

6
7
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
6
7