rextendr
rextendr copied to clipboard
Using a local rust crate with extendr
I am working on a Rust tool with this directory structure:
I want to add R bindings in bindings/r
using rextendr that can call functions from my main Rust crate.
The specific issue I'm running into is with Cargo being unable to find the main crate during package installation. While an absolute path in bindings/r/src/rust/Cargo.toml
works:
[dependencies]
gtars = { path = "/Users/sam/Documents/Work/gtars/gtars" }
This obviously isn't suitable for distribution. Using a relative path fails during R package installation:
[dependencies]
gtars = { path = "../../../../gtars" }
Error during installation:
error: failed to get `gtars` as a dependency of package `gtars-r v0.1.0`
Caused by:
failed to load source for dependency `gtars`
How can I properly set up R bindings that:
- Can access my main Rust crate
- Works with relative paths
- Can be distributed to other users
I've tried:
- Relative paths in Cargo.toml
- Using --no-staged-install
Any guidance on the correct way to address this would be appreciated.