Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust_sitrep() seems to fail to instruct the user if target is not gnu and matches toolchain arch on Windows #326

Open
yanyu2015 opened this issue Dec 19, 2023 · 4 comments
Assignees
Milestone

Comments

@yanyu2015
Copy link

system:win11
R version:4.3.2

> rust_sitrep()
Rust infrastructure sitrep:
✔ "rustup": 1.26.0 (5af9b9484 2023-04-05)
✔ "cargo": 1.74.1 (ecb9851af 2023-10-18)
ℹ host: x86_64-pc-windows-msvc
ℹ toolchain: stable-x86_64-pc-windows-msvc
ℹ target: x86_64-pc-windows-msvc

When I use the code in the example, I encounter the following error

> rust_function("fn add(a:f64, b:f64) -> f64 { a + b }")
ℹ build directory: C:/Users/admin/AppData/Local/Temp/RtmpKMywd4/file75383e69395d
    Updating crates.io index
   Compiling proc-macro2 v1.0.70
   Compiling unicode-ident v1.0.12
   Compiling libR-sys v0.6.0
   Compiling paste v1.0.14
   Compiling extendr-api v0.6.0
   Compiling once_cell v1.19.0
error: could not compile `once_cell` (lib) due to 242 previous errors
warning: build failed, waiting for other jobs to finish...

    |
454 |     impl<T: PartialEq> PartialEq for OnceCell<T> {
    |                        ^^^^^^^^^ not found in this scope

✖ error[E0405]: cannot find trait `PartialEq` in this scope
   --> D:\ds\Rusts\o\.cargo\registry\src\index.crates.io-6f17d22bba15001f\once_cell-1.19.0\src\lib.rs:454:13
    |
454 |     impl<T: PartialEq> PartialEq for OnceCell<T> {
    |             ^^^^^^^^^ not found in this scope

It should be noted that rust is installed in the path D:\ds\Rusts\o, and I have also configured the path.

@Ilia-Kosenkov
Copy link
Member

Strange that rust_sitrep() does not report that you are missing a target. It should look something like this
image
What is the version of {rextendr} that you use?

After I removed the required target (to get the screenshot above), I got like a million compilation errors in your example, which is expected. To solve this, run

rustup target add x86_64-pc-windows-gnu
rextendr::rust_sitrep()
#> Rust infrastructure sitrep:
#> ✔ "rustup": 1.26.0 (5af9b9484 2023-04-05)
#> ✔ "cargo": 1.72.1 (103a7ff2e 2023-08-15)
#> ℹ host: x86_64-pc-windows-msvc
#> ℹ toolchains: stable-i686-pc-windows-gnu, stable-x86_64-pc-windows-msvc
#>   (default), nightly-x86_64-pc-windows-gnu, nightly-x86_64-pc-windows-msvc,
#>   1.60.0-x86_64-pc-windows-msvc, 1.64.0-x86_64-pc-windows-gnu,
#>   1.64.0-x86_64-pc-windows-msvc, and 1.71.1-x86_64-pc-windows-msvc
#> ℹ targets: x86_64-pc-windows-gnu and x86_64-pc-windows-msvc

rextendr::rust_function("fn add(a:f64, b:f64) -> f64 { a + b }")
#> ℹ build directory: 'C:/Users/.../AppData/Local/Temp/RtmpqiLYgf/file6dc45f862d81'
#> ✔ Writing 'C:/Users/.../AppData/Local/Temp/RtmpqiLYgf/file6dc45f862d81/target/extendr_wrappers.R'

add(42, 100500)
#> [1] 100542

@Ilia-Kosenkov
Copy link
Member

Ilia-Kosenkov commented Dec 19, 2023

It also could be because you do not have a default toolchain set through rustup? You can try then first with

rustup default stable-msvc

followed by R

rextendr::rust_sitrep()

@yanyu2015
Copy link
Author

Now it can work properly. (After completing the above configuration, it may need to wait a moment before running rust_sitrep() to avoid potential issues of not finding rustup. Thank you.

@Ilia-Kosenkov
Copy link
Member

I hope this helped. To {rextendr} people -- I will keep this issue open & assigned to me because I want to investigate why there was no 'error' message when the default toolchain was not selected. We should be able to detect this and inform the user.

@Ilia-Kosenkov Ilia-Kosenkov self-assigned this Dec 29, 2023
@Ilia-Kosenkov Ilia-Kosenkov changed the title error: could not compile once_cell (lib) rust_sitrep() seems to fail to instruct the user if default toolchain is not selected on Windows Dec 29, 2023
@Ilia-Kosenkov Ilia-Kosenkov changed the title rust_sitrep() seems to fail to instruct the user if default toolchain is not selected on Windows rust_sitrep() seems to fail to instruct the user if target is not gnu and matches toolchain arch on Windows Jan 3, 2024
@Ilia-Kosenkov Ilia-Kosenkov added this to the v0.4.0 milestone Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants