I have command I would like to call with Dart.
The command is sonar-runner
which works perfectly if I run it in a normal Ubuntu terminal. This is because I have edited the PATH
in the .profile
file so it becomes a global command.
However, if I wrote a simple Process.start
code that should trigger the same thing:
Process.run('sonar-runner', []).then((result) {
stdout.write(result.stdout);
stderr.write(result.stderr);
});
I get as a response:
Uncaught Error: ProcessException: No such file or directory
Command: sonar-runner
Unhandled exception:
ProcessException: No such file or directory
Command: sonar-runner
I am guessing this is an Ubuntu configuration thing, as I have no problem running ping localhost
via Dart in the same way.
What could be wrong, so that a third party application cannot find global commands when running it as a new process?
UPDATED - SOLUTION WAS FOUND
I found the solution to my problem, as described here:
Set Environment variable using Process.start
For my specific case, this code worked:
Process.run("bash", ["-c", "sonar-runner"]).then((result) {
stdout.write(result.stdout);
stderr.write(result.stderr);
});
Try this approach run it in a normal Ubuntu terminal
:
Process.run('sonar-runner', [], runInShell: true).then((result) {
stdout.write(result.stdout);
stderr.write(result.stderr);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With