Skip to content

recognize $PATHEXT on windows for cargo subcommands #10455

Closed as not planned
Closed as not planned
@insomnimus

Description

@insomnimus

Problem

Currently on Windows, external cargo subcommands must have the .exe extension for cargo to recognize them.

However, .exe files are not the only executable extensions as you already know.

Proposed Solution

What many don't know is, there's a standardized environment variable Windows uses to determine if files can be executed from $PATH, which is also pre-populated by Windows: $PATHEXT.

The contents of $PATHEXT might look like this:

.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JSE;.WSF;.WSH;.MSC;.CPL

The user is free to extend this value by adding custom extensions, and the "interpreter" is likewise configurable through some built-in cmd.exe commands or the Windows registry.

On Linux or MacOSX file extensions play no role so the user can write their cargo extensions in a bash script with a shebang and set the executable bit for cargo to recognize it (assuming the file is named cargo-* and available under $PATH).

Similar can be accomplished by respecting the value of $PATHEXT on Windows, or, not specifying *.exe since programs with an extension contained in $PATHEXT don't require the extension to be specified.

Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-custom-subcommandsArea: custom 3rd party subcommand pluginsC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`O-windowsOS: WindowsS-propose-closeStatus: A team member has nominated this for closing, pending further input from the team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions