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

Neon fails when having a main.rs file #1040

Closed
paviro opened this issue May 11, 2024 · 12 comments · Fixed by neon-bindings/neon-rs#53
Closed

Neon fails when having a main.rs file #1040

paviro opened this issue May 11, 2024 · 12 comments · Fixed by neon-bindings/neon-rs#53

Comments

@paviro
Copy link

paviro commented May 11, 2024

Hi,
My project also builds a CLI tool from main.rs it seems like as soon as a main.rs is present neon fails with

> neon dist < cargo.log

error: No artifacts were generated for crate

Moving it to main_.rs and then back to main.rs when building with neon works.

Best,
Paul

@kjvalencik
Copy link
Member

I believe when a crate is both a lib and a bin cargo defaults to building the bin. Can you try adding adding --lib to the build command?

cargo build --lib

@paviro
Copy link
Author

paviro commented May 14, 2024

Sadly this does not help. But also without it cargo does build both the bin and the lib.

@kjvalencik
Copy link
Member

@dherman This might be a bug in the new CLI.

@paviro As a workaround you can make a wrapper crate for the Neon lib that re-exports everything. It will require making the project a workspace.

@paviro
Copy link
Author

paviro commented May 14, 2024

My workaround right now is:

cd src && mv main.rs main_.rs && cd ..
npm run build
cd src && mv main_.rs main.rs && cd ..

Looks ridiculous but works for my case. Thank you for the additional hints though!

@kjvalencik
Copy link
Member

I'm glad you have a workaround! If you have a second to test cargo-cp-artifact to see if it works, that will help narrow down if the issue was introduced in the new CLI. Thanks!

@paviro
Copy link
Author

paviro commented May 14, 2024

I am quite new to rust and neon so I am not sure what exactly to test. Could you give me a hint?

@dherman
Copy link
Collaborator

dherman commented May 16, 2024

I can reproduce too! I'll get this fixed asap.

@dherman
Copy link
Collaborator

dherman commented May 16, 2024

Found the culprit. I'll publish a fix soon!

dherman added a commit to neon-bindings/neon-rs that referenced this issue May 16, 2024
- fixes neon-bindings/neon#1040
- add test harness for cli
- add test for hybrid crates
@dherman
Copy link
Collaborator

dherman commented May 16, 2024

@paviro What version of @neon-rs/cli do you have in your package.json? I've published a new version that fixes the issue, and it should work to just update to 0.1.69. But let me know if you have trouble upgrading and I'll be happy to help.

@dherman
Copy link
Collaborator

dherman commented May 16, 2024

(Reopening for now just to make sure it actually works for @paviro.)

@dherman dherman reopened this May 16, 2024
@paviro
Copy link
Author

paviro commented May 16, 2024

It works, thank you for the quick fix! And for being so lovely to reopen the issue until I confirmed, made me smile!

@paviro paviro closed this as completed May 16, 2024
@tsingwong
Copy link

thanks. update the newest version help me fix the problem.

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 a pull request may close this issue.

4 participants