Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test if a Ruby script is running via Bundler

Tags:

ruby

bundler

In a Ruby script, is there a way to test if the current process has been launched via Bundler - i.e. via bundle exec or a binstub?

like image 478
Ginty Avatar asked Jul 11 '15 17:07

Ginty


1 Answers

You could check defined?(Bundler), but that will also be present if you require 'bundler' without having run bundle exec.

When you run inside bundle exec, there are a few ENV variables present that aren't otherwise. Notably, BUNDLE_GEMFILE and BUNDLE_BIN_PATH.

There are some more details in the Environment Modifications section of the bundle exec docs.

like image 112
Kristján Avatar answered Nov 12 '22 20:11

Kristján