LoginSignup
3
0

More than 5 years have passed since last update.

【Bundler】Command: `bundle exec`

Last updated at Posted at 2018-02-07

bundle exec

Summary

  • カレントディレクトリ配下のGemfileに記述されたGem環境の元でコマンドが実行される

Roles

  • 複数のGemのバージョンがインストールされている(アプリケーションごとにGemを閉じているのではなく、システムの方にGemがインストールされている)場合、どのバージョンのGemを使うかを指定する必要がある
  • bundle execをコマンドの接頭に付与することで、「Gemfileに記述されたGemのバージョンで実行してね!」と指定することができる

Result

  • カレントディレクトリ配下のGemfileに記述されたGem環境下で、Gemのコマンドが実行されていく

Examples

gem listコマンドを用いて)

  1. 「Railsアプリケーション配下」で「bundle execを付加せず」実行したgemコマンドの挙動
  2. 同じく「Railsアプリケーション配下」で「bundle execを付加して」実行した場合の挙動

1 bundle exec を付加せず実行
(システムにインストールされたGem達が黄泉の国から帰ってくる)

$ gem list

*** LOCAL GEMS ***

actioncable (5.1.4, 5.1.2, 5.0.6, 5.0.1)
actionmailer (5.1.4, 5.1.2, 5.0.6, 5.0.1, 4.2.6, 4.2.5, 4.2.3, 4.2.1, 4.1.6)
actionpack (5.1.4, 5.1.2, 5.0.6, 5.0.1, 4.2.6, 4.2.5, 4.2.3, 4.2.1, 4.1.6)
actionview (5.1.4, 5.1.2, 5.0.6, 5.0.1, 4.2.6, 4.2.5, 4.2.3, 4.2.1, 4.1.6)
activejob (5.1.4, 5.1.2, 5.0.6, 5.0.1, 4.2.6, 4.2.5, 4.2.3, 4.2.1)
activemodel (5.1.4, 5.1.2, 5.0.6, 5.0.1, 4.2.6, 4.2.5, 4.2.3, 4.2.1, 4.1.6)
activerecord (5.1.4, 5.1.2, 5.0.6, 5.0.1, 4.2.6, 4.2.5, 4.2.3, 4.2.1, 4.1.6)
activesupport (5.1.4, 5.1.2, 5.0.6, 5.0.1, 4.2.6, 4.2.5, 4.2.3, 4.2.1, 4.1.6)
addressable (2.5.2)
arel (8.0.0, 7.1.4, 6.0.4, 6.0.3, 6.0.0, 5.0.1.20140414130214)
bcrypt (3.1.11, 3.1.10)
bigdecimal (1.2.8)
bindex (0.5.0)
binding_of_caller (0.7.3, 0.7.2)
builder (3.2.3, 3.2.2)
bundler (1.16.0, 1.15.1)
byebug (10.0.0, 9.1.0, 9.0.6, 6.0.2, 4.0.5)
capybara (2.17.0, 2.16.1)
carrierwave (1.2.2)
childprocess (0.8.0)
chunky_png (1.3.8, 1.3.4)
climate_control (0.2.0)
cocaine (0.5.8)
coderay (1.1.2, 1.1.1, 1.1.0)
coffee-rails (4.2.2, 4.1.1, 4.1.0, 4.0.1)
coffee-script (2.4.1)
coffee-script-source (1.12.2, 1.9.1.1)
columnize (0.9.0)
compass (0.12.7)
compass-rails (2.0.0)
concurrent-ruby (1.0.5)
crass (1.0.3)
debug_inspector (0.0.3, 0.0.2)
devise (4.4.0, 4.3.0, 4.2.0, 3.4.1)
did_you_mean (1.0.0)
diff-lcs (1.3)
domain_name (0.5.20170404)
erubi (1.7.0)
erubis (2.7.0)
execjs (2.7.0, 2.6.0, 2.5.2)
factory_girl (4.4.0)
factory_girl_rails (4.4.1)
ffi (1.9.21, 1.9.18)
fssm (0.2.10)
globalid (0.4.1, 0.4.0, 0.3.6, 0.3.5)
hike (1.2.3)
http-cookie (1.0.3)
i18n (0.9.3, 0.9.1, 0.8.6, 0.8.5, 0.8.4, 0.7.0)
io-console (0.4.5)
jbuilder (2.7.0, 2.6.4, 2.3.2, 2.2.13, 1.5.3)
jquery-rails (4.3.1, 4.0.5, 4.0.3, 3.1.4)
json (1.8.6, 1.8.3, 1.8.2)
kaminari (1.0.1, 0.16.3)
kaminari-actionview (1.0.1)
kaminari-activerecord (1.0.1)
kaminari-core (1.0.1)
kgio (2.11.0)
libv8 (3.16.14.19)
listen (3.1.5, 3.0.8)
loofah (2.1.1, 2.0.3, 2.0.1)
mail (2.7.0, 2.6.6, 2.6.3)
mechanize (2.7.5)
method_source (0.9.0, 0.8.2)
mime-types (3.1, 2.6.2, 2.5)
mime-types-data (3.2016.0521)
mimemagic (0.3.2)
mini_mime (1.0.0)
mini_portile (0.6.2)
mini_portile2 (2.3.0, 2.2.0, 2.1.0)
minitest (5.11.3, 5.11.1, 5.10.3, 5.10.2, 5.9.0, 5.8.3, 5.8.1, 5.6.1)
multi_json (1.13.1, 1.12.2, 1.12.1, 1.11.2, 1.11.0)
mysql2 (0.4.10, 0.4.8, 0.4.6, 0.3.20, 0.3.18)
net-http-digest_auth (1.4.1)
net-http-persistent (2.9.4)
net-telnet (0.1.1)
nio4r (2.2.0, 2.1.0, 1.2.1)
nokogiri (1.8.2, 1.8.1, 1.8.0, 1.6.8, 1.6.6.2)
ntlm-http (0.1.1)
orm_adapter (0.5.0)
paperclip (5.1.0)
pkg-config (1.1.7)
power_assert (0.2.6)
pry (0.11.3, 0.10.4, 0.10.1)
pry-rails (0.3.6, 0.3.4)
psych (2.0.17)
public_suffix (3.0.1)
puma (3.11.2, 3.11.0, 3.9.1)
rack (2.0.4, 2.0.3, 1.6.8, 1.6.4, 1.6.0, 1.5.5)
rack-test (0.8.2, 0.6.3)
rails (5.1.4, 5.1.2, 5.0.6, 5.0.1, 4.2.6, 4.2.5, 4.2.3, 4.2.1, 4.1.6)
rails-deprecated_sanitizer (1.0.3)
rails-dom-testing (2.0.3, 1.0.9, 1.0.8, 1.0.7, 1.0.6)
rails-html-sanitizer (1.0.3, 1.0.2)
railties (5.1.4, 5.1.2, 5.0.6, 5.0.1, 4.2.6, 4.2.5, 4.2.3, 4.2.1, 4.1.6)
raindrops (0.18.0)
rake (12.3.0, 12.0.0, 11.2.2, 10.4.2)
rb-fsevent (0.10.2)
rb-inotify (0.9.10)
rdoc (4.3.0, 4.2.1, 4.2.0)
ref (2.0.0)
responders (2.4.0, 2.2.0, 2.1.0, 1.1.2)
rspec-core (3.7.1)
rspec-expectations (3.7.0)
rspec-mocks (3.7.0)
rspec-rails (3.7.2)
rspec-support (3.7.1)
ruby_dep (1.5.0)
rubyzip (1.2.1)
sass (3.5.5, 3.5.4, 3.5.1, 3.4.24, 3.4.19, 3.2.19)
sass-listen (4.0.0)
sass-rails (5.0.7, 5.0.6, 5.0.4, 4.0.5, 4.0.4, 4.0.2)
sdoc (0.4.2, 0.4.1)
selenium-webdriver (3.9.0, 3.8.0)
slop (3.6.0)
spring (2.0.2, 2.0.0, 1.7.2, 1.4.0, 1.3.5)
spring-watcher-listen (2.0.1)
sprockets (3.7.1, 3.4.0, 2.12.4, 2.11.0)
sprockets-rails (3.2.1, 3.2.0, 2.3.3, 2.2.4, 2.0.1)
sqlite3 (1.3.13)
test-unit (3.1.5)
therubyracer (0.12.3)
thor (0.20.0, 0.19.4, 0.19.1)
thread_safe (0.3.6, 0.3.5)
tilt (2.0.8, 2.0.7, 2.0.1, 1.4.1)
turbolinks (5.1.0, 5.0.1, 2.5.3)
turbolinks-source (5.1.0, 5.0.3)
tzinfo (1.2.5, 1.2.4, 1.2.3, 1.2.2)
uglifier (4.1.5, 4.1.3, 4.1.1, 4.0.2, 3.2.0, 2.7.2, 2.7.1)
unf (0.1.4)
unf_ext (0.0.7.4)
unicorn (5.3.0)
warden (1.2.7, 1.2.6, 1.2.3)
web-console (3.5.1, 2.3.0, 2.2.1, 2.1.2)
webrobots (0.1.2)
websocket-driver (0.6.5)
websocket-extensions (0.1.3)
xpath (3.0.0, 2.1.0)

2 bundle exec を付加して実行
(アプリケーションで利用している(アプリケーション配下のGemfileに記述された)Gem達が黄泉の国から帰ってくる)

$ bundle exec gem list

*** LOCAL GEMS ***

actioncable (5.1.4)
actionmailer (5.1.4)
actionpack (5.1.4)
actionview (5.1.4)
activejob (5.1.4)
activemodel (5.1.4)
activerecord (5.1.4)
activesupport (5.1.4)
addressable (2.5.2)
arel (8.0.0)
bindex (0.5.0)
builder (3.2.3)
bundler (1.16.0)
byebug (10.0.0)
capybara (2.17.0)
childprocess (0.8.0)
coffee-rails (4.2.2)
coffee-script (2.4.1)
coffee-script-source (1.12.2)
concurrent-ruby (1.0.5)
crass (1.0.3)
erubi (1.7.0)
execjs (2.7.0)
ffi (1.9.21)
globalid (0.4.1)
i18n (0.9.3)
jbuilder (2.7.0)
listen (3.1.5)
loofah (2.1.1)
mail (2.7.0)
method_source (0.9.0)
mini_mime (1.0.0)
mini_portile2 (2.3.0)
minitest (5.11.3)
multi_json (1.13.1)
nio4r (2.2.0)
nokogiri (1.8.2)
public_suffix (3.0.1)
puma (3.11.2)
rack (2.0.4)
rack-test (0.8.2)
rails (5.1.4)
rails-dom-testing (2.0.3)
rails-html-sanitizer (1.0.3)
railties (5.1.4)
rake (12.3.0)
rb-fsevent (0.10.2)
rb-inotify (0.9.10)
ruby_dep (1.5.0)
rubyzip (1.2.1)
sass (3.5.5)
sass-listen (4.0.0)
sass-rails (5.0.7)
selenium-webdriver (3.9.0)
spring (2.0.2)
spring-watcher-listen (2.0.1)
sprockets (3.7.1)
sprockets-rails (3.2.1)
sqlite3 (1.3.13)
thor (0.20.0)
thread_safe (0.3.6)
tilt (2.0.8)
turbolinks (5.1.0)
turbolinks-source (5.1.0)
tzinfo (1.2.5)
uglifier (4.1.5)
web-console (3.5.1)
websocket-driver (0.6.5)
websocket-extensions (0.1.3)
xpath (3.0.0)
3
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
3
0