You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
> error: `proc-macro` crate types currently cannot export any items other than functions tagged with `#[proc_macro]`, `#[proc_macro_derive]`, or `#[proc_macro_attribute]`
> --> core/macros/src/lib.rs:14:1
> |
> 14 | pub fn main() {}
> | ^^^^^^^^^^^^^
>
> error: could not compile `macros` (lib) due to 1 previous error
> warning: build failed, waiting for other jobs to finish...
For full logs, run 'nix-store -l /nix/store/ymbh5xqg7z4cbiprgvs2i93fw93k27r7-cargo-package-deps-0.0.1.drv'.
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 and my-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:
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:
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 Cargo.tomls is stripping out lib.proc-macro = true which might be a separate bug) 🤔
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: