Extern location for sorted_collections does not exist

VS Code shows this:

extern location for sorted_collections does not exist:
libsorted_collections-3591b71508bf34cc.rmeta rustc


sorted-collections-rs is a library providing useful extension traits and convenience methods for ordered collections in Rust.


sorted_collections = { version = "0.0.8", package = 'sorted-collections' }

Import code in main.rs

extern crate sorted_collections;
use sorted_collections;

I've also tried without the extern crate directive, but the result is the same.

I'm not sure why you would get that particular error, but I notice two things:

  • sorted-collections is very old code and may have some oddities current tools aren't expecting.
  • You appear to be using RLS instead of rust-analyzer. rust-analyzer is generally much more capable and compatible. Uninstall the Rust VS Code extension and install rust-analyzer. Despite being described as unofficial and unstable, it is in fact much better-behaved and what most people use.

Since this thread is a top result when searching the web for the error message encountered, it might be worth adding to it. Apologies if this post wanders slightly of topic with regards of being unrelated to sorted-collections.

Attempting to use rls in a project with both a binary and a library gives the error message of the library being not-existent. While that is documented in the debug instructions for rls, along with how to work around it, I found it rather hard to find. As quoted from page linked above:

You can build the library by setting rust.build_lib to true (this is often most useful).

Before finding the above configuration I did follow the suggestion of trying rust-analyzer instead of rls, and attempted to use it for a full day. From my perspective the latter is still a lot more stable, and the former was practically useless to me. I have not dug into any possible cause, but with rls ALEGoToDefinition and ALERename in vim-ale works flawlessy. While the same software with rust-analyzer seem to find only a fraction of the symbols, making code navigation unergonomic and leaving code in a non-compiling state after refactoring.

Unfortunately rust-analyser seems to have a bit of stabilizing left before it can replace rls.

Which project are you working on? Can you please open an issue on GitHub - rust-analyzer/rust-analyzer: A Rust compiler front-end for IDEs so we can fix it?

The project where I encountered this is in an early phase of rapid prototyping. No source code is yet publicly available.

Issue #11249 has been filed on rust-analyzer though.

No problem. The reproduction you posted at the issue is likely enough to fix the problem.


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.