crates.io: I still get links errors despite #4978 landing

I maintain a -sys crate but my users keep getting

error: multiple packages link to native library `z`, but a native library can be linked only once

I thought that had been fixed in rust-lang/cargo#4978 but it doesn’t seem to be working. What can I do?


In fact this is mostly a place for me to link people to, to unify the discussion. I will try to keep this up to date with any discussion below.

it doesn’t seem to be working

Here is why rust-lang/cargo#4978 doesn’t seem to be working for you. rust-lang/cargo#4978 only stops that error for crate with the links attribute in the index. That attribute only gets into the index if you publish the crate with a recent nightly/beta. So no protection for the older versions of your crate.

What can I do?

You can manually make a PR to the index to add the attribute to older versions.

Someone could scan all crates to find all the missing links attributes and add them.

It is not yet clear what the cargo team recommends at this time.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 19 (11 by maintainers)

Most upvoted comments

First prototype: https://github.com/klausi/cargo_fix_links/blob/master/src/main.rs I have hard-coded everything to get the update for libz-sys working. Let’s see if that pull request gets accepted and then we can refine the script from there.

Thanks for the info! My current plan is to build a cargo subcommand to update the links attribute for a single crate:

I tried to search the cargo source for an API how to interact with the registry and read versions, but did not find anything useful. So I think I will use https://github.com/nabijaczleweli/cargo-update which has helpers such as get_index_path() and find_package_data().