diff options
author | Adam Wanninger <ajwann@users.noreply.github.com> | 2017-07-30 13:15:57 -0400 |
---|---|---|
committer | Adam Wanninger <ajwann@users.noreply.github.com> | 2017-08-07 18:18:59 -0400 |
commit | 944862e7e75b07e2400baedf6d637a7467284add (patch) | |
tree | 0d68e5269ea3b47bb925fd2ed4c96bf195ca311b | |
parent | dedaedcf727af38e78c51b95624d8dea3515529b (diff) | |
download | bundler-944862e7e75b07e2400baedf6d637a7467284add.tar.gz |
exit if bundle bin path contains a path separator
-rw-r--r-- | lib/bundler/shared_helpers.rb | 9 | ||||
-rw-r--r-- | spec/bundler/shared_helpers_spec.rb | 10 |
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index 99b073f542..909125171e 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -203,6 +203,14 @@ module Bundler private + def validate_bundle_path + if Bundler.bundle_path.to_s.match(File::PATH_SEPARATOR) + puts 'WARNING: Your bundle path contains a ":", which can cause problems.' + puts 'Please change your bundle path path to not include ":".' + exit(1) + end + end + def find_gemfile(order_matters = false) given = ENV["BUNDLE_GEMFILE"] return given if given && !given.empty? @@ -270,6 +278,7 @@ module Bundler end def set_path + validate_bundle_path paths = (ENV["PATH"] || "").split(File::PATH_SEPARATOR) paths.unshift "#{Bundler.bundle_path}/bin" Bundler::SharedHelpers.set_env "PATH", paths.uniq.join(File::PATH_SEPARATOR) diff --git a/spec/bundler/shared_helpers_spec.rb b/spec/bundler/shared_helpers_spec.rb index c17f3b8582..9ec6ff1796 100644 --- a/spec/bundler/shared_helpers_spec.rb +++ b/spec/bundler/shared_helpers_spec.rb @@ -261,6 +261,16 @@ RSpec.describe Bundler::SharedHelpers do subject.set_bundle_environment end + it "exits if bundle path contains the path seperator" do + File::PATH_SEPARATOR = ':' + allow(Bundler).to receive(:bundle_path) { "so:me/dir/bin" } + expect(subject.send(:validate_bundle_path)).to raise_error(SystemExit) + + File::PATH_SEPARATOR = '^' + allow(Bundler).to receive(:bundle_path) { "so^me/dir/bin" } + expect(subject.send(:validate_bundle_path)).to raise_error(SystemExit) + end + context "ENV['PATH'] does not exist" do before { ENV.delete("PATH") } |