Pager for dune build -w?

I’m starting to run into really long dune build error msgs. For example:

190 |       | Special -> Worker_Msg_Untyped.make ~tag:Tag.Special ~msg:empty ~transfer_list:empty
                                                                       ^^^^^
Error: This expression has type 'a Js.js_array Js.t
       but an expression was expected of type
         Js.Unsafe.any_js_array = Js.Unsafe.top Js.t
       Type
         'a Js.js_array =
           < concat : 'a Js.js_array Js.t -> 'a Js.js_array Js.t Js.meth;
             every : ('a -> int -> 'a Js.js_array Js.t -> bool Js.t)
                     Js.callback -> bool Js.t Js.meth;
             filter : ('a -> int -> 'a Js.js_array Js.t -> bool Js.t)
                      Js.callback -> 'a Js.js_array Js.t Js.meth;
             forEach : ('a -> int -> 'a Js.js_array Js.t -> unit) Js.callback ->
                       unit Js.meth;
             join : Js.js_string Js.t -> Js.js_string Js.t Js.meth;
             length : int Js.prop;
             map : ('a -> int -> 'a Js.js_array Js.t -> 'a) Js.callback ->
                   'a Js.js_array Js.t Js.meth;
             pop : 'a Js.optdef Js.meth; push : 'a -> int Js.meth;
             push_2 : 'a -> 'a -> int Js.meth;
             push_3 : 'a -> 'a -> 'a -> int Js.meth;
             push_4 : 'a -> 'a -> 'a -> 'a -> int Js.meth;
             reduce : ('a -> 'a -> int -> 'a Js.js_array Js.t -> 'a)
                      Js.callback -> 'a Js.meth;
             reduceRight : ('a -> 'a -> int -> 'a Js.js_array Js.t -> 'a)
                           Js.callback -> 'a Js.meth;
             reduceRight_init : 'b.
                                  ('b ->
                                   'a -> int -> 'a Js.js_array Js.t -> 'b)
                                  Js.callback -> 'b -> 'b Js.meth;
             reduce_init : 'b.
                             ('b -> 'a -> int -> 'a Js.js_array Js.t -> 'b)
                             Js.callback -> 'b -> 'b Js.meth;
             reverse : 'a Js.js_array Js.t Js.meth;
             shift : 'a Js.optdef Js.meth;
             slice : int -> int -> 'a Js.js_array Js.t Js.meth;
             slice_end : int -> 'a Js.js_array Js.t Js.meth;
             some : ('a -> int -> 'a Js.js_array Js.t -> bool Js.t)
                    Js.callback -> bool Js.t Js.meth;
             sort : ('a -> 'a -> float) Js.callback ->
                    'a Js.js_array Js.t Js.meth;
             sort_asStrings : 'a Js.js_array Js.t Js.meth;
             splice : int -> int -> 'a Js.js_array Js.t Js.meth;
             splice_1 : int -> int -> 'a -> 'a Js.js_array Js.t Js.meth;
             splice_2 : int -> int -> 'a -> 'a -> 'a Js.js_array Js.t Js.meth;
             splice_3 : int ->
                        int -> 'a -> 'a -> 'a -> 'a Js.js_array Js.t Js.meth;
             splice_4 : int ->
                        int ->
                        'a -> 'a -> 'a -> 'a -> 'a Js.js_array Js.t Js.meth;
             toLocaleString : Js.js_string Js.t Js.meth;
             toString : Js.js_string Js.t Js.meth;
             unshift : 'a -> int Js.meth;
             unshift_2 : 'a -> 'a -> int Js.meth;
             unshift_3 : 'a -> 'a -> 'a -> int Js.meth;
             unshift_4 : 'a -> 'a -> 'a -> 'a -> int Js.meth >
       is not compatible with type Js.Unsafe.top 

dune build -w only show the bottom lines, not the top lines, and there appears to be no way to scroll.

As a result, I end up killing dune build-w running dune build to see error msg, then maknig change, then manually rerunning dune build.

Question: is there some way to have dune build -w have a pager of some form? Some errors involving js_of_ocaml bindings get really long due to the member JS methods.

? Your terminal has a buffer so I don’t know what you mean there.

You could maybe use tmux which also has a configurable buffer.

Or I’d do something like this:

find src/ bin/ | entr bash -c 'dune build 2>/tmp/tmp.log

And then just tail the log file from your pager (less can do that)

I’m on nixos + urxvt. dune build -w literally fights me when I try to scroll with mouse button.

A running process outputting something often does not allow you to scroll or use < shift >-< PgUp > or similar.

What works, is teeing the output to a file:

dune build -w 2>&1 | tee -a out.txt

That’s one reason I don’t like for example build commands in “watch”-mode.

1 Like

There’s also a dune diagnostics command to view the errors in another terminal window.

Although I second the other suggestions in this thread to get a terminal emulator (or multiplexer) that has a proper scroll-back buffer.

1 Like

Scrollback works fine in urxvt for other programs, including dune build; just now dune build -w.

Are you confident this is not an issue of dune build -w rather than urxvt ?

Very confident. I use dune in watch mode nearly every day and I get to scroll through everything in tmux.

We also have a --terminal-persistence option to fiddle with for special setups. Maybe it would be useful to you?

Are you able to scroll if you “pause” dune’s output using CTRL+s (can later be resumed with CTRL+q)?