-
-
Notifications
You must be signed in to change notification settings - Fork 791
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
Use relative paths in -file attributes #4166
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
I see build has failed in a strange way, I expect this is due to a new Rust version being released or such.
Could you update the tests such that they demonstrate the fix working please 🙏
@@ -20,7 +20,7 @@ pub fn main() { | |||
|
|||
-export([main/0]). | |||
|
|||
-file("/root/project/test/my/mod.gleam", 1). | |||
-file("my/mod/project/test/my/mod.gleam", 1). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do these start with my/mod/project/etc
now? Shouldn't they be project/etc
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lpil We use module name as the prefix after we strip off the root, which is /root
. The existing test has my/mod
as the module name and it is used for module name normalization tests so I choose not to change to minimize the noise of this fix. If you prefer to change it, let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'm confused. Why do we use the module name as a prefix? That results in an invalid path to a file that doesn't exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lpil No worries. Here is how I understood this issue:
If you look at the #4141, here is actual -file
directory being generated before the fix:
-file("/Users/USERNAME/SOME/PATH/some_lib_or_app/src/some_lib_or_app.gleam", 26).
And the expectation is:
-file("some_lib_or_app/src/some_lib_or_app.gleam", 26), which the fix is about.
In our pipeline, I understood that the project root getting parsed as /Users/USERNAME/SOME/PATH
, the module name as some_lib_or_app
. Thus the fix. Let me know if you think there is better way to fix this issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand, so I'll give an example of what the behaviour should be.
Current working directory: /root/project
Source file location: /root/project/src/wibble.gleam
-file
value: src/wibble.gleam
The tests don't seem to match this from what I can see, why is that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, if that is what the expected behaviour, then the fix would be much simpler and I could update the code changes and tests to reflect that. So to confirm:
Currently (main branch) generates fqn for the generated erlang -file directive like this:
/root/project/src/wibble.gleam
given the cwd of /root/project
, which is the bug.
The correct behaviour is:
the file directive should be src/wibble.gleam
.
Please confirm and will take care of this soon.
Closes #4141 |
Closing this PR in favor of #4193. |
Hi @lpil,
Please have a look. It seems the entire pipeline (load, compile and gen) does uses absolute path, which IMHO is a great thing for reproducibility and tooling. This PR propagates the project root so it is stripped off from the generated module file directive. I might be completely off and feel free to comment as you see fit.