cool-easter-32542
02/03/2025, 8:19 PM2.24.0, when one has something other than an absolute path on one's PATH, Pants will throw an error like:
10:12:30.54 [ERROR] 1 Exception encountered:
Engine traceback:
in `export` goal
IntrinsicError: path_metadata_request error: path for PathNamespace.SYSTEM must an absolute path. Instead, got `${PATH}"`
10:12:31.35 [ERROR] 1 Exception encountered:
Engine traceback:
in `export-codegen` goal
IntrinsicError: path_metadata_request error: path for PathNamespace.SYSTEM must an absolute path. Instead, got `${PATH}"
This comes from
pants/src/rust/engine/src/intrinsics/digests.rs
Line 368 in</pantsbuild/pants/commit/8f4d59432c1e0482ccd6e2082a26c78b6533f89a|8f4d594>
| fn path_metadata_request(single_path: Value) -> PyGeneratorResponseNativeCall { |
| ------------------------------------------------------------------------------- |
added to support the type of uses cases outlined in #20996. The primary Python call site is -- I think --
pants/src/python/pants/core/util_rules/adhoc_process_support.py
Line 693 in</pantsbuild/pants/commit/8f4d59432c1e0482ccd6e2082a26c78b6533f89a|8f4d594>
| async def compute_workspace_invalidation_hash(path_globs: PathGlobs) -> str: |
| ---------------------------------------------------------------------------- |
which supports the spiffy shell/adhoc invalidation #21092.
That the contents of the PATH variable contains well.. paths is I agree reasonable, but there are decades of shell cruft here:
• One might have a literal like ${PATH}" due to some quoting.
• One might have something like ~/foo due to the posix quoting reasons outlined in #21900
• There might be intentional shell expressions like eval "$(pyenv init --path)" assuming bash will sort it out.
• There isn't a standard for .env files, but popular tools like vscode have pseudo shell-like expectations of them microsoft/vscode-python#18307
I'm not sure what to do exactly:
• (A) Do nothing, Pants is dramatically stricter about PATH contents than most tools. I don't think this is viable based on the number of user reports I've triaged.
• (B) Drop everything that isn't a path on the floor either of the Python or Rust sides. This stops the error, but maybe leads to cases where features work most of the time, except when the needed tools are behind one of the corner cases?
• (C) Do a full variable expansion using https://docs.rs/shellexpand/latest/shellexpand/, not just the tilde expansion in #21900. I don't think this would cover all the cases with expressions and not just variables.
*(D) Shell out to... `$SHELL`(?!) to evaluate $PATH before using.
Pants version
2.24.x
OS
Both
pantsbuild/pantscool-easter-32542
02/11/2025, 2:00 PM