Stream: beginners

Topic: ld: library 'zstd' not found


view this post on Zulip Luke Boswell (Jun 12 2024 at 06:02):

I recently updated my mac OS. Now when I try to run cargo build on roc I get an error ld: library 'zstd' not found and ld: warning: ignoring duplicate libraries: '-lm'.

Has anyone else come across these issues?

I have zstd installed I think.

$ which zstd
/opt/homebrew/bin/zstd

view this post on Zulip Luke Boswell (Jun 12 2024 at 06:03):

I can build things using nix develop so not a total blocker.. though I use to be able to build this way also

view this post on Zulip Brendan Hansknecht (Jun 12 2024 at 06:06):

zstd is the executable I wonder if you need the shared lib separately

view this post on Zulip Luke Boswell (Jun 12 2024 at 06:08):

I have the library... not sure why ld can't find it

$ pwd
/opt/homebrew/Cellar/zstd/1.5.6/lib
$ ls -al
total 2784
drwxr-xr-x   8 luke  admin     256 Jun  3 19:11 .
drwxr-xr-x  13 luke  admin     416 Jun  7 19:02 ..
drwxr-xr-x   3 luke  admin      96 Mar 22 09:05 cmake
-rw-r--r--   1 luke  admin  669440 Jun  3 19:11 libzstd.1.5.6.dylib
lrwxr-xr-x   1 luke  admin      19 Mar 22 09:05 libzstd.1.dylib -> libzstd.1.5.6.dylib
-r--r--r--   1 luke  admin  753312 Mar 22 09:05 libzstd.a
lrwxr-xr-x   1 luke  admin      15 Mar 22 09:05 libzstd.dylib -> libzstd.1.dylib
drwxr-xr-x   3 luke  admin      96 Jun  3 19:11 pkgconfig

view this post on Zulip Luke Boswell (Jun 12 2024 at 06:09):

Maybe it's meant to be symlink'd somewhere without the version number

view this post on Zulip Luke Boswell (Jun 12 2024 at 06:09):

But I would have thought homebrew would manage all that

view this post on Zulip Joshua Warner (Jul 04 2024 at 19:46):

I'm seeing the same thing; any tips? Did you end up figuring it out?

view this post on Zulip Joshua Warner (Jul 04 2024 at 19:53):

Ahh, found this in the CI config:

    env:
      LIBRARY_PATH: /opt/homebrew/Cellar/zstd/1.5.6/lib

view this post on Zulip Joshua Warner (Jul 04 2024 at 19:53):

Setting that env var seems to make things work for me

view this post on Zulip Richard Feldman (Aug 16 2024 at 16:04):

why do we depend on zstd? :thinking:

is it LLVM?

view this post on Zulip Sam Mohr (Aug 16 2024 at 16:16):

│   │   │   │   ├── snafu v0.7.5
│   │   │   │   │   ├── backtrace v0.3.69
│   │   │   │   │   │   ├── addr2line v0.21.0
│   │   │   │   │   │   │   └── gimli v0.28.0
│   │   │   │   │   │   ├── cfg-if v1.0.0
│   │   │   │   │   │   ├── libc v0.2.149
│   │   │   │   │   │   ├── miniz_oxide v0.7.1
│   │   │   │   │   │   │   └── adler v1.0.2
│   │   │   │   │   │   ├── object v0.32.2
│   │   │   │   │   │   │   ├── crc32fast v1.3.2
│   │   │   │   │   │   │   │   └── cfg-if v1.0.0
│   │   │   │   │   │   │   ├── flate2 v1.0.28
│   │   │   │   │   │   │   │   ├── crc32fast v1.3.2 (*)
│   │   │   │   │   │   │   │   └── miniz_oxide v0.7.1 (*)
│   │   │   │   │   │   │   ├── hashbrown v0.14.3 (*)
│   │   │   │   │   │   │   ├── indexmap v2.1.0
│   │   │   │   │   │   │   │   ├── equivalent v1.0.1
│   │   │   │   │   │   │   │   └── hashbrown v0.14.3 (*)
│   │   │   │   │   │   │   ├── memchr v2.6.4
│   │   │   │   │   │   │   └── ruzstd v0.5.0
│   │   │   │   │   │   │       ├── byteorder v1.5.0
│   │   │   │   │   │   │       ├── derive_more v0.99.17 (proc-macro)

view this post on Zulip Sam Mohr (Aug 16 2024 at 16:17):

From cargo tree, it seems that snafu has a backtrace feature that when enabled, brings in backtrace which uses it

view this post on Zulip Sam Mohr (Aug 16 2024 at 16:18):

rg -i zstd only brings up that usage and then us installing zstd:

❯ rg -i zstd
Cargo.lock
1707: "ruzstd",
3360:name = "ruzstd"

.github/workflows/nightly_macos_apple_silicon.yml
18:      LIBRARY_PATH: /opt/homebrew/Cellar/zstd/1.5.6/lib

www/content/install/macos_x86_64.md
24:   brew install z3 zstd

view this post on Zulip Richard Feldman (Aug 16 2024 at 16:25):

oh wow

view this post on Zulip Richard Feldman (Aug 16 2024 at 16:26):

so we could get rid of snafu and get rid of that dependency?

view this post on Zulip Richard Feldman (Aug 16 2024 at 16:26):

we barely even use snafu! :big_smile:

view this post on Zulip Sam Mohr (Aug 16 2024 at 16:26):

I believe so!

view this post on Zulip Sam Mohr (Aug 16 2024 at 16:26):

I'll make a PR

view this post on Zulip Sam Mohr (Aug 16 2024 at 16:28):

Actually, we just have to disable backtraces. Would you rather disable backtraces or remove it in favor of manually implementing std::error::Error for the...

view this post on Zulip Sam Mohr (Aug 16 2024 at 16:29):

2 enums we have

view this post on Zulip Sam Mohr (Aug 16 2024 at 16:29):

I'm leaning towards remove

view this post on Zulip Sam Mohr (Aug 16 2024 at 17:05):

https://github.com/roc-lang/roc/pull/7003

view this post on Zulip Sam Mohr (Aug 16 2024 at 17:06):

Seems like we were also "using" it in the object crate, in that the crate has a compression feature that brings in zstd. By disabling the feature, we removed the dependency.

view this post on Zulip Sam Mohr (Aug 16 2024 at 17:06):

If tests all run correctly (beyond it compiling for me locally), then we're good to go.

view this post on Zulip Sam Mohr (Aug 16 2024 at 17:07):

There's a chance, though, that there's an OSX-only code portion that uses the compression feature, in which case this PR is moot and can be closed

view this post on Zulip Richard Feldman (Aug 16 2024 at 17:46):

I think it's a good change regardless!

view this post on Zulip Sam Mohr (Aug 16 2024 at 18:21):

All the tests pass, so it looks like we don't need zstdor z3

view this post on Zulip Sam Mohr (Aug 16 2024 at 18:21):

It's on auto-merge, just needs an approval

view this post on Zulip Sam Mohr (Aug 16 2024 at 18:24):

Richard Feldman said:

why do we depend on zstd? :thinking:

is it LLVM?

This is why these "basic" questions are useful!


Last updated: Jul 06 2025 at 12:14 UTC