2018-11-02 19:07:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
RSpec.describe "bundle install" do
|
2020-10-15 00:20:25 -04:00
|
|
|
describe "with path configured" do
|
2018-11-02 19:07:56 -04:00
|
|
|
before :each do
|
|
|
|
build_gem "rack", "1.0.0", :to_system => true do |s|
|
|
|
|
s.write "lib/rack.rb", "puts 'FAIL'"
|
|
|
|
end
|
|
|
|
|
|
|
|
gemfile <<-G
|
2019-05-06 12:06:21 -04:00
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
2018-11-02 19:07:56 -04:00
|
|
|
gem "rack"
|
|
|
|
G
|
|
|
|
end
|
|
|
|
|
2020-10-15 00:20:25 -04:00
|
|
|
it "does not use available system gems with `vendor/bundle" do
|
2021-01-03 20:11:34 -05:00
|
|
|
bundle "config set --local path vendor/bundle"
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :install
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(the_bundle).to include_gems "rack 1.0.0"
|
|
|
|
end
|
|
|
|
|
2020-10-15 00:20:25 -04:00
|
|
|
it "uses system gems with `path.system` configured with more priority than `path`" do
|
2021-01-03 20:11:34 -05:00
|
|
|
bundle "config set --local path.system true"
|
|
|
|
bundle "config set --global path vendor/bundle"
|
2020-10-15 00:20:25 -04:00
|
|
|
bundle :install
|
|
|
|
run "require 'rack'", :raise_on_error => false
|
|
|
|
expect(out).to include("FAIL")
|
|
|
|
end
|
|
|
|
|
2018-11-02 19:07:56 -04:00
|
|
|
it "handles paths with regex characters in them" do
|
|
|
|
dir = bundled_app("bun++dle")
|
|
|
|
dir.mkpath
|
|
|
|
|
2021-01-03 20:11:34 -05:00
|
|
|
bundle "config set --local path #{dir.join("vendor/bundle")}"
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :install, :dir => dir
|
2020-05-08 01:19:04 -04:00
|
|
|
expect(out).to include("installed into `./vendor/bundle`")
|
2018-11-02 19:07:56 -04:00
|
|
|
|
|
|
|
dir.rmtree
|
|
|
|
end
|
|
|
|
|
2020-10-15 00:20:25 -04:00
|
|
|
it "prints a message to let the user know where gems where installed" do
|
2021-01-03 20:11:34 -05:00
|
|
|
bundle "config set --local path vendor/bundle"
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :install
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(out).to include("gems are installed into `./vendor/bundle`")
|
|
|
|
end
|
|
|
|
|
2019-01-04 08:10:58 -05:00
|
|
|
it "disallows --path vendor/bundle --system", :bundler => "< 3" do
|
2020-06-03 12:43:17 -04:00
|
|
|
bundle "install --path vendor/bundle --system", :raise_on_error => false
|
2019-04-14 02:01:35 -04:00
|
|
|
expect(err).to include("Please choose only one option.")
|
2020-06-24 13:53:16 -04:00
|
|
|
expect(exitstatus).to eq(15)
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
2019-01-04 08:10:58 -05:00
|
|
|
it "remembers to disable system gems after the first time with bundle --path vendor/bundle", :bundler => "< 3" do
|
2018-11-02 19:07:56 -04:00
|
|
|
bundle "install --path vendor/bundle"
|
|
|
|
FileUtils.rm_rf bundled_app("vendor")
|
|
|
|
bundle "install"
|
|
|
|
|
|
|
|
expect(vendored_gems("gems/rack-1.0.0")).to be_directory
|
|
|
|
expect(the_bundle).to include_gems "rack 1.0.0"
|
|
|
|
end
|
|
|
|
|
|
|
|
context "with path_relative_to_cwd set to true" do
|
2020-06-03 14:45:36 -04:00
|
|
|
before { bundle "config set path_relative_to_cwd true" }
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-01-04 08:10:58 -05:00
|
|
|
it "installs the bundle relatively to current working directory", :bundler => "< 3" do
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "install --gemfile='#{bundled_app}/Gemfile' --path vendor/bundle", :dir => bundled_app.parent
|
2020-05-08 01:19:04 -04:00
|
|
|
expect(out).to include("installed into `./vendor/bundle`")
|
|
|
|
expect(bundled_app("../vendor/bundle")).to be_directory
|
2018-11-02 19:07:56 -04:00
|
|
|
expect(the_bundle).to include_gems "rack 1.0.0"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "installs the standalone bundle relative to the cwd" do
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :install, :gemfile => bundled_app_gemfile, :standalone => true, :dir => bundled_app.parent
|
2020-05-08 01:19:04 -04:00
|
|
|
expect(out).to include("installed into `./bundled_app/bundle`")
|
|
|
|
expect(bundled_app("bundle")).to be_directory
|
|
|
|
expect(bundled_app("bundle/ruby")).to be_directory
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "config unset path"
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :install, :gemfile => bundled_app_gemfile, :standalone => true, :dir => bundled_app("subdir").tap(&:mkpath)
|
2020-05-08 01:19:04 -04:00
|
|
|
expect(out).to include("installed into `../bundle`")
|
|
|
|
expect(bundled_app("bundle")).to be_directory
|
|
|
|
expect(bundled_app("bundle/ruby")).to be_directory
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "when BUNDLE_PATH or the global path config is set" do
|
|
|
|
before :each do
|
|
|
|
build_lib "rack", "1.0.0", :to_system => true do |s|
|
|
|
|
s.write "lib/rack.rb", "raise 'FAIL'"
|
|
|
|
end
|
|
|
|
|
|
|
|
gemfile <<-G
|
2019-05-06 12:06:21 -04:00
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
2018-11-02 19:07:56 -04:00
|
|
|
gem "rack"
|
|
|
|
G
|
|
|
|
end
|
|
|
|
|
|
|
|
def set_bundle_path(type, location)
|
|
|
|
if type == :env
|
|
|
|
ENV["BUNDLE_PATH"] = location
|
|
|
|
elsif type == :global
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "config set path #{location}", "no-color" => nil
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
[:env, :global].each do |type|
|
|
|
|
context "when set via #{type}" do
|
|
|
|
it "installs gems to a path if one is specified" do
|
|
|
|
set_bundle_path(type, bundled_app("vendor2").to_s)
|
2021-01-03 20:11:34 -05:00
|
|
|
bundle "config set --local path vendor/bundle"
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :install
|
2018-11-02 19:07:56 -04:00
|
|
|
|
|
|
|
expect(vendored_gems("gems/rack-1.0.0")).to be_directory
|
|
|
|
expect(bundled_app("vendor2")).not_to be_directory
|
|
|
|
expect(the_bundle).to include_gems "rack 1.0.0"
|
|
|
|
end
|
|
|
|
|
2019-06-01 05:49:40 -04:00
|
|
|
it "installs gems to ." do
|
|
|
|
set_bundle_path(type, ".")
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle "config set --global disable_shared_gems true"
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :install
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-06-01 05:49:40 -04:00
|
|
|
paths_to_exist = %w[cache/rack-1.0.0.gem gems/rack-1.0.0 specifications/rack-1.0.0.gemspec].map {|path| bundled_app(Bundler.ruby_scope, path) }
|
|
|
|
expect(paths_to_exist).to all exist
|
|
|
|
expect(the_bundle).to include_gems "rack 1.0.0"
|
|
|
|
end
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-06-01 05:49:40 -04:00
|
|
|
it "installs gems to the path" do
|
|
|
|
set_bundle_path(type, bundled_app("vendor").to_s)
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :install
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-06-01 05:49:40 -04:00
|
|
|
expect(bundled_app("vendor", Bundler.ruby_scope, "gems/rack-1.0.0")).to be_directory
|
|
|
|
expect(the_bundle).to include_gems "rack 1.0.0"
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
2019-06-01 05:49:40 -04:00
|
|
|
it "installs gems to the path relative to root when relative" do
|
|
|
|
set_bundle_path(type, "vendor")
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-06-01 05:49:40 -04:00
|
|
|
FileUtils.mkdir_p bundled_app("lol")
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :install, :dir => bundled_app("lol")
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2019-06-01 05:49:40 -04:00
|
|
|
expect(bundled_app("vendor", Bundler.ruby_scope, "gems/rack-1.0.0")).to be_directory
|
|
|
|
expect(the_bundle).to include_gems "rack 1.0.0"
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it "installs gems to BUNDLE_PATH from .bundle/config" do
|
|
|
|
config "BUNDLE_PATH" => bundled_app("vendor/bundle").to_s
|
|
|
|
|
|
|
|
bundle :install
|
|
|
|
|
|
|
|
expect(vendored_gems("gems/rack-1.0.0")).to be_directory
|
|
|
|
expect(the_bundle).to include_gems "rack 1.0.0"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "sets BUNDLE_PATH as the first argument to bundle install" do
|
2021-01-03 20:11:34 -05:00
|
|
|
bundle "config set --local path ./vendor/bundle"
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :install
|
2018-11-02 19:07:56 -04:00
|
|
|
|
|
|
|
expect(vendored_gems("gems/rack-1.0.0")).to be_directory
|
|
|
|
expect(the_bundle).to include_gems "rack 1.0.0"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "disables system gems when passing a path to install" do
|
|
|
|
# This is so that vendored gems can be distributed to others
|
|
|
|
build_gem "rack", "1.1.0", :to_system => true
|
2021-01-03 20:11:34 -05:00
|
|
|
bundle "config set --local path ./vendor/bundle"
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :install
|
2018-11-02 19:07:56 -04:00
|
|
|
|
|
|
|
expect(vendored_gems("gems/rack-1.0.0")).to be_directory
|
|
|
|
expect(the_bundle).to include_gems "rack 1.0.0"
|
|
|
|
end
|
|
|
|
|
2020-05-16 06:47:24 -04:00
|
|
|
it "re-installs gems whose extensions have been deleted", :ruby_repo do
|
2018-11-02 19:07:56 -04:00
|
|
|
build_lib "very_simple_binary", "1.0.0", :to_system => true do |s|
|
|
|
|
s.write "lib/very_simple_binary.rb", "raise 'FAIL'"
|
|
|
|
end
|
|
|
|
|
|
|
|
gemfile <<-G
|
2019-05-06 12:06:21 -04:00
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
2018-11-02 19:07:56 -04:00
|
|
|
gem "very_simple_binary"
|
|
|
|
G
|
|
|
|
|
2021-01-03 20:11:34 -05:00
|
|
|
bundle "config set --local path ./vendor/bundle"
|
2020-06-03 14:45:36 -04:00
|
|
|
bundle :install
|
2018-11-02 19:07:56 -04:00
|
|
|
|
|
|
|
expect(vendored_gems("gems/very_simple_binary-1.0")).to be_directory
|
|
|
|
expect(vendored_gems("extensions")).to be_directory
|
|
|
|
expect(the_bundle).to include_gems "very_simple_binary 1.0", :source => "remote1"
|
|
|
|
|
|
|
|
vendored_gems("extensions").rmtree
|
|
|
|
|
2020-06-03 12:43:17 -04:00
|
|
|
run "require 'very_simple_binary_c'", :raise_on_error => false
|
2019-06-01 05:49:40 -04:00
|
|
|
expect(err).to include("Bundler::GemNotFound")
|
2018-11-02 19:07:56 -04:00
|
|
|
|
2021-01-03 20:11:34 -05:00
|
|
|
bundle "config set --local path ./vendor/bundle"
|
2020-05-29 06:46:16 -04:00
|
|
|
bundle :install
|
2018-11-02 19:07:56 -04:00
|
|
|
|
|
|
|
expect(vendored_gems("gems/very_simple_binary-1.0")).to be_directory
|
|
|
|
expect(vendored_gems("extensions")).to be_directory
|
|
|
|
expect(the_bundle).to include_gems "very_simple_binary 1.0", :source => "remote1"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "to a file" do
|
|
|
|
before do
|
2020-05-08 01:19:04 -04:00
|
|
|
FileUtils.touch bundled_app("bundle")
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "reports the file exists" do
|
|
|
|
gemfile <<-G
|
2019-05-06 12:06:21 -04:00
|
|
|
source "#{file_uri_for(gem_repo1)}"
|
2018-11-02 19:07:56 -04:00
|
|
|
gem "rack"
|
|
|
|
G
|
|
|
|
|
2021-01-03 20:11:34 -05:00
|
|
|
bundle "config set --local path bundle"
|
2020-06-03 12:43:17 -04:00
|
|
|
bundle :install, :raise_on_error => false
|
2019-04-14 02:01:35 -04:00
|
|
|
expect(err).to include("file already exists")
|
2018-11-02 19:07:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|