Skip to content

Commit

Permalink
[rubygems/rubygems] Reword the message
Browse files Browse the repository at this point in the history
For errors that could happened while loading `rubygems/defaults/operating_system`

rubygems/rubygems@6e1e2141f8
  • Loading branch information
daniel-niknam authored and hsbt committed Aug 31, 2021
1 parent 7d85948 commit 34e073c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/rubygems.rb
Expand Up @@ -1333,7 +1333,12 @@ def default_gem_load_paths
rescue LoadError
# Ignored
rescue Exception => e
raise e.class, "#{e.message}\nThis is not expected so please report this issue to your OS support and ask for help."
msg = "#{e.message}\n" \
"Loading the rubygems/defaults/operating_system.rb file caused an error. " \
"This file is owned by your OS, not by rubygems upstream. " \
"Please find out which OS package this file belongs to and follow the guidelines from your OS to report " \
"the problem and ask for help."
raise e.class, msg
end

begin
Expand Down
6 changes: 5 additions & 1 deletion test/rubygems/test_rubygems.rb
Expand Up @@ -15,7 +15,11 @@ def test_operating_system_other_exceptions

output = Gem::Util.popen(*ruby_with_rubygems_and_fake_operating_system_in_load_path(path), '-e', "'require \"rubygems\"'", {:err => [:child, :out]}).strip
assert !$?.success?
assert_includes output, "This is not expected so please report this issue to your OS support and ask for help"
assert_includes output, "unterminated string meets end of file (SyntaxError)"
assert_includes output, "Loading the rubygems/defaults/operating_system.rb file caused an error. " \
"This file is owned by your OS, not by rubygems upstream. " \
"Please find out which OS package this file belongs to and follow the guidelines from your OS to report " \
"the problem and ask for help."
end

private
Expand Down

0 comments on commit 34e073c

Please sign in to comment.