Can't find crate 'syntax' when trying to use soundcloud crate

Hello,

I'm trying to work out if I'm not setting up a project correctly, or if there is a problem with a dependency that I'm using.

I'm trying to create a simple project that uses the soundcloud crate: https://crates.io/crates/soundcloud

when I reference that crate in my project and run cargo bulid or cargo run I get an error that extern crate syntax; cannot be found.

error[E0463]: can't find crate for `syntax`
    --> /Users/alex/.cargo/registry/src/github.com-1ecc6299db9ec823/aster-0.22.1/src/lib.rs:10:1
     |
10 | extern crate syntax;
     | ^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: could not compile `aster`.
warning: build failed, waiting for other jobs to finish...
error: build failed

Can anyone else check that crate works for them or tell me what I'm doing wrong with my project setup?

1 Like

I'm pretty sure the syntax crate is (was?) the compiler's internal parser. This was never stable to begin with. So it doesn't suprise me this doesn't build (it's a 4 year old unmaintained crate that you are trying to build).

2 Likes

Right that's what I was hoping was the case, it's had over 800 downloads but it's been a long time since it's been updated.

Thanks for looking at this.

1 Like

If you're interested in updating it (and either forking / releasing, or just using it internally), it looks like there's one main "bad" dependency. The serde_macros version 0.7 crate is probably what's depending on syntax. If the serde and serde_json dependencies were updated to 1.0, and serde_macros replaced with serde_derive 1.0, then I imagine it should compile. I think all the other dependencies were always buildable on stable rust, so they should still build.

It would be a good idea to also update log to 0.4 (not a big change) and replace hyper with reqwest 0.10 (a bigger change), but those two shouldn't be necessary just to compile.

Thanks for the tip @daboross, I tried updating the dependencies but now I get an error with openssl_sys_extras when I try and build.

It's to do with openssl/hmac.h file not found.

1 Like

Ah darn- I guess the older openssl crate versions probably depend on having openssl headers available on the system. I know the newer versions will bundle them in if you don't have OpenSSL headers installed, but maybe not older ones.

If you're on a linux or macos and can install openssl-dev or similar, then you could try that- otherwise I think you will probably need to update hyper, which is what's depending on the old version of OpenSSL.

The problem with updating hyper though is that at around 0.11, I think, they became an async http library and radically changed most of their APIs. So it'll probably be easier to switch to a different up-to-date blocking client than try to update hyper directly. reqwest::blocking is one I know of which uses hyper internally. Probably also need to bump url from 1.0 to 2.0 to go along with that. It's more involved than updating serde, but it still should be possible?