Skip to content

Built-in handling of $env.PATH doesn't expand paths when converting to a string #14780

Open
@abusch

Description

Describe the bug

Previous to 0.101.0, the default behaviour for converting $env.PATH to a string before calling an external command was to not only handle the PATH/Path case issue, but also to expand individual paths using path expand. E.g:

$env.ENV_CONVERSIONS = {
    "PATH": {
        from_string: { |s| $s | split row (char esep) | path expand --no-symlink }
        to_string: { |v| $v | path expand --no-symlink | str join (char esep) }
    }
}

After 0.101.0, the case-sensitivity issue is handled internally, but $env.ENV_CONVERSIONS is now empty by default, so no path expansion is performed.

How to reproduce

  1. Add a path to $env.PATH that requires expansion, for instance: $env.PATH = ($env.PATH | prepend [ "~/.cargo/bin" ]).
  2. Run a program that needs to exec a command found in the above path (in my case, I was running trunk which was trying to run cargo metadata)
  3. Observe the failure, as the executed program will have a $PATH variable containing the unexpanded ~/.cargo/bin path instead of the fully resolved one.

Expected behavior

I expected the default behaviour in 0.101.0 to match that of 0.100.0 and prior.

Configuration

key value
version 0.101.0
major 0
minor 101
patch 0
branch makepkg
commit_hash fb26109
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.83.0 (90b35a623 2024-11-26) (Arch Linux rust 1:1.83.0-1)
cargo_version cargo 1.83.0 (5ffbef321 2024-10-29)
build_time 2024-12-23 06:13:49 +00:00
build_rust_channel release
allocator mimalloc
features default, sqlite, trash
installed_plugins

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions