make local worker execute command with canonicalized path,#2221
make local worker execute command with canonicalized path,#2221zhizhi-dev wants to merge 4 commits intoTraceMachina:mainfrom
Conversation
as rust doc [current_dir](https://doc.rust-lang.org/std/process/struct.Command.html#method.current_dir) say `current_dir` is ambiguous
// The arguments to the command.
//
// The first argument specifies the command to run, which may be either an
// absolute path, a path relative to the working directory, or an unqualified
// path (without path separators) which will be resolved using the operating
// system's equivalent of the PATH environment variable. Path separators
// native to the operating system running on the worker SHOULD be used. If the
// `environment_variables` list contains an entry for the PATH environment
// variable, it SHOULD be respected. If not, the resolution process is
// implementation-defined.
//
// Changed in v2.3. v2.2 and older require that no PATH lookups are performed,
// and that relative paths are resolved relative to the input root. This
// behavior can, however, not be relied upon, as most implementations already
// followed the rules described above.
repeated string arguments = 1; |
thread 'test_sentinel_connect_with_url_specified_master' panicked at nativelink-store/tests/redis_store_test.rs:848:42:
Working spec: Error { code: DeadlineExceeded, messages: ["deadline has elapsed", "Timeout while connecting to redis with url: redis+sentinel://127.0.0.1:46093/?sentinelServiceName=specific_master"] }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtraceWhy ? |
|
Hi, @MarcusSorealheis |
|
@zhizhi-dev I'm reviewing now but in the short term, the tests fail, so we need to get over that issue. |
Test failure was which is weird and I'm not sure why that one occurs as the logs before it seem fine, and it feels unrelated to this issue so re-running. |
| PathBuf::from(&args[0]) | ||
| }; | ||
|
|
||
| let mut command_builder = process::Command::new(program); |
There was a problem hiding this comment.
@zhizhi-dev Can you add a test for this please? Possibly split out the canonicalisation as a new function and test that?
There was a problem hiding this comment.
Sorry, Rust is not my primary language . Recent days I use Nativelink as chromium RBE backend on Windows. Chromium's siso always send command like [‘../../third_party/llvm-build/.../clang-cl.exe',.....], Nativelink can not execute command
| let program = if Path::new(&args[0]).components().count() > 1 { | ||
| PathBuf::from(&self.work_directory) | ||
| .join(&command_proto.working_directory) | ||
| .join(&args[0]) |
There was a problem hiding this comment.
BTW there's a warning flag on this one
warning: the borrowed expression implements the required traits
--> nativelink-worker/src/running_actions_manager.rs:937:23
|
937 | .join(&args[0])
| ^^^^^^^^ help: change this to: `args[0]`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args
There was a problem hiding this comment.
Could this be a false positive?
There was a problem hiding this comment.
Nope. Previous version of the arg was also args[0] and args is a Vec of &OsStr so we don't need to re-reference them
|
I'm closing out this PR because there's now #2237 instead, which takes the work here and adds testing around it. Turns out there's some Windows-specific issues that the tests flagged and I've fixed there, but still needs testing/review on that platform as I don't have a Windows machine to test on. @zhizhi-dev You were running on that, if you're able to test that, that would be appreciated! |
as rust doc current_dir say
current_diris ambiguousThis change is