-
Notifications
You must be signed in to change notification settings - Fork 77
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
Cannot build proc-macro crate when using lib.proc_macro = true
(underscore vs dash)
#610
Comments
Hi @dsxmachina thanks for the report! Yes it does seem like there is something going wrong with the dummification, perhaps we have to treat proc-macro crates differently... Do you have a(n ideally) minimal reproduction I can take a look at? I tried to come up with a trivial proc-macro crate myself, but it built just fine (though now that I notice it, cleaning |
The proc-macro crate itself as a flake works fine, this seems only to be an issue with workspaces. I created a small repo to reproduce the bug: https://github.com/dsxmachina/crane-bug-test Hope this helps. |
Ah thank you for the example, I found the issue! Apparently cargo accepts both |
lib.proc_macro = true
(underscore vs dash)
Describe the bug
I have a workspace containing a few binary, library and one proc-macro crate. However, when I want to build any package or use
nix flake check
, I get a weird build error:Which is bogus, because the library does not include a
pub fn main() {}
at line 14.Reproduction
I used the example init flake from your documentation (https://crane.dev/examples/quick-start-workspace.html) and replaced
my-cli
andmy-server
with my own binary crates from the workspace. Everything else is as it is in the example.I traced down the error and found what was causing it. By looking at the derivation, I searched for the code inside the nix-store, that is used for the compilation:
This gave me quite a lot of output. Under the key "env/src" I found the link to the src repository:
And inside
/nix/store/knwb69fg1gqwhlrz4zbn23pv187za27m-source
I found the basic directory structure of my workspace, but the Code has been replaced with a dummy implementation (which seems to be something that crane does, although I don't know why or how I could influence this behaviour).Here is the code of the proc-macro library that is causing the compilation error:
And there we have the culprit -
pub fn main() {}
in line 14.It seems to me, that this is the default dummy implementation that you guys use for everything. All other library crates had their
lib.rs
content replaced with the same code above. For normal libraries it does not seem to be a problem that there is a main function defined though.The text was updated successfully, but these errors were encountered: