Skip to content

Config env snapshot doesn't handle case-insensitive env vars correctly on windows #11814

Closed
@sokra

Description

Problem

Some recent changes introduce snapshotting of env variables:

/// Environment variables, separated to assist testing.
env: HashMap<String, String>,

e. g. this PR #11727 by @kylematsuda

That introduces a little bug on windows where env vars are case-insensitive. env::var_os would handle that correctly, but config.get_env_os does a HashMap lookup which is case-sensitive.

e. g. the mentioned PR breaks the lookup of cargo subcommands on windows (where the env var is called Path instead of PATH).

Steps

  1. On windows install a cargo subcommand into a different directory
  2. Add the directory to your PATH
  3. Run cargo
  4. Cargo says: no such command: <subcommand>

Workaround:

set PATH2=%PATH%
set PATH=
set PATH=%PATH2%
set PATH2=

This changes the casing of the env variable.

Possible Solution(s)

Wrap the keys in the env snapshot HashMap with some case-insenstive NewType struct.

Notes

No response

Version

nightly-2023-03-01

Activity

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions