Skip to content

Commit

Permalink
[rubygems/rubygems] Add newline to validate_platforms! message when p…
Browse files Browse the repository at this point in the history
…latform is missing

When I run bundle install with BUNDLE_DEPLOYMENT=true in the environment
on a different platform than I usually do development, I get the
following output to the console (wrapped exactly as shown):

Your bundle only supports platforms ["x86_64-darwin-19"] but your local platform
is x86_64-linux. Add the current platform to the lockfile with `bundle lock
--add-platform x86_64-linux` and try again.

Because the way the message wraps, its not as simple as copying the
suggested command to the clipboard because it contains a newline:

    $ bundle lock
    Writing lockfile to [...]/Gemfile.lock
    $ --add-platform x86_64-linux

Adding a newline right before the command forces the command in the
error message to be on the same line, which facilitates copy-pasting the
command in the message.

rubygems/rubygems@4cf6989b11
  • Loading branch information
win93 authored and matzbot committed Mar 7, 2022
1 parent c445963 commit 943efa8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/bundler/definition.rb
Expand Up @@ -433,7 +433,7 @@ def validate_platforms!

raise ProductionError, "Your bundle only supports platforms #{@platforms.map(&:to_s)} " \
"but your local platform is #{Bundler.local_platform}. " \
"Add the current platform to the lockfile with `bundle lock --add-platform #{Bundler.local_platform}` and try again."
"Add the current platform to the lockfile with\n`bundle lock --add-platform #{Bundler.local_platform}` and try again."
end

def add_platform(platform)
Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/commands/install_spec.rb
Expand Up @@ -856,7 +856,7 @@ def run

expect(err).to eq(
"Your bundle only supports platforms [\"x86_64-darwin-19\"] but your local platform is x86_64-linux. " \
"Add the current platform to the lockfile with `bundle lock --add-platform x86_64-linux` and try again."
"Add the current platform to the lockfile with\n`bundle lock --add-platform x86_64-linux` and try again."
)
end
end
Expand Down

0 comments on commit 943efa8

Please sign in to comment.