aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bundler/shared_helpers.rb
diff options
context:
space:
mode:
authorAndre Arko <andre@arko.net>2015-01-19 13:05:04 -0800
committerAndre Arko <andre@arko.net>2015-01-19 13:10:43 -0800
commit4251a1bfe29a7980f80bcaf3dc28fa0f4d3992b0 (patch)
tree16812ebba9af684353fec0c1e7d81e9b05bc76df /lib/bundler/shared_helpers.rb
parentd3922e972570f6bd1144dfeade35d81b5830ac6e (diff)
downloadbundler-4251a1bfe29a7980f80bcaf3dc28fa0f4d3992b0.tar.gz
share bundle env setup between exec and Runtime
this means we only have to maintain setting up Bundler environment variables in one place
Diffstat (limited to 'lib/bundler/shared_helpers.rb')
-rw-r--r--lib/bundler/shared_helpers.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb
index b4c73f69..b7fdee1e 100644
--- a/lib/bundler/shared_helpers.rb
+++ b/lib/bundler/shared_helpers.rb
@@ -74,6 +74,25 @@ module Bundler
keys.each {|key| ENV[key] = old_env[key] }
end
+ def set_bundle_environment
+ # Set PATH
+ paths = (ENV["PATH"] || "").split(File::PATH_SEPARATOR)
+ paths.unshift "#{Bundler.bundle_path}/bin"
+ ENV["PATH"] = paths.uniq.join(File::PATH_SEPARATOR)
+
+ # Set RUBYOPT
+ rubyopt = [ENV["RUBYOPT"]].compact
+ if rubyopt.empty? || rubyopt.first !~ /-rbundler\/setup/
+ rubyopt.unshift %|-rbundler/setup|
+ ENV["RUBYOPT"] = rubyopt.join(' ')
+ end
+
+ # Set RUBYLIB
+ rubylib = (ENV["RUBYLIB"] || "").split(File::PATH_SEPARATOR)
+ rubylib.unshift File.expand_path('../..', __FILE__)
+ ENV["RUBYLIB"] = rubylib.uniq.join(File::PATH_SEPARATOR)
+ end
+
private
def find_gemfile