diff --git a/lib/bundler/source/path.rb b/lib/bundler/source/path.rb index 6a99f8e977ec67..d4c530e922b0d6 100644 --- a/lib/bundler/source/path.rb +++ b/lib/bundler/source/path.rb @@ -53,6 +53,8 @@ def to_s "source at `#{@path}`" end + alias_method :to_gemfile, :path + def hash [self.class, expanded_path, version].hash end diff --git a/spec/bundler/install/deploy_spec.rb b/spec/bundler/install/deploy_spec.rb index 4b2b0325c8f2e4..bd39ac5cc1d4ae 100644 --- a/spec/bundler/install/deploy_spec.rb +++ b/spec/bundler/install/deploy_spec.rb @@ -483,6 +483,27 @@ expect(err).not_to include("You have deleted from the Gemfile") end + it "explodes if you change a source from path to git" do + build_git "myrack", path: lib_path("myrack") + + install_gemfile <<-G + source "https://gem.repo1" + gem "myrack", :path => "#{lib_path("myrack")}" + G + + gemfile <<-G + source "https://gem.repo1" + gem "myrack", :git => "https:/my-git-repo-for-myrack" + G + + bundle "config set --local frozen true" + bundle :install, raise_on_error: false + expect(err).to include("frozen mode") + expect(err).to include("You have changed in the Gemfile:\n* myrack from `#{lib_path("myrack")}` to `https:/my-git-repo-for-myrack`") + expect(err).not_to include("You have added to the Gemfile") + expect(err).not_to include("You have deleted from the Gemfile") + end + it "remembers that the bundle is frozen at runtime" do bundle :lock