-
Notifications
You must be signed in to change notification settings - Fork 409
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
dune build --watch
crashes when it detects filesystem change on macOS 13.1 on some Apple Silicon machines
#6907
dune build --watch
crashes when it detects filesystem change on macOS 13.1 on some Apple Silicon machines
#6907
Comments
same here, any news? |
dune.3.7.0 shows the same crash. |
Just an update: I will try to take a look (probably won't happen before next week -- I need to procure an M1 mac). |
I tried, but could not reproduce in a M2 Macbook Air with OCaml 4.14.1 and Dune 3.7.0. Unfortunately, it is impossible to investigate with a reproducible case. By the way, there is another bug report involving M1 macs and the file watching mechanism in #6151. In principle they do not seem related, but I thought I would mention it just in case. If you can set up remote access to a machine where the issue can be reproduced, then I can try to investigate, otherwise I don't have any other ideas to propose, sorry! |
It's not related. The bug appears on every mac and I can readily reproduce it. In fact, you've pointed out the bug to me in a private slack chat before and exactly what was causing it :) |
send me a ssh key to [email protected]. At my office I am behind a NAT, so we have to schedule a time slot and I will be in a sensible network. But it will be slow. 12MBit downstream. |
Done, thanks. Let's see if we can coordinate and figure out what is going on... |
Right, thanks for the reminder :) |
@nojb quite typical the crash is shy and doesn't show in a fresh account. Also it seems to go away if I purify the messy PATH in my everyday account from $ echo $PATH to $ echo $PATH If nothing jumps at you, give me some days of fiddling with the PATH to narrow it down or have a workaround. Debugging via ssh access IMO doesn't make sense right now. |
Nothing specific, but the dune watching mechanism will "watch" every directory in
OK! We can revisit that possibility in the future as needed. Thanks. |
What is the path of the project that you're building with dune? |
fish is my default shell. But if I launch a new terminal, start a |
I can confirm that simplifying my |
@dmzimmerman do you have any paths in |
I did... I'm also embarrassed to say that |
not after cleaning, but, look at what $ opam env
set -gx OPAM_SWITCH_PREFIX '/Users/mro/.opam/4.12.1';
set -gx CAML_LD_LIBRARY_PATH '/Users/mro/.opam/4.12.1/lib/stublibs:/Users/mro/.opam/4.12.1/lib/ocaml/stublibs:/Users/mro/.opam/4.12.1/lib/ocaml';
set -gx OCAML_TOPLEVEL_PATH '/Users/mro/.opam/4.12.1/lib/toplevel';
set -gx PKG_CONFIG_PATH '/Users/mro/.opam/4.12.1/lib/pkgconfig';
set -gx PATH ':/Users/mro/.opam/4.12.1/bin' '/opt/homebrew/bin' '/bin' '/sbin' '/usr/bin' '/usr/sbin' '/usr/local/bin' '/usr/local/MacGPG2/bin' '/Users/mro/bin'; the leading colon in After setting
|
a workaround: $ eval (opam env | sed -e "s/':/'/g;s/'\.'//g") |
It is probably a good idea to robustify Dune by eg only watching absolute directories in |
Should we close this? |
I can add a patch that checks for dirs in PATH being absolute and then close. |
OK, sounds good! |
Well not so sure anymore. Here is what we are doing: let parse_path ?(sep = path_sep) s =
String.split s ~on:sep
|> List.filter_map ~f:(function
| "" -> None
| p -> Some (Path.of_filename_relative_to_initial_cwd p)) The assumption is that if there is a relative path in PATH then we treat it relative to the current working directory. Is this sane behaviour or should we safely enforce absolute paths? I would like to understand why we have a crash if the path does not exist. |
Independently of the present issue, I don't think treating it relative to the current working directory is a good idea; it makes the "watched set" of directories depend on where you are when you launch Dune. So I would filter out relative paths from
Indeed, this sounds like it should be handled in the Fsevents bindings. As a data point, in the Windows file watching backend, the existence of the path is checked, and if it doesn't exist it is ignored. (To be clear, I haven't checked if the FSEvents bindings do this check or not, I am just guessing.) cc @rgrinberg |
I've made a patch to ignore relative paths but I don't think we should close this issue until we sort out the possible issue with Fsevents. |
I don't think it's a good idea to ignore relative paths in PATH. If they are interpreted by the rest of the system and not dune, that makes dune inconsistent and poorly behaved. |
Do you mind sending a test for this issue first? I think it's just a matter of including CWD in PATH and trying to build. |
@rgrinberg I am not able to reproduce on Linux. I did something along the lines of our watching tests:
If I understood the issue correctly, the second build should fail. |
@dmzimmerman If you are able to make a cram test that you can reproduce on apple silicon that would be much appreciated. It would help us understand what the real issue is here. |
@Alizter in my case it was unrelated to apple silicon but rather to the leading colon in the fish So IMO close |
@mro I see. The leading colon in the PATH variable is still something we ought to be resilient against however. |
I'm not exactly sure how to make a cram test for this, because it requires environment variables to be set in a specific way, so it'd be more like a shell script... but boiling it down to its essence, if I run, in some directory: git clone https://github.com/OCamlPro/ocaml-solidity
cd ocaml-solidity
export PATH=/opt/homebrew/bin:/usr/bin:.
eval $(opam env)
dune build --watch the crash happens every time. This is with OPAM installed via Homebrew, and my default switch (4.14.1), but it doesn't matter which switch I use, it still crashes. The choice of |
a dune crash that occurs when: * dune is running in watch mode * $PWD is added to $PATH on macos Signed-off-by: Rudi Grinberg <[email protected]>
a dune crash that occurs when: * dune is running in watch mode * $PWD is added to $PATH on macos Signed-off-by: Rudi Grinberg <[email protected]>
a dune crash that occurs when: * dune is running in watch mode * $PWD is added to $PATH on macos Signed-off-by: Rudi Grinberg <[email protected]>
a dune crash that occurs when: * dune is running in watch mode * $PWD is added to $PATH on macos Signed-off-by: Rudi Grinberg <[email protected]>
a dune crash that occurs when: * dune is running in watch mode * $PWD is added to $PATH on macos Signed-off-by: Rudi Grinberg <[email protected]>
a dune crash that occurs when: * dune is running in watch mode * $PWD is added to $PATH on macos Signed-off-by: Rudi Grinberg <[email protected]>
a dune crash that occurs when: * dune is running in watch mode * $PWD is added to $PATH on macos Signed-off-by: Rudi Grinberg <[email protected]>
a dune crash that occurs when: * dune is running in watch mode * $PWD is added to $PATH on macos Signed-off-by: Rudi Grinberg <[email protected]>
CHANGES: - When a rule's action is interrupted, delete any leftover directory targets. This is consistent with how we treat file targets. (@rgrinberg, 7564) - Fix plugin loading with findlib. The functionality was broken in 3.7.0. (ocaml/dune#7556, @anmonteiro) - Introduce a `public_headers` field on libraries. This field is like `install_c_headers`, but it allows to choose the extension and choose the paths for the installed headers. (ocaml/dune#7512, @rgrinberg) - Load the host context `findlib.conf` when cross-compiling (ocaml/dune#7428, fixes ocaml/dune#1701, @rgrinberg, @anmonteiro) - Resolve `ppx_runtime_libraries` in the target context when cross compiling (ocaml/dune#7450, fixes ocaml/dune#2794, @anmonteiro) - Use `$PKG_CONFIG`, when set, to find the `pkg-config` binary (ocaml/dune#7469, fixes ocaml/dune#2572, @anmonteiro) - Preliminary support for Coq compiled intefaces (`.vos` files) enabled via `(mode vos)` in `coq.theory` stanzas. This can be used in combination with `dune coq top` to obtain fast re-building of dependencies (with no checking of proofs) prior to stepping into a file. (ocaml/dune#7406, @rlepigre) - Fix dune crashing on MacOS in watch mode whenever `$PATH` contains `$PWD` (ocaml/dune#7441, fixes ocaml/dune#6907, @rgrinberg) - Fix `dune install` when cross compiling (ocaml/dune#7410, fixes ocaml/dune#6191, @anmonteiro, @rizo) - Find `pps` dependencies in the host context when cross-compiling, (ocaml/dune#7410, fixes ocaml/dune#4156, @anmonteiro) - Dune in watch mode no longer builds concurrent rules in serial (ocaml/dune#7395 @rgrinberg, @jchavarri) - `dune coq top` now correctly respects the project root when called from a subdirectory. However, absolute filenames passed to `dune coq top` are no longer supported (due to being buggy) (ocaml/dune#7357, fixes ocaml/dune#7344, @rlepigre and @Alizter) - Added a `--no-build` option to `dune coq top` for avoiding rebuilds (ocaml/dune#7380, fixes ocaml/dune#7355, @Alizter) - RPC: Ignore SIGPIPE when clients suddenly disconnect (ocaml/dune#7299, ocaml/dune#7319, fixes ocaml/dune#6879, @rgrinberg) - Always clean up the UI on exit. (ocaml/dune#7271, fixes ocaml/dune#7142 @rgrinberg) - Bootstrap: remove reliance on shell. Previously, we'd use the shell to get the number of processors. (ocaml/dune#7274, @rgrinberg) - Bootstrap: correctly detect the number of processors by allowing `nproc` to be looked up in `$PATH` (ocaml/dune#7272, @Alizter) - Speed up file copying on macos by using `clonefile` when available (@rgrinberg, ocaml/dune#7210) - Adds support for loading plugins in toplevels (ocaml/dune#6082, fixes ocaml/dune#6081, @ivg, @richardlford) - Support commands that output 8-bit and 24-bit colors in the terminal (ocaml/dune#7188, @Alizter) - Speed up rule generation for libraries and executables with many modules (ocaml/dune#7187, @jchavarri) - Add `--watch-exclusions` to Dune build options (ocaml/dune#7216, @jonahbeckford) - Do not re-render UI on every frame if the UI doesn't change (ocaml/dune#7186, fix ocaml/dune#7184, @rgrinberg) - Make coq_db creation in scope lazy (@ejgallego, ocaml/dune#7133) - Non-user proccesses such as version control or config checking are now run silently. (ocaml/dune#6994, fixes ocaml/dune#4066, @Alizter) - Add the `--display-separate-messages` flag to separate the error messages produced by commands with a blank line. (ocaml/dune#6823, fixes ocaml/dune#6158, @esope) - Accept the Ordered Set Language for the `modes` field in `library` stanzas (ocaml/dune#6611, @anmonteiro). - dune install now respects --display quiet mode (ocaml/dune#7116, fixes ocaml/dune#4573, fixes ocaml/dune#7106, @Alizter) - Stub shared libraries (dllXXX_stubs.so) in Dune-installed libraries could not be used as dependencies of libraries in the workspace (eg when compiling to bytecode and/or Javascript). This is now fixed. (ocaml/dune#7151, @nojb) - Allow the main module of a library with `(stdlib ...)` to depend on other libraries (ocaml/dune#7154, @anmonteiro). - Bytecode executables built for JSOO are linked with `-noautolink` and no longer depend on the shared stubs of their dependent libraries (ocaml/dune#7156, @nojb) - Added a new user action `(concurrent )` which is like `(progn )` but runs the actions concurrently. (ocaml/dune#6933, @Alizter) - Allow `(stdlib ...)` to be used with `(wrapped false)` in library stanzas (ocaml/dune#7139, @anmonteiro). - Allow parallel execution of inline tests partitions (ocaml/dune#7012, @hhugo) - Support `(link_flags ...)` in `(cinaps ...)` stanza. (ocaml/dune#7423, fixes ocaml/dune#7416, @nojb) - Allow `(package ...)` in any position within `(rule ...)` stanza (ocaml/dune#7445, @Leonidas-from-XIV) - Always include `opam` files in the generated `.install` file. Previously, it would not be included whenever `(generate_opam_files true)` was set and the `.install` file wasn't yet generated. (ocaml/dune#7547, @rgrinberg)
CHANGES: - Fix string quoting in the json file written by `--trace-file` (ocaml/dune#7773, @rleshchinskiy) - Read `pkg-config` arguments from the `PKG_CONFIG_ARGN` environment variable (ocaml/dune#1492, ocaml/dune#7734, @anmonteiro) - Correctly set `MANPATH` in `dune exec`. Previously, we would use the `bin/` directory of the context. (ocaml/dune#7655, @rgrinberg) - Allow overriding the `ocaml` binary with findlib configuration (ocaml/dune#7648, @rgrinberg) - merlin: ignore instrumentation settings for preprocessing. (ocaml/dune#7606, fixes ocaml/dune#7465, @Alizter) - When a rule's action is interrupted, delete any leftover directory targets. This is consistent with how we treat file targets. (ocaml/dune#7564, @rgrinberg) - Fix plugin loading with findlib. The functionality was broken in 3.7.0. (ocaml/dune#7556, @anmonteiro) - Introduce a `public_headers` field on libraries. This field is like `install_c_headers`, but it allows to choose the extension and choose the paths for the installed headers. (ocaml/dune#7512, @rgrinberg) - Load the host context `findlib.conf` when cross-compiling (ocaml/dune#7428, fixes ocaml/dune#1701, @rgrinberg, @anmonteiro) - Add a `coqdoc_flags` field to the `coq.theory` stanza allowing the user to pass extra arguments to `coqdoc`. (ocaml/dune#7676, fixes ocaml/dune#7954 @Alizter) - Resolve `ppx_runtime_libraries` in the target context when cross compiling (ocaml/dune#7450, fixes ocaml/dune#2794, @anmonteiro) - Use `$PKG_CONFIG`, when set, to find the `pkg-config` binary (ocaml/dune#7469, fixes ocaml/dune#2572, @anmonteiro) - Modules that were declared in `(modules_without_implementation)`, `(private_modules)` or `(virtual_modules)` but not declared in `(modules)` will cause Dune to emit a warning which will become an error in 3.9. (ocaml/dune#7608, fixes ocaml/dune#7026, @Alizter) - Preliminary support for Coq compiled intefaces (`.vos` files) enabled via `(mode vos)` in `coq.theory` stanzas. This can be used in combination with `dune coq top` to obtain fast re-building of dependencies (with no checking of proofs) prior to stepping into a file. (ocaml/dune#7406, @rlepigre) - Fix dune crashing on MacOS in watch mode whenever `$PATH` contains `$PWD` (ocaml/dune#7441, fixes ocaml/dune#6907, @rgrinberg) - Fix `dune install` when cross compiling (ocaml/dune#7410, fixes ocaml/dune#6191, @anmonteiro, @rizo) - Find `pps` dependencies in the host context when cross-compiling, (ocaml/dune#7410, fixes ocaml/dune#4156, @anmonteiro) - Dune in watch mode no longer builds concurrent rules in serial (ocaml/dune#7395 @rgrinberg, @jchavarri) - Dune can now detect Coq theories from outside the workspace. This allows for composition with installed theories (not necessarily installed with Dune). (ocaml/dune#7047, @Alizter, @ejgallego) - `dune coq top` now correctly respects the project root when called from a subdirectory. However, absolute filenames passed to `dune coq top` are no longer supported (due to being buggy) (ocaml/dune#7357, fixes ocaml/dune#7344, @rlepigre and @Alizter) - Added a `--no-build` option to `dune coq top` for avoiding rebuilds (ocaml/dune#7380, fixes ocaml/dune#7355, @Alizter) - RPC: Ignore SIGPIPE when clients suddenly disconnect (ocaml/dune#7299, ocaml/dune#7319, fixes ocaml/dune#6879, @rgrinberg) - Always clean up the UI on exit. (ocaml/dune#7271, fixes ocaml/dune#7142 @rgrinberg) - Bootstrap: remove reliance on shell. Previously, we'd use the shell to get the number of processors. (ocaml/dune#7274, @rgrinberg) - Bootstrap: correctly detect the number of processors by allowing `nproc` to be looked up in `$PATH` (ocaml/dune#7272, @Alizter) - Speed up file copying on macos by using `clonefile` when available (@rgrinberg, ocaml/dune#7210) - Adds support for loading plugins in toplevels (ocaml/dune#6082, fixes ocaml/dune#6081, @ivg, @richardlford) - Support commands that output 8-bit and 24-bit colors in the terminal (ocaml/dune#7188, @Alizter) - Speed up rule generation for libraries and executables with many modules (ocaml/dune#7187, @jchavarri) - Add `--watch-exclusions` to Dune build options (ocaml/dune#7216, @jonahbeckford) - Do not re-render UI on every frame if the UI doesn't change (ocaml/dune#7186, fix ocaml/dune#7184, @rgrinberg) - Make coq_db creation in scope lazy (@ejgallego, ocaml/dune#7133) - Non-user proccesses such as version control or config checking are now run silently. (ocaml/dune#6994, fixes ocaml/dune#4066, @Alizter) - Add the `--display-separate-messages` flag to separate the error messages produced by commands with a blank line. (ocaml/dune#6823, fixes ocaml/dune#6158, @esope) - Accept the Ordered Set Language for the `modes` field in `library` stanzas (ocaml/dune#6611, @anmonteiro). - dune install now respects --display quiet mode (ocaml/dune#7116, fixes ocaml/dune#4573, fixes ocaml/dune#7106, @Alizter) - Stub shared libraries (dllXXX_stubs.so) in Dune-installed libraries could not be used as dependencies of libraries in the workspace (eg when compiling to bytecode and/or Javascript). This is now fixed. (ocaml/dune#7151, @nojb) - Allow the main module of a library with `(stdlib ...)` to depend on other libraries (ocaml/dune#7154, @anmonteiro). - Bytecode executables built for JSOO are linked with `-noautolink` and no longer depend on the shared stubs of their dependent libraries (ocaml/dune#7156, @nojb) - Added a new user action `(concurrent )` which is like `(progn )` but runs the actions concurrently. (ocaml/dune#6933, @Alizter) - Allow `(stdlib ...)` to be used with `(wrapped false)` in library stanzas (ocaml/dune#7139, @anmonteiro). - Allow parallel execution of inline tests partitions (ocaml/dune#7012, @hhugo) - Support `(link_flags ...)` in `(cinaps ...)` stanza. (ocaml/dune#7423, fixes ocaml/dune#7416, @nojb) - Allow `(package ...)` in any position within `(rule ...)` stanza (ocaml/dune#7445, @Leonidas-from-XIV) - Always include `opam` files in the generated `.install` file. Previously, it would not be included whenever `(generate_opam_files true)` was set and the `.install` file wasn't yet generated. (ocaml/dune#7547, @rgrinberg) - Fix regression where Merlin was unable to handle filenames with uppercase letters under Windows. (ocaml/dune#7577, @nojb) - On nix+macos, pass `-f` to the codesign hook to avoid errors when the binary is already signed (ocaml/dune#7183, fixes ocaml/dune#6265, @greedy) - Fix bug where RPC clients built with dune-rpc-lwt would crash when closing their connection to the server (ocaml/dune#7581, @gridbugs) - Introduce mdx stanza 0.4 requiring mdx >= 2.3.0 which updates the default list of files to include `*.mld` files (ocaml/dune#7582, @Leonidas-from-XIV) - Fix RPC server on Windows (used for OCaml-LSP). (ocaml/dune#7666, @nojb) - Coq language versions less 0.8 are deprecated, and will be removed in an upcoming Dune version. All users are required to migrate to `(coq lang 0.8)` which provides the right semantics for theories that have been globally installed, such as those coming from opam (@ejgallego, @Alizter) - Bump minimum version of the dune language for the melange syntax extension from 3.7 to 3.8 (ocaml/dune#7665, @jchavarri)
Expected Behavior
I expected it to watch the filesystem and rebuild as necessary, without crashes.
Actual Behavior
It crashes every time the filesystem changes.
Reproduction
Start with any Dune project (I happened to use https://github.com/OCamlPro/ocaml-solidity). Open two terminals and change working directory in both to the root directory of the project. Run
dune build
, thendune build --watch
in one (the reason for the initialbuild
run is that if the project needs building,dune build --watch
crashes immediately with the same error as you'll see on a filesystem change). In the other, change the filesystem - either by editing one of the files, or even something liketouch foo
to create a new file that Dune wouldn't even need to build. It should crash immediately with the messageInternal error, please report upstream including the contents of _build/log
and a stack trace (which you can see in the verbose gist below) that seems to indicate anas_outside_build_dir_exn
being thrown.Specifications
dune
(output ofdune --version
): 3.6.1ocaml
(output ofocamlc --version
): 4.14.1Additional information
I replicated this on completely clean installs of OCaml 4.14.1 and Dune via OPAM (i.e.,
rm -rf ~/.opam; opam init; opam switch create 4.14.1
followed byopam
installation of Dune and the required libraries for the project I was building, on both a MacBook Pro/M1 Pro/32GB RAM and a Mac Studio/M1 Ultra/128GB RAM. Colleagues of mine who have tried the same on 16GB M1 or M1 Pro machines do not seem to be experiencing this issue, but I don't know if that's just a coincidence or something meaningful.dune
with the--verbose
flag): https://gist.github.com/dmzimmerman/89f37f639c1fe4ce7e5ee00dc6e734dd_build/log
: https://gist.github.com/dmzimmerman/0c533e90be627946637746b321874672The text was updated successfully, but these errors were encountered: