Skip to content

fix: treat an empty CARGO_HOME as unset - #49

Merged
VikramLex merged 1 commit into
Graphicle-AI:mainfrom
leninworld:fix-empty-cargo-home
Nov 27, 2026
Merged

VikramLex merged 1 commit into
Graphicle-AI:mainfrom
leninworld:fix-empty-cargo-home

Conversation

@leninworld

Copy link
Copy Markdown
Contributor

Summary

  • terminal::installed used an empty CARGO_HOME as a folder, so Cargo's bin folder became the relative bin. A program that cargo install put in ~/.cargo/bin was then not recognised as a Cargo install:
    • graphicle update reported "installed": "script" and printed the install script command (curl ... install.sh | sh -s -- --bin-dir ~/.cargo/bin) instead of cargo install --path runtime --locked --force.
    • graphicle uninstall, which uses the same installed, said to rm ~/.cargo/bin/graphicle instead of cargo uninstall graphicle-runtime, which would leave Cargo's install record behind.
  • Cargo itself treats an empty CARGO_HOME as unset and uses ~/.cargo, as does packaging/release_build.py (os.environ.get('CARGO_HOME') or ...). installed now does the same, with the empty-value filter the program already uses for its other variables. A non-empty value is still used as given.

Not changed: a relative CARGO_HOME (Cargo joins it to the current folder; installed still compares it as given, as on main), and crates/graphicle-graph/tools/vendor_engine_grammars.py, which also reads CARGO_HOME without the or fallback.

Test plan

  • ux_terminal::update_and_uninstall_treat_an_empty_cargo_home_as_unset puts the built program in the sandbox's ~/.cargo/bin and runs update with CARGO_HOME unset, empty, and set to another Cargo home holding a copy, then uninstall with CARGO_HOME="". On main the empty case fails (installed is "script"; uninstall gives rm ...); with this change each run reports Cargo. The test gets a small Sandbox::command_of helper so it can run the copied program with the sandbox's usual environment.
  • cargo fmt --check, cargo clippy --locked --all-targets -- -D warnings, cargo clippy --locked --all-targets --features local-inference -- -D warnings and cargo test --locked --all-targets in crates/graphicle (Rust 1.95.0, macOS). Linux and Windows run in CI.

An empty CARGO_HOME made terminal::installed look for Cargo's bin folder
at the relative path `bin`, so a program installed with `cargo install`
into ~/.cargo/bin was reported as an install-script copy: `graphicle
update` printed the install script command and `graphicle uninstall`
said to rm the file instead of `cargo uninstall graphicle-runtime`.
Cargo itself treats an empty CARGO_HOME as unset and uses ~/.cargo.

Signed-off-by: Lenin Mookiah <2639584+leninworld@users.noreply.github.com>
@VikramLex
VikramLex merged commit 167080d into Graphicle-AI:main Nov 27, 2026
14 checks passed
@VikramLex

Copy link
Copy Markdown
Member

Merged, thank you. update and uninstall now treat an empty CARGO_HOME as unset, as Cargo does, and the test covers the unset, empty and custom cases. This will ship in the next release.

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.

2 participants