Skip to content

Conversation

Carbonhell
Copy link
Contributor

@Carbonhell Carbonhell commented Aug 24, 2025

Fixes #3975

This pull request introduces a new global command, pixi global tree. The behavior is very similar to pixi tree, but it works on global environments.
It is required to pass an argument representing the environment to target, like pixi global list.
The implementation was extracted from the one existing for pixi tree, with some attempts at simplifying and documenting to make maintenance on it easier.

Example screenshots:
image

I also included a small tweak to reduce the verbosity of the output slightly by filtering virtual packages (such as __osx), which I believe to be of little use for users of this command. This tweak was applied both to the new command and to the workspace-specific tree command.

Just like the workspace-specific tree command, I've also allowed the possibility of printing dependent trees / reverse dependency trees by passing the --invert flag and specifying a regex to filter the packages to show.

Two assumptions I'd like confirmation on, since this is my first code PR to Pixi and I'm not knowledgeable of package managers / Conda:

  1. I assume global environments can only have Conda dependency. I'm assuming you cannot have Pypi dependencies in a global environment, since you cannot use the --pypi flag in pixi global add. I initially assumed this was possible, e.g. if I wanted a global environment with a Jupyter Notebook with specific Pypi dependencies that aren't available on Conda.
  2. I believe there's no concept of lock files for global environments. To work around this, I'm using the find_package_records method to list the dependencies of an environment from its conda-meta folder. From some basic manual tests, the output looks correct, but I'm not sure whether there is some edge case or nuance I'm missing.

I'm contributing to Pixi both because the project is really useful imo, but I also want to keep/improve my Rust skills, so please feel free to point out any issue or possible improvement during the review! Even though most of the code is "recycled" from the current implementation of pixi tree :)

Edit: I just saw another PR related to the tree command: #4261. This PR may conflict with that one. I'm not sure if the PR is still active or not. If my PR is merged first, it might be a good idea to add the json format to the global tree command for consistency.

@baszalmstra
Copy link
Contributor

Works on my machine! :)

Copy link
Contributor

@ruben-arts ruben-arts left a comment

Choose a reason for hiding this comment

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

Thank you, this is a great addition! I've add some tests and it all seems to work great!

@ruben-arts ruben-arts enabled auto-merge (squash) August 25, 2025 08:37
@ruben-arts ruben-arts merged commit f7f1d4a into prefix-dev:main Aug 25, 2025
41 checks passed
tdejager added a commit to tdejager/pixi that referenced this pull request Aug 25, 2025
@bollwyvl bollwyvl mentioned this pull request Aug 25, 2025
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.

feat(global): tree output

4 participants