philss / rustler_precompiled

Use precompiled NIFs from trusted sources in your Elixir code
182 stars 26 forks source link

Confusion regarding checksum file #15

Closed nbw closed 2 years ago

nbw commented 2 years ago

Hi there,

I'm having an issue publishing a library I would like some help. I'm a little confused by the documentation so I'd be happy to submit a PR once we've clarified the issue.

The library I've published is: https://github.com/nbw/qrusty

When I add the library to a another project, for example a new phoenix app, then the following error occurs during compilation:

==> qrusty
could not compile dependency :qrusty, "mix compile" failed. You can recompile this dependency with "mix deps.compile qrusty", update it with "mix deps.update qrusty" or clean it with "mix deps.clean qrusty"
==> qrtester
** (Mix) Could not find a Mix.Project, please ensure you are running Mix in a directory with a mix.exs file

To include the checksum file, I pushed this commit based on the mix.exs file of nx's explorer.

  1. I ran mix rustler_precompiled.download Qrusty.Native --all --print

  2. confirmed the existence of a checksum file

    Screenshot 2022-05-22 at 0 24 26
  3. then ran mix hex.publish which pushed 0.1.2 to hex (here)

Am I missing a step?

wojtekmach commented 2 years ago

By setting:

files: [
  "checksum-*.exs"
],

you're making that only checksum is part of your package, not mix.exs, not lib/, nothing.

If you published this less than an hour ago, consider reverting the release. Otherwise, retire it as it is unusable.

Notice that Nx is setting :files like this: https://github.com/elixir-nx/explorer/blob/v0.1.1/mix.exs#L65:L72

When you're publishing the package, Hex outputs what's in it. Make sure all the files are there.

You can also do this mix hex.build --unpack to check if the package looks good locally.

Finally, if a package is published you can also check it on Hex Preview: https://preview.hex.pm/preview/qrusty/0.1.2.

nbw commented 2 years ago

Thanks for the tips! I've retired the versions I've already pushed as you suggested.

Is there a different way other than the way explorer configures includes or is that only way (to include all the other files too)? I would just not have made that leap based on the current docs for rustler_precompiled. I'll gladly put up a PR to clarify it, but just want to make sure I'm understanding everything correctly.

[Update]

wojtekmach's solution worked. Thank you. I'll put out a PR later to update the docs (and example)

Screenshot 2022-05-22 at 11 23 09

nbw commented 2 years ago

i think this issue has been addressed by #16