Skip to content

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

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

Closed
Haoxiqiang opened this issue Oct 16, 2024 · 4 comments · Fixed by #7

Comments

@Haoxiqiang
Copy link

Haoxiqiang commented Oct 16, 2024

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?

@MatrixDev
Copy link
Owner

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?

@Haoxiqiang
Copy link
Author

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.

@Haoxiqiang
Copy link
Author

Haoxiqiang commented Oct 23, 2024

@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.

MatrixDev added a commit that referenced this issue Dec 27, 2024
@MatrixDev MatrixDev linked a pull request Dec 27, 2024 that will close this issue
@MatrixDev
Copy link
Owner

I couldn't find any meaningfull solution so at this moment we need to provide cargo path manually in the local.properties file:

sdk.dir=...
cargo.bin=/Users/{user}/.cargo/bin/

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

Successfully merging a pull request may close this issue.

2 participants