Skip to content

Conversation

mrswastik-robot
Copy link
Contributor

@mrswastik-robot mrswastik-robot commented Jun 17, 2025

Implements external command discovery infrastructure following cargo's proven pattern, enabling pixi to find and recognize pixi-* executables in the system PATH.

Changes

  • New module: src/cli/command_info.rs with complete external command discovery
  • Core functions:
    • find_external_commands() - Discovers all pixi-* executables in PATH
    • find_external_subcommand() - Finds specific external command by name
    • search_directories() - PATH traversal following cargo's exact pattern
    • is_executable() - Cross-platform executable detection
    • builtin_exec() - Built-in command existence check

Next Steps

This lays the foundation for command dispatching logic, allowing us to integrate this discovery with the main CLI dispatcher.

Part of #3957
Parent issue - #3956

Copy link
Contributor

@nichmor nichmor left a comment

Choose a reason for hiding this comment

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

This should serve as the foundation for handling external subcommands. The idea is that from this command::external place we can start finding and executing commands.

Hardcoding available commands is often not a good idea because it requires keeping track of and modifying them everywhere, which is prone to errors.

Copy link
Contributor

@nichmor nichmor left a comment

Choose a reason for hiding this comment

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

I think it would be a good thing to have some integration tests ( in python ) that will test finding the pixi-extension and executing them correctly. You can take a look how we do it for pixi global

Copy link
Contributor

@nichmor nichmor left a comment

Choose a reason for hiding this comment

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

One small change and by fixing the CI I think we can merge it

cwd=tmp_pixi_workspace,
stderr_contains="No such command: `pixi nonexistent`",
expected_exit_code=ExitCode.FAILURE,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you also test that it always takes the pixi commands first, e.g. pixi global install -e pixi-foobar --expose pixi-info=pixi-foobar

To make sure pixi itself always "wins"

@nichmor
Copy link
Contributor

nichmor commented Jun 25, 2025

after a discussion with @ruben-arts - we may want in followup implementation did_you_mean error message

@nichmor
Copy link
Contributor

nichmor commented Jun 25, 2025

also would be good to have some initial documentation ( pixi facing rather than pixi extension developer) around this behaviour

Copy link
Contributor

@Hofer-Julian Hofer-Julian left a comment

Choose a reason for hiding this comment

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

Awesome work @mrswastik-robot and @nichmor 🚀

Copy link
Contributor

@nichmor nichmor left a comment

Choose a reason for hiding this comment

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

looks good from my side

@nichmor nichmor merged commit 2e3dde5 into prefix-dev:main Jun 25, 2025
41 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.

4 participants