Process PATH search prefers current directory #37101
Labels
area-core-library
SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.
library-io
P1
A high priority bug; for example, a single project is unusable or has many test failures
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
The Dart process execute search prefers the current directory over a PATH search. This behavior violates the rule of least surprise and doesn't appear to be documented. It should instead simply do a path search.
This example program demonstrates the issue:
This normally works if the system tar is first in the PATH, but if the current directory contains an executable file named
tar
, then that is preferred even when the current directory is not in the PATH.If that file exists, the test instead prints
Preferred the current directory
because it preferred the current directory even though it was not in the PATH.This seems related to the dart --namespace option. The issue seems to be in
runtime/bin/process_linux.cc
andruntime/bin/process_android.cc
inProcessStarter::ExecProcess
andProcessStarter::ExecDetachedProcess
The intention of the namespace feature seems to be to emulate a different root directory and working directory, possibly per isolate. The PATH search in the namespace case doesn't seem to be implemented at all, where only absolute paths work. I'll understand what the code is trying to do a bit closer and then come up with a proper fix.
cc @jonasfj
The text was updated successfully, but these errors were encountered: