diff --git a/lib/bundler/cli/lock.rb b/lib/bundler/cli/lock.rb index 2ccaba86eba..beeb2e46337 100644 --- a/lib/bundler/cli/lock.rb +++ b/lib/bundler/cli/lock.rb @@ -33,7 +33,7 @@ def run options["add-platform"].each do |platform_string| platform = Gem::Platform.new(platform_string) - if platform.to_a.compact == %w(unknown) + if platform.to_s == "unknown" Bundler.ui.warn "The platform `#{platform_string}` is unknown to RubyGems " \ "and adding it will likely lead to resolution errors" end diff --git a/spec/commands/lock_spec.rb b/spec/commands/lock_spec.rb index 1c00aa3c1fa..b51003f2578 100644 --- a/spec/commands/lock_spec.rb +++ b/spec/commands/lock_spec.rb @@ -161,6 +161,12 @@ def read_lockfile(file = "Gemfile.lock") expect(lockfile.platforms).to eq([java, local, mingw]) end + it "supports adding the `ruby` platform" do + bundle! "lock --add-platform ruby" + lockfile = Bundler::LockfileParser.new(read_lockfile) + expect(lockfile.platforms).to eq([local, "ruby"].uniq) + end + it "warns when adding an unknown platform" do bundle "lock --add-platform foobarbaz" expect(out).to include("The platform `foobarbaz` is unknown to RubyGems and adding it will likely lead to resolution errors")