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

Demo does not run on OCaml 5.0: Error: Unbound module Demo after Sys_error("Broken pipe") #2

Open
lukstafi opened this issue Feb 20, 2023 · 5 comments

Comments

@lukstafi
Copy link

When I run:

:~/ppx_debug$ dune exec ./demo/debug/debug.exe -- trace debug.trace -f calls | head -n 6
File "demo/lib/other.ml", line 4, characters 8-19:
Error: Unbound module Demo

My complete session for reference:

:~/ppx_debug$ opam install . --deps-only
The following actions will be performed:
  ∗ install ppx_deriving        5.2.1
  ∗ install linenoise           1.4.0
  ∗ install containers          3.11
  ∗ install ppx_deriving_yojson 3.7.0
===== ∗ 4 =====
Do you want to continue? [Y/n] Y

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
⬇ retrieved ppx_deriving.5.2.1  (cached)
⬇ retrieved containers.3.11  (https://opam.ocaml.org/cache)
⬇ retrieved linenoise.1.4.0  (https://opam.ocaml.org/cache)
⬇ retrieved ppx_deriving_yojson.3.7.0  (https://opam.ocaml.org/cache)
∗ installed linenoise.1.4.0
∗ installed ppx_deriving.5.2.1
∗ installed containers.3.11
∗ installed ppx_deriving_yojson.3.7.0
Done.
:~/ppx_debug$ make
dune test
File "ppx_debug_common/interpret_cmt.ml", line 450, characters 9-40:
450 |          Load_path.init cmt.cmt_loadpath;
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: This expression has type
         auto_include:Load_path.auto_include_callback -> unit
       but an expression was expected of type unit
       because it is in the left-hand side of a sequence
make: *** [Makefile:8: all] Error 1             
lukstafi@DESKTOP-6RRUNR4:~/ppx_debug$ make
dune test
rm /tmp/ppx_debug* debugger.json chrome.json *.trace > /dev/null 2>&1 || true
dune exec ./demo/app/app.exe
Done: 99% (121/122, 1 left) (jobs: 1)dune exec ./demo/debug/debug.exe -- trace debug.trace > chrome.json
Done: 99% (135/136, 1 left) (jobs: 1)dune exec ./demo/debug/debug.exe -- trace debug.trace -f debugger > debugger.json
Done: 46% (6/13, 7 left) (jobs: 0)dune exec ./demo/debug/debug.exe -- trace debug.trace -f calls | head -n 6
Done: 27% (23/85, 62 left) (jobs: 0)    1 demo/lib/lib.ml:40 main = ()
    6 demo/lib/lib.ml:25 consume (t: (Misc 1)) = 1
   13 demo/lib/lib.ml:11 depth (t: (Node [(Node [(Leaf 1)]); (Leaf 2)])) = 2
   18 demo/lib/lib.ml:14 _lambda (c: (Leaf 2)), (t: 0) = 0
   21 demo/lib/lib.ml:11 depth (t: (Leaf 2)) = 0
   26 demo/lib/lib.ml:14 _lambda (c: (Node [(Leaf 1)])), (t: 0) = 1
debug: internal error, uncaught exception:
       Sys_error("Broken pipe")
       Raised by primitive operation at Stdlib in file "stdlib.ml" (inlined), line 339, characters 0-54
       Called from Stdlib__Format.formatter_of_out_channel.(fun) in file "format.ml", line 999, characters 50-58
       Called from Ppx_debug_runtime__Main.act_on.(fun) in file "ppx_debug_runtime/main.ml", line 44, characters 8-68
       Called from Stdlib__List.iter in file "list.ml", line 110, characters 12-15
       Called from Stdlib__List.iter in file "list.ml", line 110, characters 12-15
       Called from Cmdliner_term.app.(fun) in file "cmdliner_term.ml", line 24, characters 19-24
       Called from Cmdliner_eval.run_parser in file "cmdliner_eval.ml", line 34, characters 37-44
Fatal error: exception Sys_error("Broken pipe")
Raised by primitive operation at Stdlib in file "stdlib.ml" (inlined), line 339, characters 0-54
Called from Stdlib__Format.formatter_of_out_channel.(fun) in file "format.ml", line 999, characters 50-58
Called from Stdlib__Format.pp_print_flush in file "format.ml" (inlined), line 673, characters 30-51
Called from Stdlib__Format.flush_standard_formatters in file "format.ml" (inlined), line 1474, characters 2-47
Called from Stdlib.at_exit.new_exit in file "stdlib.ml", line 564, characters 59-63
Called from Stdlib.do_at_exit in file "stdlib.ml" (inlined), line 574, characters 2-31
Called from Stdlib.exit in file "stdlib.ml", line 577, characters 2-15
Called from Dune__exe__Debug in file "demo/debug/debug.ml", line 3, characters 9-52
dune exec ./demo/debug/debug.exe -- trace debug.trace -f tree | head -n 6
Done: 20% (6/30, 24 left) (jobs: 0)(1) demo/lib/lib.ml:40 main
  (6) demo/lib/lib.ml:25 consume (t: (Misc 1))
  (6) demo/lib/lib.ml:25 consume = 1
  (13) demo/lib/lib.ml:11 depth (t: (Node [(Node [(Leaf 1)]); (Leaf 2)]))
    (18) demo/lib/lib.ml:14 _lambda (c: (Leaf 2)), (t: 0)
      (21) demo/lib/lib.ml:11 depth (t: (Leaf 2))
debug: internal error, uncaught exception:
       Sys_error("Broken pipe")
       Raised by primitive operation at Stdlib in file "stdlib.ml" (inlined), line 339, characters 0-54
       Called from Stdlib__Format.formatter_of_out_channel.(fun) in file "format.ml", line 999, characters 50-58
       Called from Ppx_debug_runtime__Main.act_on.(fun) in file "ppx_debug_runtime/main.ml", line 52, characters 8-72
       Called from Stdlib__List.iter in file "list.ml", line 110, characters 12-15
       Called from Ppx_debug_runtime__Main.act_on.(fun) in file "ppx_debug_runtime/main.ml", line 53, characters 8-23
       Called from Stdlib__List.iter in file "list.ml", line 110, characters 12-15
       Called from Ppx_debug_runtime__Main.act_on.(fun) in file "ppx_debug_runtime/main.ml", line 53, characters 8-23
       Called from Stdlib__List.iter in file "list.ml", line 110, characters 12-15
       Called from Cmdliner_term.app.(fun) in file "cmdliner_term.ml", line 24, characters 19-24
       Called from Cmdliner_eval.run_parser in file "cmdliner_eval.ml", line 34, characters 37-44
Fatal error: exception Sys_error("Broken pipe")
Raised by primitive operation at Stdlib in file "stdlib.ml" (inlined), line 339, characters 0-54
Called from Stdlib__Format.formatter_of_out_channel.(fun) in file "format.ml", line 999, characters 50-58
Called from Stdlib__Format.pp_print_flush in file "format.ml" (inlined), line 673, characters 30-51
Called from Stdlib__Format.flush_standard_formatters in file "format.ml" (inlined), line 1474, characters 2-47
Called from Stdlib.at_exit.new_exit in file "stdlib.ml", line 564, characters 59-63
Called from Stdlib.do_at_exit in file "stdlib.ml" (inlined), line 574, characters 2-31
Called from Stdlib.exit in file "stdlib.ml", line 577, characters 2-15
Called from Dune__exe__Debug in file "demo/debug/debug.ml", line 3, characters 9-52
ls chrome.json debugger.json *.trace /tmp/ppx_debug* || true
/tmp/ppx_debug.txt  /tmp/ppx_debug_tool.txt  chrome.json  debug.trace  debugger.json
lukstafi@DESKTOP-6RRUNR4:~/ppx_debug$ dune exec ./demo/debug/debug.exe -- trace debug.trace -f calls | head -n 6
File "demo/lib/other.ml", line 4, characters 8-19:
Error: Unbound module Demo
@lukstafi
Copy link
Author

I see the same output in OCaml 4.14.1.

@lukstafi
Copy link
Author

Maybe there is some problem with my system. I'm using WSL 2 on Windows 11 (the default install running Ubuntu).

@lukstafi
Copy link
Author

I only get the Broken pipe error on Windows WSL 2, but on native Ubuntu I still get Unbound module Demo. Full logs:

$ make
dune test
rm /tmp/ppx_debug* debugger.json chrome.json *.trace > /dev/null 2>&1 || true
dune exec ./demo/app/app.exe
Done: 99% (121/122, 1 left) (jobs: 1)dune exec ./demo/debug/debug.exe -- trace debug.trace > chrome.json
Done: 99% (135/136, 1 left) (jobs: 1)dune exec ./demo/debug/debug.exe -- trace debug.trace -f debugger > debugger.json
Done: 28% (32/111, 79 left) (jobs: 0)dune exec ./demo/debug/debug.exe -- trace debug.trace -f calls | head -n 6
Done: 46% (6/13, 7 left) (jobs: 0)    1 demo/lib/lib.ml:40 main = ()
    6 demo/lib/lib.ml:25 consume (t: (Misc 1)) = 1
   13 demo/lib/lib.ml:11 depth (t: (Node [(Node [(Leaf 1)]); (Leaf 2)])) = 2
   18 demo/lib/lib.ml:14 _lambda (c: (Leaf 2)), (t: 0) = 0
   21 demo/lib/lib.ml:11 depth (t: (Leaf 2)) = 0
   26 demo/lib/lib.ml:14 _lambda (c: (Node [(Leaf 1)])), (t: 0) = 1
dune exec ./demo/debug/debug.exe -- trace debug.trace -f tree | head -n 6
Done: 20% (6/30, 24 left) (jobs: 0)(1) demo/lib/lib.ml:40 main
  (6) demo/lib/lib.ml:25 consume (t: (Misc 1))
  (6) demo/lib/lib.ml:25 consume = 1
  (13) demo/lib/lib.ml:11 depth (t: (Node [(Node [(Leaf 1)]); (Leaf 2)]))
    (18) demo/lib/lib.ml:14 _lambda (c: (Leaf 2)), (t: 0)
      (21) demo/lib/lib.ml:11 depth (t: (Leaf 2))
ls chrome.json debugger.json *.trace /tmp/ppx_debug* || true
chrome.json  debugger.json  debug.trace  /tmp/ppx_debug_tool.txt  /tmp/ppx_debug.txt
lukstafi@lukstafi-HP-Elite-Mini:~/ppx_debug$ dune exec ./demo/debug/debug.exe -- trace debug.trace > chrome.json
File "demo/lib/other.ml", line 4, characters 8-19:
Error: Unbound module Demo
:~/ppx_debug$ dune exec ./demo/debug/debug.exe -- trace debug.trace
File "demo/lib/other.ml", line 4, characters 8-19:
Error: Unbound module Demo

@lukstafi
Copy link
Author

Demo is not mentioned, i.e. dune describe pp demo/lib/other.ml | grep Demo is empty.

@dariusf
Copy link
Owner

dariusf commented Mar 9, 2023

I'm on macOS and can't reproduce the broken pipe issue unfortunately.

About Unbound module Demo, the fix is to set the environment variable PPX_DEBUG='{"libraries": ["demo/lib"]}'.

The reason this is needed is that given a type name from the cmt, we need to know how to access the printer for it from the project's main module - that's what is provided above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants