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

Exception in thread "main" com.jaredrummler.ktsh.Shell$NotFoundException on Windows #20

Open
Cyberavater opened this issue Jul 26, 2022 · 0 comments

Comments

@Cyberavater
Copy link

Cyberavater commented Jul 26, 2022

I'm not sure if I'm doing something wrong here, but I got this error on a simple kotlin project.

Exception in thread "main" com.jaredrummler.ktsh.Shell$NotFoundException: Error opening shell: 'sh'
	at com.jaredrummler.ktsh.Shell.<init>(Shell.kt:95)
	at com.jaredrummler.ktsh.Shell.<init>(Shell.kt:52)
	at com.jaredrummler.ktsh.Shell$Companion.get(Shell.kt:761)
	at com.jaredrummler.ktsh.Shell$Companion.getSH(Shell.kt:766)
	at MainKt.main(Main.kt:4)
	at MainKt.main(Main.kt)
Caused by: java.io.IOException: Cannot run program "sh": CreateProcess error=2, The system cannot find the file specified
	at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1143)
	at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)
	at java.base/java.lang.Runtime.exec(Runtime.java:615)
	at java.base/java.lang.Runtime.exec(Runtime.java:439)
	at java.base/java.lang.Runtime.exec(Runtime.java:370)
	at com.jaredrummler.ktsh.Shell$Companion.runWithEnv(Shell.kt:784)
	at com.jaredrummler.ktsh.Shell$Companion.access$runWithEnv(Shell.kt:746)
	at com.jaredrummler.ktsh.Shell.<init>(Shell.kt:90)
	... 5 more
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
	at java.base/java.lang.ProcessImpl.create(Native Method)
	at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:494)
	at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:159)
	at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1110)
	... 12 more

Process finished with exit code 1
import com.jaredrummler.ktsh.Shell

fun main() {
    val shell = Shell.SH                       // create a shell
    val result = shell.run("echo 'Hello, World!'")  // execute a command
    if (result.isSuccess) {                         // check if the exit-code was 0
        println(result.stdout())                    // prints "Hello, World!"
    }
}
@Cyberavater Cyberavater changed the title Exception in thread "main" com.jaredrummler.ktsh.Shell$NotFoundException Exception in thread "main" com.jaredrummler.ktsh.Shell$NotFoundException on Windows Aug 14, 2022
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

1 participant