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

dnf list --installed: wrong colors #2013

Open
CanePlayz opened this issue Nov 7, 2023 · 6 comments
Open

dnf list --installed: wrong colors #2013

CanePlayz opened this issue Nov 7, 2023 · 6 comments

Comments

@CanePlayz
Copy link

I've read that red packages mean that they are no longer available through any installed repo. However, on my machine, all packages listed under dnf list --installed appear red. Is there any piece of documentation on the colors?

@kontura
Copy link
Contributor

kontura commented Nov 8, 2023

There is https://dnf.readthedocs.io/en/latest/conf_ref.html?highlight=color#main-options-colors.
I think the colors also depend on your terminal and its configuration.

@CanePlayz
Copy link
Author

Thanks, I somehow missed the "default" part in there. I still don't get why all my installed packages are marked red when they work fine and I can update them just fine, but I guess it's okay as long as they work. Or is there anything we can do to try to solve this?

@kontura kontura self-assigned this Nov 9, 2023
@kontura
Copy link
Contributor

kontura commented Nov 13, 2023

I have looked into it more and you are correct, there is indeed a bug when running with the --installed flag.

The problem is dnf is optimized to not even load information about available packages when the --installed flag is used, it just loads the system repo. Given that this information is needed for correct coloring it breaks.

@CanePlayz
Copy link
Author

Thanks for digging into it, that makes sense.

@kontura
Copy link
Contributor

kontura commented Nov 13, 2023

We have discussed this internally and the best solution we came up with would probably be to turn off the wrong colors in this case.
This command is expected to work correctly even when the remote repos are not available.

However, given that our primary focus is dnf5 we will most likely not be fixing the issue. Contributions welcome though if anyone would be interested.

@kontura kontura changed the title Question about colors dnf list --installed: wrong colors Nov 13, 2023
@Et7f3
Copy link

Et7f3 commented May 23, 2024

We have a workaround: dnf list --color=always | { sed -n '/31m/p; /Available Packages/q'; cat > /dev/null; }

dnf list without --installed first list the installed packages then it show Available Packages (this string is localized) then the list of available packages.

So this sed invocation cut when yum have finished to print the first part. The cat is to avoid broken pipe error from dnf trying to write on a closed pipe.

Also in the first part without --installed it will display correct color (only red for missing packages) so we used this: -n '/31m/p;' it is basically a grep on the escape sequence used by yum (red).

The only thing missing is how to say to yum to not wrap (since it is not a pty it wrap at 80 so repository might get on another line and not visible so you need to do yum list x after. It is still useful to see missing packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants