Grigoriev Nick
Grigoriev Nick

Reputation: 1129

Sbt external process can't process `eval` command

Running in sbt command "eval $(minikube docker-env)" !! log give exception.

[error] java.io.IOException: Cannot run program "eval": error=2, No such file or directory

but same command in bash script

#!/usr/bin/env bash
eval $(minikube docker-env)

Runn as "eval.sh" !! log Work fine. I can't understand why. Please explain.

Upvotes: 3

Views: 296

Answers (1)

that other guy
that other guy

Reputation: 123450

eval is a shell feature. There is no way to call it from java to set up the environment for future commands the way you can for a shell.

If you want to run a second command from Java that depends on doing eval "$(minikube docker-env)" first, you can instead run a single shell with both commands:

String shellCommand = "eval \"$(minikube docker-env)\"; your-second-command";
Runtime.exec(new String[] { "sh", "-c", shellCommand });

Upvotes: 3

Related Questions