"missing lifetime specifier" in cargo crate on commit that previously built

I can't figure out why this has stopped building.
I have reverted to an earlier commit that certainly did build previously, and tried using earlier versions of rustc (1.80, 1.79.0), but I can't get my project to build anymore.
I tried cargo clean and git clean -df

The error is fairly clear, but it seems like there's something environmental that has changed.

Creating a new dev container is certainly an option, but I'd much prefer to find out what the root cause is for future debugging.

Thank you so much for reading this and even if you can't help I really appreciate you!

The build error:

error[E0106]: missing lifetime specifier
  --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/liquid_crystal-0.2.0/src/lcd_trait/mod.rs:46:16
   |
46 |     interface: & mut T,
   |                ^ expected named lifetime parameter
   |
help: consider introducing a named lifetime parameter
   |
45 ~ pub struct LiquidCrystal<'a,  T: Interface, const COLS: u8, const LINES: usize, MODE = Blocking> {
46 ~     interface: &'a  mut T,
   |

error[E0412]: cannot find type `Rc` in this scope
  --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/liquid_crystal-0.2.0/src/lcd_trait/mod.rs:59:20
   |
59 |         interface: Rc<RefCell< T>>,
   |                    ^^ not found in this scope

Some errors have detailed explanations: E0106, E0412.
For more information about an error, try `rustc --explain E0106`.
error: could not compile `liquid_crystal` (lib) due to 2 previous errors```

I wonder if something has mistakenly modified your local copy of the liquid_crystal 0.2.0 code?

Looking in the git repo linked on lib.rs, I see interface field in liquid_crystal-0.2.0/src/lcd_trait/mod.rs in the first error has a lifetime (&'interface mut...) in both the "New API" commit ea03463db549430aaaa864839dfa0209e01d6774 and the file creation in commit b4cf9089179d74283bf8beccc5491f84dc7c887c .

I'm not sure what's the best way to have cargo re-download the cargo/registry/src files, but that may be a good first step.

Oh right, thanks for checking that!

I reinstalled the package by running:

cargo remove liquid_crystal
rm -rf /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f
cargo add liquid_crystal

And now it builds! Thank you so much @danjl1100!

FYI, there is no benefit to running those cargo remove and cargo add commands, and they could lose some configuration you had. Deletion of the cached files will suffice.

4 Likes

Thanks! That answers one of the questions I had about the relationship between the cached files and the functionality of cargo add

Is there a cargo command for clearing the system-wide cache? I had assumed that cargo clean did that, but after reading the docs I realise that just cleans up target folders

No. It should never be modified, and if it is, you can just delete it. (cargo clean without options is also equivalent to just deleting target/.)

Ah ok. In the rare case that it is modified, is there a cargo command to verify the cache checksums?

Not that I know of. The manual lists all the commands — it's a fairly short list and worth skimming. Someone might have written a plugin for doing this job, though.

Here are some issues about improving the situation:

2 Likes

Thank you again! I had read all the cargo commands, but I had hoped I was missing something. I was about to check if there were any issues submitted regarding making the cache read-only, but you got there first!

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.