-
Notifications
You must be signed in to change notification settings - Fork 413
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
jbuilder utop doesn't load ppx_rewriters #346
Comments
@diml any tips on how to make this work? I would like to get this working if it isn't too hard. |
We could pass the same ppx command we pass to merlin to utop. |
Bump, I got the problem again when I try to debug a PPX I was working on, and wanted to see the syntax tree interactively! |
Yh, let's try to do that soon. That shouldn't be too difficult. @Drup or anyone else, if you'd like to work on it I can provide some pointers. |
Here are a few pointers:
Essentially, what you want to do is:
Then there will be something more to do for runtime dependencies, I'll describe that later. /cc @stephanieyou |
Does it make sense to add a
This would create a toplevel with (The reason this wasn't brought up earlier is that this issue predates the toplevel stanza) |
Indeed, that's a good idea! @rgrinberg could you give a few pointers to @stephanieyou for how to add such a field? |
Sure. At first, it's better to start with the advice that follows:
Then, a
As far as I understand, nothing special needs to be done here. If you use Feel free to ask if there's anything unclear. |
Thanks for the pointers, @diml and @rgrinberg! I'm currently testing my addition of the pps field to the toplevel stanza, and my test hangs when I attempt to use the
The ppx clflag If I remove |
Do you have a branch somewhere we can try? That should make it easier for us to help you debug. If I had to blindly guess, then I would say that the toplevel is stuck in the interactive loop waiting for input. Try running the test manually and see if you get more output this way. |
I'm currently working on the toplevel-ppx branch on my fork. (https://github.com/stephanieyou/dune/tree/toplevel-ppx) Sorry if this is a silly question, but how do I run the test manually? I tried to run
I don't get this error when running |
Ah yeah, that’s because you’re using the dune that’s installed globally (likely via opam). You need to use the dune that you’ve just built in development. This dune should exist in the _build/install/default/bin directory.
To use it, one simple way is to spawn a shell with the directory above in PATH. You could do this with:
$ ./dune.exe exec bash
bash-5.0$ which dune
/Users/rgrinberg/github/ocaml/dune/_build/install/default/bin/dune
$ # run whatever command you need to execute the test
…On Mar 26, 2020, 7:14 PM -0700, Stephanie You ***@***.***>, wrote:
I'm currently working on the toplevel-ppx branch on my fork. (https://github.com/stephanieyou/dune/tree/toplevel-ppx)
Sorry if this is a silly question, but how do I run the test manually? I tried to run dune build -p preprocessors tt.exe (where preprocessors is the name of my test directory), but I get this error:
File "dune", line 10, characters 1-11:
10 | (preprocess (pps ppx_sexp_conv)))
^^^^^^^^^^
Error: Unknown field preprocess
I don't get this error when running dune build @toplevel-stanza.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
So the toplevel is stuck waiting for input because using [%sexp_of] gives this error: When I run Is there a difference between -ppx flag in the above command, and setting |
That’s because Topmain.main () resets Clflags.all_ppx before starting the toplevel. Try setting Compenv.first_ppx instead of Clflags.all_ppx. It’s a hack, but the toplevel API is hairy and I don’t know of a better way to do it. Let’s see if Jeremie suggests something nicer perhaps.
…On Mar 27, 2020, 12:09 PM -0700, Stephanie You ***@***.***>, wrote:
So the toplevel is stuck waiting for input because using [%sexp_of] gives this error:
Error: Uninterpreted extension 'sexp_of'
When I run
$ dune exec --root preprocessors ./tt.exe -- -ppx "/Users/stephanieyou/Desktop/work/dune/test/blackbox-tests/test-cases/toplevel-stanza/preprocessors/_build/default/.ppx/e5c62d576feb9cf4645d7d03ed58d831/ppx.exe --as-ppx" -init preprocessors/init.ml
(just added the ppx flag), the test works fine.
Is there a difference between -ppx flag in the above command, and setting Clflags.all_ppx before calling Topmain.main()? I was under the impression that the -ppx flag sets Clflags.all_ppx in utop/uTop_main.ml.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
If we have a library with a
(ppx_kind rewriter)
defined in a directory, then$ jbuilder utop
will not not make this ppx extension usable in the toplevel. Would be nice if that would be automatic, or at least possible somehow.The text was updated successfully, but these errors were encountered: