Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exec watch mode spawns processes with initial cwd #10262

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion bin/exec.ml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ module Command_to_exec = struct
let path = Path.to_string path in
let env = Env.to_unix env |> Spawn.Env.of_list in
let argv = path :: args in
Spawn.spawn ~prog:path ~env ~argv ()
let cwd = Spawn.Working_dir.Path Fpath.initial_cwd in
Spawn.spawn ~prog:path ~env ~cwd ~argv ()
in
Pid.of_int pid
;;
Expand Down
3 changes: 3 additions & 0 deletions doc/changes/10262.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Fix bug with `dune exec --watch` where the working directory would always be
set to the project root rather than the directory where the command was run
(#10262, @gridbugs)
4 changes: 2 additions & 2 deletions test/blackbox-tests/test-cases/exec-watch/exec-pwd.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ In normal (non-watching) mode, pwd is the folder from which dune is launched
$ rm -rf $OUTPUT
$ cd ..

While in watch mode, pwd is always the root project folder
In watch mode, pwd is also the folder from which dune is launched.
$ cd bin
$ dune exec --root .. -w -- pwd > $OUTPUT &
Entering directory '..'
Expand All @@ -20,6 +20,6 @@ While in watch mode, pwd is always the root project folder
$ until test -s $OUTPUT; do sleep 0.1; done;
$ kill $PID
$ cat $OUTPUT
$TESTCASE_ROOT
$TESTCASE_ROOT/bin
$ rm -rf $OUTPUT
$ cd ..
Loading