fix: resolve EACCES error from incorrect bundled plugins directory - #2815
Merged
code-yeongyu merged 1 commit intoMay 25, 2026
Merged
Conversation
fixes: PluginManager::bundled_root() used env!("CARGO_MANIFEST_DIR") to locate bundled plugins, baking in the source-tree path at compile time. A binary built from a root-owned checkout fails with EACCES for non-root users on startup.
|
Good catch. Using env!(CARGO_MANIFEST_DIR) for runtime path resolution is a common pitfall in Rust binaries - the fix to derive the bundled plugins path from the actual binary location at runtime is the correct approach. This prevents EACCES when users build and run the binary outside the source tree. |
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.
Cam's Explanation:
Hello, I found an issue with the resulting binary when following the quick start guide and doing:
when using the resulting binary:
rust/target/release/claw, it would try to access/root/claw/claw-code/rust/crates/plugins/bundled, the program would error and fail due to permission denied and the program would then exit. This PR fixes that behavior.Copilot's Explanation:
PluginManager::bundled_root()usedenv!("CARGO_MANIFEST_DIR")to locate bundled plugins, baking in the source-tree path at compile time (e.g./root/claw/claw-code/rust/crates/plugins/bundled). A binary built from a root-owned checkout fails withEACCESfor non-root users on startup.Changes
bundled_root()resolution order (first existing path wins):<exe_dir>/../share/claw/plugins/bundled— standard FHS install<exe_dir>/bundled— simple relocated layoutCARGO_MANIFEST_DIR/bundled— dev/source-tree fallback, only if it exists<exe_dir>/../share/claw/plugins/bundled— canonical default when nothing foundsync_bundled_plugins()error handling —EACCESon the auto-detected default bundled root is now treated as an empty plugin list rather than a fatal error. Explicitplugins.bundledRootconfig overrides continue to surface errors normally.Tests (4 new/updated):
default_bundled_root_is_not_blindly_cargo_manifest_dir— asserts the compile-time path is not returned when it doesn't existoverride_bundled_root_is_used_exactly— explicit config override is honoredexplicit_nonexistent_bundled_root_does_not_fail— missing explicit path yields empty bundled list, no errorno_bundled_root_config_uses_auto_detection_without_panic—bundled_root = Noneauto-detection path doesn't panicOriginal prompt
Create a fix in the
camAtGitHub/claw-codefork (basemain) for the upstream bug inultraworkers/claw-codeRust workspace underrust/.Background / bug
When building
rust/target/release/clawfrom a repo cloned under a root-owned directory (e.g./root/claw/claw-code), the runtime attempts to open the bundled plugins directory at startup from a compile-time path:/root/claw/claw-code/rust/crates/plugins/bundledThis happens because
PluginManager::bundled_root()usesenv!("CARGO_MANIFEST_DIR")and returns.../bundled.When the binary runs as a non-root user, this path may be unreadable, causing
EACCESand early program exit.The user validated that setting runtime config
plugins.bundledRootin project config (e.g./opt/defender-spyder-workspace/.claw.json) works, but the default fallback remains broken.Required change
Modify the default bundled plugins root resolution so it is suitable for installed/relocated binaries and does not depend on
CARGO_MANIFEST_DIRunless explicitly intended.Constraints
PluginManagerConfig.bundled_rootis explicitly provided (e.g. via runtime configplugins.bundledRoot).std::env::current_exe()(e.g.<exe_dir>/../share/claw/plugins/bundledor<exe_dir>/bundled). Choose a reasonable convention.CARGO_MANIFEST_DIR/bundled, but only if it exists and as a last resort.Tests
Add/adjust unit tests in the plugins crate to cover:
bundled_rootis not set, the default no longer blindly returnsCARGO_MANIFEST_DIR/bundled.bundled_rootis provided, that value is used.Tests should be reliable in CI.
Acceptance criteria
clawbinary from a root-owned repo checkout as a non-root user should no longer attempt to open/root/.../rust/crates/plugins/bundledby default.Relevant code
rust/crates/plugins/src/lib.rs:PluginManager::bundled_root()currently usesenv!("CARGO_MANIFEST_DIR").sync_bundled_plugins()usesconfig.bundled_root.unwrap_or_else(Self::bundled_root).Please implement the fix and open a PR on the fork.
The following is the prior conversation context from the user's chat exploration (may be truncated):
User: i cloned this repo and from the rust directory i ran:
cargo build -r --workspaceit worked.For reference I cloned the repo to my local directory
/root/claw/claw-codeand the compiled binary during startup now has the fatal to non-root flaw that the binary is trying to access/root/claw/claw-code/rust/crates/plugins/bundled- it gets permission error and exits the program early into the startup.My strace shows the issue: