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

Show the context name for errors happening in "alt" contexts #10414

Merged
merged 18 commits into from
Jun 19, 2024

Conversation

jchavarri
Copy link
Collaborator

Fixes #10378.

Initially I started looking into adding the changes at a later stage (Build_cmd, Report_error) but at that moment it seems it's already "too late" and I couldn't find a way to get the context where the process is being executed from. In the end I am resorting

The print function doesn't add any new information if the context name is default. Maybe there could be some opt-in configuration to enable default logging in all cases added in a future PR cc @davesnx.

Given the pervasiveness of User_message.make, I assume this initial PR is missing a lot of places where it'd be interesting to print the context name as well. But I thought it'd make things easier for reviewers to start with a small PR, and then follow up later on with other PRs that will include any improvements over it.

Signed-off-by: Javier Chávarri <[email protected]>
Signed-off-by: Javier Chávarri <[email protected]>
Signed-off-by: Javier Chávarri <[email protected]>
@rgrinberg
Copy link
Member

We're actually trying to get rid of contexts from the engine and make them strictly rule only, so this PR would make it more more difficult for us.

I think we pass the directory with some user messages. So you could try extracting in Report_error and deriving the context from that.

Signed-off-by: Javier Chávarri <[email protected]>
@jchavarri
Copy link
Collaborator Author

@rgrinberg is 63f17d1 what you had in mind? I tried moving the with-directory annotation function to User_message to simplify things further, but this creates a cycle between User_message and Path. I assume that's the reason why it was in Process to begin with.

@jchavarri
Copy link
Collaborator Author

We're actually trying to get rid of contexts from the engine and make them strictly rule only, so this PR would make it more more difficult for us.

Ftr: #7049.

@jchavarri jchavarri requested a review from emillon April 26, 2024 07:38
Signed-off-by: Javier Chávarri <[email protected]>
@rgrinberg
Copy link
Member

@rgrinberg is 63f17d1 what you had in mind? I tried moving the with-directory annotation function to User_message to simplify things further, but this creates a cycle between User_message and Path. I assume that's the reason why it was in Process to begin with.

I'm going to double check this tomorrow, but I think you can just get rid of that annotation and just include dir inside User_message.

@jchavarri
Copy link
Collaborator Author

I think you can just get rid of that annotation and just include dir inside User_message.

I tried adding a new field dir : Path.t option to User_message.t, but I get some dep cycle error:

Error: dependency cycle between modules in
_build/default/otherlibs/stdune/src:
   User_warning
-> Path
-> Path
-> required by _build/default/otherlibs/stdune/src/stdune.cmxa
-> required by
   _build/default/otherlibs/dune-rpc-lwt/examples/rpc_client/rpc_client.exe
-> required by _build/install/default/bin/dune-rpc-lwt-example-client
-> required by _build/default/dune-rpc-lwt.install
-> required by alias install

I don't get it very well because User_warning doesn't really use Path.

@emillon
Copy link
Collaborator

emillon commented May 2, 2024

I think there's a cycle even without User_warning since in the original code:

  • Path depends on User_error through User_error.raise calls
  • User_error depends on User_message through the definiton of E
graph LR
User_error -- User_error.raise --> Path
User_message -- User_error.t --> User_error
Loading

@rgrinberg
Copy link
Member

That's a bit of a pain. I think you can just use a string path though.

@jchavarri
Copy link
Collaborator Author

I think you can just use a string path though.

Tried something in 550d20e.

Signed-off-by: Javier Chávarri <[email protected]>
@jchavarri
Copy link
Collaborator Author

Tests are failing for unrelated reason, see #10484.

Signed-off-by: Javier Chávarri <[email protected]>
@rgrinberg
Copy link
Member

@pmwhite can you check if this change is going to work internally?

@pmwhite
Copy link
Collaborator

pmwhite commented May 22, 2024

@rgrinberg I just wrote a patch to import this PR internally. It mostly applies without changes, except for a few places (e.g. action_runners.ml, process.ml, and build_system_error.ml) where we already had access to the directory through a job_summary field that has yet to be upstreamed. These places are not very significant, and all our internal tests pass, so this PR is 👍 with respect to not conflicting with internal changes.

@rgrinberg
Copy link
Member

Ok, thanks. In general, I'm quite happy to get rid of this "annots" map and just shove things directly into the user error type. Once the internal patch is merged, could you sync this PR with it and we can merge?

@rgrinberg rgrinberg merged commit 3d6d55a into ocaml:main Jun 19, 2024
28 checks passed
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

Successfully merging this pull request may close these issues.

Include the context name for errors that happen in the non-default context
5 participants