From 47b79c3cc15a2fbf2e0ba2ee6c9ed403cd506510 Mon Sep 17 00:00:00 2001 From: Bundlerbot Date: Mon, 16 Dec 2019 20:08:32 +0000 Subject: Merge #7493 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 7493: Fix another silent rubygems issue r=deivid-rodriguez a=deivid-rodriguez ### What was the end-user problem that led to this PR? The problem was that we still have some issues where using the `gem` script on a `bundler` context is silenced. ### What was your diagnosis of the problem? My diagnosis was that `bundle exec` adds `-rbundler/setup` to RUBYOPT which silences `rubygems` output, and that we need to reset `rubygems` UI after that so that if we end up shelling out to `gem`, it is not silent. The previous approach worked for loading the `gem` script in-process, but didn't work in other case. ### What is your fix for the problem, implemented in this PR? My fix is to reset rubygems UI right after `bundler/setup`. ### Why did you choose this fix out of the possible options? I chose this fix because it fixes the problem independently of the rubygems version being run, but we can probably also fix this more cleanly inside the `gem` script by adding something like `Gem::DefaultUserInteraction.ui = Gem::ConsoleUI.new` at the top of the script. Fixes #7490. Co-authored-by: David Rodríguez (cherry picked from commit f54ae4f4b2e287792f53410dec42e6b26b3dfcaa) --- lib/bundler/cli/exec.rb | 15 +++------------ lib/bundler/setup.rb | 5 +++++ spec/commands/exec_spec.rb | 6 ++++++ 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/bundler/cli/exec.rb b/lib/bundler/cli/exec.rb index 2bace6e77d..0a1edbdbbd 100644 --- a/lib/bundler/cli/exec.rb +++ b/lib/bundler/cli/exec.rb @@ -25,12 +25,12 @@ module Bundler SharedHelpers.set_bundle_environment if bin_path = Bundler.which(cmd) if !Bundler.settings[:disable_exec_load] && ruby_shebang?(bin_path) - return with_verbose_rubygems { kernel_load(bin_path, *args) } + return kernel_load(bin_path, *args) end - with_verbose_rubygems { kernel_exec(bin_path, *args) } + kernel_exec(bin_path, *args) else # exec using the given command - with_verbose_rubygems { kernel_exec(cmd, *args) } + kernel_exec(cmd, *args) end end @@ -89,14 +89,5 @@ module Bundler first_line = File.open(file, "rb") {|f| f.read(possibilities.map(&:size).max) } possibilities.any? {|shebang| first_line.start_with?(shebang) } end - - def with_verbose_rubygems - old_ui = Gem::DefaultUserInteraction.ui - Gem::DefaultUserInteraction.ui = nil - - yield - ensure - Gem::DefaultUserInteraction.ui = old_ui - end end end diff --git a/lib/bundler/setup.rb b/lib/bundler/setup.rb index 70a0968f4b..27911dc1ad 100644 --- a/lib/bundler/setup.rb +++ b/lib/bundler/setup.rb @@ -19,4 +19,9 @@ if Bundler::SharedHelpers.in_bundle? else Bundler.ui.silence { Bundler.setup } end + + # We might be in the middle of shelling out to rubygems + # (RUBYOPT=-rbundler/setup), so we need to give rubygems the opportunity of + # not being silent. + Gem::DefaultUserInteraction.ui = nil end diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb index c1d6e4c25a..42f760ab12 100644 --- a/spec/commands/exec_spec.rb +++ b/spec/commands/exec_spec.rb @@ -61,6 +61,12 @@ RSpec.describe "bundle exec" do expect(out).to eq(Gem::VERSION) end + it "works when exec'ing to rubygems through sh -c" do + install_gemfile 'gem "rack"' + bundle "exec sh -c '#{gem_cmd} --version'" + expect(out).to eq(Gem::VERSION) + end + it "respects custom process title when loading through ruby" do script_that_changes_its_own_title_and_checks_if_picked_up_by_ps_unix_utility = <<~'RUBY' Process.setproctitle("1-2-3-4-5-6-7-8-9-10-11-12-13-14-15") -- cgit v1.2.1 From 56939f62ec1f2e13c58267b8629e965891f6b252 Mon Sep 17 00:00:00 2001 From: Bundlerbot Date: Tue, 17 Dec 2019 20:52:51 +0000 Subject: Merge #7498 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 7498: Add compatibility methods for `rubygems-bundler` gem r=deivid-rodriguez a=deivid-rodriguez ### What was the end-user problem that led to this PR? The problem was that `bundler install` on a `ruby` installation using `rvm` is broken by default. ### What was your diagnosis of the problem? My diagnosis was that during 2.1.0 development phase I removed some stuff I thought it was internal and nobody would be using. ### What is your fix for the problem, implemented in this PR? My fix is to restore a minimal compatibility layer so that this stuff works again. ### Why did you choose this fix out of the possible options? I chose this fix because I think this is the minimum set of additions that gets stuff working again. Fixes #7488. Co-authored-by: David Rodríguez (cherry picked from commit f3f34bc5e62c513190f7608edab5818414ee9669) --- .travis.yml | 3 +++ Rakefile | 9 ++++++++- lib/bundler/rubygems_integration.rb | 8 ++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 47e775cba7..e7828fd4af 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,6 +48,9 @@ jobs: - rvm: 2.6.5 script: bin/rake rubocop stage: linting + - rvm: 2.6.5 + script: bin/rake check_rvm_integration + stage: linting # Ruby 2.3 also tested in 2.x mode - rvm: 2.3.8 env: RGV=master diff --git a/Rakefile b/Rakefile index eb37dffd9a..4fd9a5179a 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,5 @@ # frozen_string_literal: true -$:.unshift File.expand_path("../lib", __FILE__) require "benchmark" require_relative "spec/support/rubygems_ext" @@ -123,6 +122,14 @@ task :rubocop do sh("bin/rubocop --parallel") end +desc "Check RVM integration" +task :check_rvm_integration do + # The rubygems-bundler gem is installed by RVM by default and it could easily + # break when we change bundler. Make sure that binstubs still run with it + # installed. + sh("bin/rake install && gem install rubygems-bundler && rake -T") +end + namespace :man do if RUBY_ENGINE == "jruby" task(:build) {} diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index bb63209632..88fcd4d9e0 100644 --- a/lib/bundler/rubygems_integration.rb +++ b/lib/bundler/rubygems_integration.rb @@ -525,6 +525,14 @@ module Bundler end end + def plain_specs + Gem::Specification._all + end + + def plain_specs=(specs) + Gem::Specification.all = specs + end + def fetch_specs(remote, name) path = remote.uri.to_s + "#{name}.#{Gem.marshal_version}.gz" fetcher = gem_remote_fetcher -- cgit v1.2.1 From 437250f93d08e8a9050fb8f20b0c5ba0272469ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 17 Dec 2019 22:34:45 +0100 Subject: Version 2.1.1 --- lib/bundler/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb index 417b21f18a..06d6a0f255 100644 --- a/lib/bundler/version.rb +++ b/lib/bundler/version.rb @@ -1,7 +1,7 @@ # frozen_string_literal: false module Bundler - VERSION = "2.1.0".freeze + VERSION = "2.1.1".freeze def self.bundler_major_version @bundler_major_version ||= VERSION.split(".").first.to_i -- cgit v1.2.1 From 0a5db7e274cac1198d7e22d4e302dd9002342eae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 17 Dec 2019 22:37:55 +0100 Subject: Changelog for 2.1.1 --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1393d19942..ec13c08754 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 2.1.1 (December 17, 2019) + +Bugfixes: + + - Fix some cases of shelling out to `rubygems` still being silent [#7493](https://github.com/bundler/bundler/pull/7493) + - Restore compatibility with `rubygems-bundler` so that binstubs work under `RVM` [#7498](https://github.com/bundler/bundler/pull/7498) + ## 2.1.0 (December 15, 2019) Features: -- cgit v1.2.1