Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report possible error prior checking output of gem uninstall #7149

Conversation

voxik
Copy link
Contributor

@voxik voxik commented Nov 9, 2023

Originally, the failed test case reported following error:

Failure: test_gem_exec_gem_uninstall(TestGemCommandsExecCommand):
  <""> was expected to include
  <"Successfully uninstalled a-2\n">.
/mnt/test/rubygems/test_gem_commands_exec_command.rb:742:in `block in test_gem_exec_gem_uninstall'
     739:
     740:       # assert_empty @ui.error
     741:       refute_includes @ui.output, "running gem exec with"
  => 742:       assert_includes @ui.output, "Successfully uninstalled a-2\n"
     743:
     744:       invoke "--verbose", "gem", "uninstall", "b"
     745:       assert_includes @ui.output, "Successfully uninstalled b-2\n"
/mnt/lib/rubygems/user_interaction.rb:46:in `use_ui'
/mnt/lib/rubygems/user_interaction.rb:69:in `use_ui'
/mnt/test/rubygems/test_gem_commands_exec_command.rb:726:in `test_gem_exec_gem_uninstall'

This does not tell much. Empty string is more often good sign, but not in this case. However, checking error output first helps with understanding possible issue:

Failure: test_gem_exec_gem_uninstall(TestGemCommandsExecCommand):
  <"ERROR:  While executing gem ... (Gem::FilePermissionError)\n" +
  "    You don't have write permissions for the /builddir/bin directory.\n" +
  "\t/mnt/lib/rubygems/uninstaller.rb:213:in `remove_executables'\n" +

... snip ...

/mnt/test/rubygems/test_gem_commands_exec_command.rb:740:in `block in test_gem_exec_gem_uninstall'
     737:         nil
     738:       end
     739:
  => 740:       assert_empty @ui.error
     741:       refute_includes @ui.output, "running gem exec with"
     742:       assert_includes @ui.output, "Successfully uninstalled a-2\n"
     743:
/mnt/lib/rubygems/user_interaction.rb:46:in `use_ui'
/mnt/lib/rubygems/user_interaction.rb:69:in `use_ui'
/mnt/test/rubygems/test_gem_commands_exec_command.rb:726:in `test_gem_exec_gem_uninstall'

BTW I have hit this in the context of #7119. This issue is caused by operating_system.rb overriding Gem.operating_system_defaults method and explicitly adding --bindir option.

Originally, the failed test case reported following error:

~~~
Failure: test_gem_exec_gem_uninstall(TestGemCommandsExecCommand):
  <""> was expected to include
  <"Successfully uninstalled a-2\n">.
/mnt/test/rubygems/test_gem_commands_exec_command.rb:742:in `block in test_gem_exec_gem_uninstall'
     739:
     740:       # assert_empty @ui.error
     741:       refute_includes @ui.output, "running gem exec with"
  => 742:       assert_includes @ui.output, "Successfully uninstalled a-2\n"
     743:
     744:       invoke "--verbose", "gem", "uninstall", "b"
     745:       assert_includes @ui.output, "Successfully uninstalled b-2\n"
/mnt/lib/rubygems/user_interaction.rb:46:in `use_ui'
/mnt/lib/rubygems/user_interaction.rb:69:in `use_ui'
/mnt/test/rubygems/test_gem_commands_exec_command.rb:726:in `test_gem_exec_gem_uninstall'
~~~

This does not tell much. Empty string is more often good sign, but not
in this case. However, checking error output first helps with
understanding possible issue:

~~~
Failure: test_gem_exec_gem_uninstall(TestGemCommandsExecCommand):
  <"ERROR:  While executing gem ... (Gem::FilePermissionError)\n" +
  "    You don't have write permissions for the /builddir/bin directory.\n" +
  "\t/mnt/lib/rubygems/uninstaller.rb:213:in `remove_executables'\n" +

... snip ...

/mnt/test/rubygems/test_gem_commands_exec_command.rb:740:in `block in test_gem_exec_gem_uninstall'
     737:         nil
     738:       end
     739:
  => 740:       assert_empty @ui.error
     741:       refute_includes @ui.output, "running gem exec with"
     742:       assert_includes @ui.output, "Successfully uninstalled a-2\n"
     743:
/mnt/lib/rubygems/user_interaction.rb:46:in `use_ui'
/mnt/lib/rubygems/user_interaction.rb:69:in `use_ui'
/mnt/test/rubygems/test_gem_commands_exec_command.rb:726:in `test_gem_exec_gem_uninstall'
~~~

BTW this issue is caused by operating_system.rb overriding
`Gem.operating_system_defaults` method and explicitly adding `--bindir`
option.
Copy link
Member

@deivid-rodriguez deivid-rodriguez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@deivid-rodriguez deivid-rodriguez merged commit 9363daf into rubygems:master Nov 9, 2023
83 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants