MatrixDev/GradleAndroidRustPlugin

Cannot run program "rustc" In Android Studio Ladybug | 2024.2.1 Patch 1 'RUN' menu action.

Haoxiqiang opened this issue · 4 comments

I have a weird problem, but could you please look into it?
If I click the ide menu trigger actions, for example, 'gradle sync', 'build', 'run'...
I will see an interrupt exception like this:

Cannot run program "rustc" (in directory "xxxx/app"): error=2, No such file or directory
	at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:25)

first I checked the PATH, and tested the command rustc/rustup/cargo. in the terminal, and all works well.
I try the source code and try more tests:

IT WORKS.
project.exec {
    executable = "echo"
    args = listOf("Hello, World!")
    standardOutput = System.out
    errorOutput = System.err
}
IT NOT WORKS.
project.exec {
    environment("PATH", System.getenv("PATH"))
    executable = "rustc"
    args = listOf("--version")
    standardOutput = System.out
    errorOutput = System.err
}
IT WORKS.
project.exec {
    executable = "/xxx/xx/rustc"
    args = listOf("--version")
    standardOutput = System.out
    errorOutput = System.err
}
before project.exec 
I print System.getenv( "PATH" )
the var is right and contains rust dir

I'm even more confused.
in the terminal, I tested this:

IT WORKS AND BUILD SUCESS.
./gradlew assembleDebug
> Task :app:buildDebugAdblockRust[arm64-v8a]
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.24s

> Task :app:buildDebugAdblockRust[armeabi-v7a]
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.05s

> Task :app:buildDebugAdblockRust[x86]
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.05s

> Task :app:buildDebugAdblockRust[x86_64]
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.05s

BUILD SUCCESSFUL in 2s

Could you give some advice on this situation?

hi @Haoxiqiang,

This is a strange bug and so far I cannot reproduce it on my mac. The only place this plugin uses rustc is to check rust's version in readRustCompilerVersion function. It is strange that cargo and rustup work while rustc doesn't.

Can you try to remove minimumSupportedRustVersion to skip version cheking and see if everything else works? Also which OS are you using? is it linux or macos?

I'm on macOS. I have to add that cargo rustc and rustup all did not work.
I have tried to remove minimumSupportedRustVersion and set minimumSupportedRustVersion direct to 1.69.0 or 1.80.0.
It seemed that the PATH setting was wrong, so I checked the PATH problem. I found that the command line could be executed normally during this process. Only running or building in the menu of Android Studio did not work. Okay, I have some doubts about the AS problem or the API compatibility issue of the Gradle plugin. After all, it is a relatively new version.

@MatrixDev I know the reason. The macOS limit it, maybe it's a bug.

https://stackoverflow.com/questions/29573526/running-jhipster-gradle-task-from-intellij-idea

It's too terrible.

open -n /Applications/Android Studio.app

I use the command as a temp resolver.