fix: use runtime CARGO_MANIFEST_DIR#834
Merged
bunnie merged 1 commit intobetrusted-io:devfrom Mar 18, 2026
Merged
Conversation
Problem: env!() bakes the path at compile time, so it breaks when the binary runs from a different location (e.g. a Guix/Nix sandbox or container). Solution: use std::env::var() to read it at runtime.
bunnie
approved these changes
Mar 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
project_root()inlocales/build.rsandxtask/src/builder.rsuses theenv!("CARGO_MANIFEST_DIR")macro, which captures the path at compile time. When the compiled binary runs in a different location than where it was originally built --- such as inside a Guix/Nix build sandbox or container -- the baked-in path is stale and points to the wrong directory.Proposed Solution
Replace
env!("CARGO_MANIFEST_DIR")withstd::env::var("CARGO_MANIFEST_DIR"). This reads the variable at runtime, so it always reflects the actual workspace location.Files changed:
locales/build.rsxtask/src/builder.rs