summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHomu <homu@barosl.com>2016-02-04 13:56:17 +0900
committerHomu <homu@barosl.com>2016-02-04 13:56:17 +0900
commit7db169c6acd43abe57db66c80227ea3892abe703 (patch)
treed14d8919c440eb746d8d5a3b177222f3aa90316e
parent46c89b3a72a6e4abcf82b2e790bc63395eef05a6 (diff)
parent1571c520c7223d4eef7ac9a167683ad60048ae6f (diff)
downloadbundler-7db169c6acd43abe57db66c80227ea3892abe703.tar.gz
Auto merge of #4264 - glennpratt:GH-4144-standalone-load-path, r=segiddins
Make standalone bin load path relative to Bundler.root rather than CWD. See #4144
-rw-r--r--lib/bundler/installer.rb2
-rw-r--r--spec/install/gems/standalone_spec.rb30
2 files changed, 31 insertions, 1 deletions
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb
index 3a54a02151..10ba3005d1 100644
--- a/lib/bundler/installer.rb
+++ b/lib/bundler/installer.rb
@@ -130,12 +130,12 @@ module Bundler
def generate_standalone_bundler_executable_stubs(spec)
# double-assignment to avoid warnings about variables that will be used by ERB
bin_path = Bundler.bin_path
+ standalone_path = standalone_path = Bundler.root.join(Bundler.settings[:path]).relative_path_from(bin_path)
template = File.read(File.expand_path("../templates/Executable.standalone", __FILE__))
ruby_command = ruby_command = Thor::Util.ruby_command
spec.executables.each do |executable|
next if executable == "bundle"
- standalone_path = standalone_path = Pathname(Bundler.settings[:path]).expand_path.relative_path_from(bin_path)
executable_path = executable_path = Pathname(spec.full_gem_path).join(spec.bindir, executable).relative_path_from(bin_path)
File.open "#{bin_path}/#{executable}", "w", 0755 do |f|
f.puts ERB.new(template, nil, "-").result(binding)
diff --git a/spec/install/gems/standalone_spec.rb b/spec/install/gems/standalone_spec.rb
index 4ce5d92eb0..d0f5af709f 100644
--- a/spec/install/gems/standalone_spec.rb
+++ b/spec/install/gems/standalone_spec.rb
@@ -272,5 +272,35 @@ describe "bundle install --standalone" do
expect(`#{bundled_app}/bin/rails -v`.chomp).to eql "2.3.2"
end
end
+
+ it "creates stubs with the correct load path" do
+ extension_line = File.read(bundled_app("bin/rails")).each_line.find {|line| line.include? "$:.unshift" }.strip
+ expect(extension_line).to eq "$:.unshift File.expand_path '../../bundle', __FILE__"
+ end
+ end
+
+ describe "with --binstubs run in a subdirectory" do
+ before do
+ FileUtils.mkdir_p("bob")
+ Dir.chdir("bob") do
+ install_gemfile <<-G, :standalone => true, :binstubs => true
+ source "file://#{gem_repo1}"
+ gem "rails"
+ G
+ end
+ end
+
+ # @todo This test fails because the bundler/setup.rb is written to the
+ # current directory.
+ xit "creates stubs that use the standalone load path" do
+ Dir.chdir(bundled_app) do
+ expect(`bin/rails -v`.chomp).to eql "2.3.2"
+ end
+ end
+
+ it "creates stubs with the correct load path" do
+ extension_line = File.read(bundled_app("bin/rails")).each_line.find {|line| line.include? "$:.unshift" }.strip
+ expect(extension_line).to eq "$:.unshift File.expand_path '../../bundle', __FILE__"
+ end
end
end