extendr: `devtools::install` fails with local Rust dependencies
When running rextendr::document
in RStudio, my package builds and is usable from the local environment, but unavailable to external scripts. Trying to install with devtools::install
to make it accessible results in the the error
error: failed to get `my-local-dependency` as a dependency of package `mypackage v0.0.1 (/tmp/Rtmpj00J85/file121d35b3ecd69/mypackage.Rcheck/00_pkg_src/thot/src/rust)`
Caused by:
failed to load source for dependency `my-local-dependency`
Caused by:
Unable to update /tmp/Rtmpj00J85/file121d35b3ecd69/mypackage.Rcheck/core
Caused by:
failed to read `/tmp/Rtmpj00J85/file121d35b3ecd69/mypackage.Rcheck/core/Cargo.toml`
Caused by:
No such file or directory (os error 2)
make: *** [Makevars:16: rust/target/release/libmypackage.a] Error 101
where mypackage
is the name of the rextendr
package, and my-local-dependency
is another rust crate in the same local workspace that mypackage
is in.
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 19 (19 by maintainers)
How do you plan to use your R package? Is it intended to work only on your local machine? If yes, then you can hard code absolute paths and forget about it. If however, you want to distribute it, then the best approach is probably to have your rust-only code pushed to some repository/crates.io and then in you R package you still only have Rust code necessary for interop with R and a dependency on your Rust crate with all of the logic.
The bottom line is, separate your R package from your complex Rust project.
For me, setting the
-p
flag with relative paths for the local dependencies resulted in the original error.Right, no worries. Just explain the full context and we’ll give it a go.