Why doesn't Dart "Process.start" execute the Ubuntu command when the command is running in the Ubuntu terminal?

I have a team that I would like to call Dart.

A command sonar-runner

that works great if I run it in a normal Ubuntu terminal. This is because I edited PATH

the file .profile

to become a global command.

However, if I were to write simple code Process.start

that should run the same thing:

Process.run('sonar-runner', []).then((result) {
  stdout.write(result.stdout);
  stderr.write(result.stderr);
});

      

I get in 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 assuming this is an Ubuntu config setting since I have no problem running ping localhost

through Dart in the same way.

What could be wrong so that a third party application cannot find global commands when launched as a new process?

UPDATED - SOLUTION WAS FOUND

I found a solution to my problem as described here:

Set environment variable using Process.start

In my specific case, this code worked:

Process.run("bash", ["-c", "sonar-runner"]).then((result) {
  stdout.write(result.stdout);
  stderr.write(result.stderr);
});

      

+3


source to share


2 answers


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);
});

      

+3


source


The problem is that "sonar runner" cannot be found, have you tried with full path?



0


source







All Articles