Skip to content

Using a local rust crate with extendr #398

Open
@sanghoonio

Description

@sanghoonio

I am working on a Rust tool with this directory structure:

image

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:

  1. Can access my main Rust crate
  2. Works with relative paths
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions