Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sbt external process can't process `eval` command

Tags:

bash

scala

eval

sbt

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.

like image 309
Grigoriev Nick Avatar asked Dec 06 '25 19:12

Grigoriev Nick


1 Answers

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 });
like image 59
that other guy Avatar answered Dec 09 '25 13:12

that other guy