extendr / rextendr

An R package that helps scaffolding extendr-enabled packages or compiling Rust code dynamically
https://extendr.github.io/rextendr/
Other
184 stars 27 forks source link

Issue with install_libR_bindings #6

Closed CGMossa closed 3 years ago

CGMossa commented 3 years ago

I've tried to use rextendr at another machine, and received this error:

> library(rextendr)
> install_libR_bindings(force = TRUE, quiet = FALSE)
build directory: C:\Users\tpb398\AppData\Local\Temp\Rtmp8uYQNw\file527c2f3c6a03
error: no such subcommand: `LIBRSYS_BINDINGS_DIR=C:/Users/tpb398/Documents/R/win-library/3.6/rextendr/rust/libR-sys/src`
clauswilke commented 3 years ago

But it works on your other Windows machine?

The problem is here: https://github.com/clauswilke/rextendr/blob/85a2c458fbb3c8150013bb735c6a74b7eaf77586/R/install_libR_bindings.R#L54-L68 The system2() call needs to set an environment variable, using the env argument. I would have hoped it did that correctly, but apparently it doesn't.

clauswilke commented 3 years ago

So env doesn't seem to work on Windows:

On Windows, env is only supported for commands such as R and make which accept environment variables on their command line.

Therefore, we'll have to find some other way to hand this info through to build.rs. Does cargo accept environment variables as command-line argument?

clauswilke commented 3 years ago

@CGMossa Does the solution described here: https://stackoverflow.com/a/39908765/4975218 work for you?

CGMossa commented 3 years ago

This however works:


  Sys.setenv(
      LIBRSYS_BINDINGS_DIR = file.path(package_dir, "rust", "libR-sys", "src"))

  system2(
    command = "cargo",
    args = c(
      "build",
      sprintf("--manifest-path=%s", file.path(dir, "Cargo.toml"))
    ),
    stdout = stdout,
    stderr = stdout
  )
CGMossa commented 3 years ago

@CGMossa Does the solution described here: https://stackoverflow.com/a/39908765/4975218 work for you?

I don't know what to tell you, but that doesn't work at all. I just don't get what I'm not seeing. The thing I did above works.

Also, am I supposed to write this:

install_libR_bindings(force = TRUE, quiet = FALSE, patch.crates_io = "libR-sys = {path = \"C:/Users/tpb398/Documents/github/libR-sys\"}")

?

clauswilke commented 3 years ago

Ok, I just committed the fix you proposed. The patch.crates_io argument will go away once we update libR-sys on crates.io.