Skip to content

Fix dnf shell bug#2315

Open
smjagtap wants to merge 2 commits intorpm-software-management:masterfrom
smjagtap:fix_dnf_shell_bug
Open

Fix dnf shell bug#2315
smjagtap wants to merge 2 commits intorpm-software-management:masterfrom
smjagtap:fix_dnf_shell_bug

Conversation

@smjagtap
Copy link
Copy Markdown

Summary

Improves error handling and user feedback in DNF shell when dependency resolution fails.

Problem

Currently, when dependency resolution fails in DNF shell mode:

  • Errors are only printed to stdout without proper logging
  • Users don't receive actionable suggestions to resolve the issue
  • Shell continues execution even after resolve failure

This makes troubleshooting dependency issues in shell mode much harder compared to regular DNF command mode.

Solution

This PR adds:

  • Proper error logging via ex_Error() function
  • Contextual suggestions based on the error type:
    • --allowerasing for conflicting packages
    • --skip-broken when strict mode is enabled
    • --nobest when best-only candidates fail
    • --setopt=optional_metadata_types=filelists for file dependency issues
  • Prevents execution when resolve fails

Testing

  • Tested with packages that have dependency conflicts
  • Verified error logging works correctly
  • Confirmed helpful suggestions are displayed
  • Verified shell stops after resolve failure

Files Changed

  • dnf/cli/commands/shell.py - Added error handling and user feedback.
  • dnf/AUTHORS - Added Suresh Jagtap in AUTHORS.

   When dependency resolution fails in DNF shell mode, errors are only
   printed to stdout without proper logging, and users don't receive
   actionable suggestions to resolve the issue. Additionally, the shell
   continues execution even after resolve failure.

   This patch adds:
   - Proper error logging via ex_Error() function
   - Contextual suggestions based on the error type:
     * --allowerasing for conflicting packages
     * --skip-broken when strict mode is enabled
     * --nobest when best-only candidates fail
     * --setopt=optional_metadata_types=filelists for file dependency issues
   - Prevents shell from continuing after resolve failure

   = changelog =
   msg: shell: Provide helpful suggestions when dependency resolution fails
   type: enhancement
   resolves: rpm-software-management#2314
@smjagtap smjagtap requested a review from a team as a code owner March 27, 2026 09:54
@smjagtap smjagtap requested a review from ppisar March 27, 2026 09:54
Copy link
Copy Markdown
Contributor

@ppisar ppisar left a comment

Choose a reason for hiding this comment

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

While this code might work, I'm against it, from a conceptual point of view: dnf shell is an interactive Python session for debugging and meddling with the internal implementation. It's not intended for general use and thus adding "helpfull hints" to the error messages is not welcome.

@ppisar
Copy link
Copy Markdown
Contributor

ppisar commented Mar 30, 2026

DNF team discussed this pull request and concluded that enhancing dnf shell like that is not a problem. I will review the code from functional point of view and provide a feed feedback.

@ppisar ppisar self-assigned this Mar 30, 2026
@ppisar
Copy link
Copy Markdown
Contributor

ppisar commented Apr 1, 2026

The code does not stop processing when a dependency error is encountered. Having this script:

# cat /tmp/test 
config exclude apr
run
install httpd
run
repository list

The output looks like this:

# PYTHONPATH=~test/dnf dnf4 shell /tmp/test; echo $?
Repository 'variables' is missing name in configuration, using id.
Last metadata expiration check: 0:10:02 ago on Wed 01 Apr 2026 05:42:05 PM CEST.
Nothing to do.
Complete!
Last metadata expiration check: 0:10:02 ago on Wed 01 Apr 2026 05:42:05 PM CEST.
Error: 
 Problem: package httpd-2.4.66-6.fc45.x86_64 from f45-build requires httpd-core = 2.4.66-6.fc45, but none of the providers can be installed
  - package httpd-core-2.4.66-6.fc45.x86_64 from f45-build requires libapr-1.so.0()(64bit), but none of the providers can be installed
  - conflicting requests
  - package apr-1.7.6-5.fc44.x86_64 from f45-build is filtered out by exclude filtering
(try to add '--skip-broken' to skip uninstallable packages)
repo id                       repo name
dnf-nightly                   Copr repo for dnfnightly owned by rpmsoftwaremanagement
f45-build                     Fedora 45 on Koji
rpminspect                    Copr repo for rpminspect
Error: 
 Problem: package httpd-2.4.66-6.fc45.x86_64 from f45-build requires httpd-core = 2.4.66-6.fc45, but none of the providers can be installed
  - package httpd-core-2.4.66-6.fc45.x86_64 from f45-build requires libapr-1.so.0()(64bit), but none of the providers can be installed
  - conflicting requests
  - package apr-1.7.6-5.fc44.x86_64 from f45-build is filtered out by exclude filtering
(try to add '--skip-broken' to skip uninstallable packages)
1

As you can see it continues evaluating repository list command after failed run command.
Also doubling the dependency resolution error is not good.

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.

2 participants