macOS: libiconv.2.dyld not loaded #51

Open
opened 2025-07-29 01:33:51 +00:00 by pauliesnug · 4 comments

After successfully installing Lix with the https://install.lix.systems/lix installation script, I attempted to execute /nix/nix-installer --help and received the error:

/nix/nix-installer 
dyld[PID]: Library not loaded: /nix/store/phzzjrksk8nnmjsbrpbkvv4pr383ab6v-libiconv-109/lib/libiconv.2.dylib
  Referenced from: <DISK-ID> /nix/nix-installer
  Reason: tried: '/nix/store/phzzjrksk8nnmjsbrpbkvv4pr383ab6v-libiconv-109/lib/libiconv.2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/nix/store/phzzjrksk8nnmjsbrpbkvv4pr383ab6v-libiconv-109/lib/libiconv.2.dylib' (no such file), '/nix/store/phzzjrksk8nnmjsbrpbkvv4pr383ab6v-libiconv-109/lib/libiconv.2.dylib' (no such file), '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib//libiconv.2.dylib' (no such file)
[1]    PID abort      /nix/nix-installer

My Xcode installation is up to date, I ran brew install libiconv and it was already installed. The dynamic library /nix/store/dka6i6yj8sgws93wc6m0lmqzhk21kq87-libiconv-107/lib/libiconv.2.dylib does exist on initial installation, but the executable seems to be looking for /nix/store/phzzjrksk8nnmjsbrpbkvv4pr383ab6v-libiconv-109/lib/libiconv.2.dylib, which does not exist.

I tested downloading the same executable from the latest lix-installer release: curl -sL -o lix-installer https://install.lix.systems/lix/lix-installer-aarch64-darwin && chmod +x ./lix-installer && ./lix-installer --help and got the same exact error, but if I run curl -sL -o lix-installer https://install.lix.systems/lix && chmod +x ./lix-installer && ./lix-installer --help, allowing the Rustup-based script to download the same exact executable into a tmp folder, it works perfectly and I'm able to manage my installation. Honestly have no idea why this happens.
:3

After successfully installing Lix with the `https://install.lix.systems/lix` installation script, I attempted to execute `/nix/nix-installer --help` and received the error: ```sh /nix/nix-installer dyld[PID]: Library not loaded: /nix/store/phzzjrksk8nnmjsbrpbkvv4pr383ab6v-libiconv-109/lib/libiconv.2.dylib Referenced from: <DISK-ID> /nix/nix-installer Reason: tried: '/nix/store/phzzjrksk8nnmjsbrpbkvv4pr383ab6v-libiconv-109/lib/libiconv.2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/nix/store/phzzjrksk8nnmjsbrpbkvv4pr383ab6v-libiconv-109/lib/libiconv.2.dylib' (no such file), '/nix/store/phzzjrksk8nnmjsbrpbkvv4pr383ab6v-libiconv-109/lib/libiconv.2.dylib' (no such file), '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib//libiconv.2.dylib' (no such file) [1] PID abort /nix/nix-installer ``` My Xcode installation is up to date, I ran `brew install libiconv` and it was already installed. The dynamic library `/nix/store/dka6i6yj8sgws93wc6m0lmqzhk21kq87-libiconv-107/lib/libiconv.2.dylib` does exist on initial installation, but the executable seems to be looking for `/nix/store/phzzjrksk8nnmjsbrpbkvv4pr383ab6v-libiconv-109/lib/libiconv.2.dylib`, which does not exist. I tested downloading the same executable from the latest `lix-installer` release: `curl -sL -o lix-installer https://install.lix.systems/lix/lix-installer-aarch64-darwin && chmod +x ./lix-installer && ./lix-installer --help` and got the same exact error, but if I run `curl -sL -o lix-installer https://install.lix.systems/lix && chmod +x ./lix-installer && ./lix-installer --help`, allowing the Rustup-based script to download the same exact executable into a `tmp` folder, it works perfectly and I'm able to manage my installation. Honestly have no idea why this happens. :3
Author

Might be linked to #45

Might be linked to #45
Owner

I am very willing to believe this, yes. It would be very plausible that for some reason the binaries we built got linked to something in the nix store, which then led to the sadness observed.

I don't like non-nix environments very much but we might have to go that route to mitigate those issues. agh!

I am very willing to believe this, yes. It would be very plausible that for some reason the binaries we built got linked to something in the nix store, which then led to the sadness observed. I don't like non-nix environments very much but we might have to go that route to mitigate those issues. agh!
ktemkin self-assigned this 2025-09-21 16:31:16 +00:00
Member

The fixing commit for #45 introduced a regression, as builiding without zigbuild was pulling in bits of the current environment, which could then e.g. wind up with us linking against libiconv from the Nix store, instead of the macOS platform.

Zig has fixed their stuff, so I'm revering the fix from #45 and adding in a check to make sure our outputs never wind up building with store references:

diff --git a/build-all.xsh b/build-all.xsh
index f578393..84c6ddf 100755
--- a/build-all.xsh
+++ b/build-all.xsh
@@ -1,5 +1,5 @@
 #! /usr/bin/env nix-shell
-#! nix-shell -i xonsh -p xonsh rustup cargo-zigbuild zig
+#! nix-shell --pure -i xonsh -p xonsh rustup cargo-zigbuild zig
 #
 # vim: ts=4 sw=4 et
 #
@@ -26,13 +26,6 @@ TARGET_PLATFORMS = [
     "x86_64-unknown-linux-musl",
     "aarch64-unknown-linux-musl",
 ]
-# Required because of ring using a C toolchain and the C toolchain being busted for some reason
-# But Zig is also busted on Apple platforms. Goofy.
-# https://git.lix.systems/lix-project/lix-installer/issues/45
-ZIG_PLATFORMS = {
-    "x86_64-unknown-linux-musl",
-    "aarch64-unknown-linux-musl",
-}
 
 # Create an alias for printing to stderr.
 printerr = functools.partial(print, file=sys.stderr)
@@ -60,11 +53,18 @@ if not all_targets_present:
 # Build for each of our platforms.
 printerr("> Building any platforms that need updating.")
 for platform in TARGET_PLATFORMS:
-    cmd = 'zigbuild' if platform in ZIG_PLATFORMS else 'build'
 
     # Build...
     printerr(f"> Building for target {platform}")
-    cargo @(cmd) --release --target=@(platform)
+    cargo zigbuild --release --target=@(platform)
+
+    # ... validate the output ...
+    if 'apple' in platform:
+        # CHECK: Make sure we don't have any references to the nix store in
+        # the libraries we link to.
+        if !(/usr/bin/otool -L target/@(platform)/release/lix-installer | grep "/nix/store").output:
+            printerr(f"ERROR: the build output for '{platform}' has nix-store dependencies, but should only depend on the MacOS platform.")
+            sys.exit(-3)
 
     # ... and copy the output to the "results" directory.
     mkdir -p ./results
The fixing commit for #45 introduced a regression, as builiding _without_ zigbuild was pulling in bits of the current environment, which could then e.g. wind up with us linking against `libiconv` from the Nix store, instead of the macOS platform. Zig has fixed their stuff, so I'm revering the fix from #45 and adding in a check to make sure our outputs never wind up building with store references: ```diff diff --git a/build-all.xsh b/build-all.xsh index f578393..84c6ddf 100755 --- a/build-all.xsh +++ b/build-all.xsh @@ -1,5 +1,5 @@ #! /usr/bin/env nix-shell -#! nix-shell -i xonsh -p xonsh rustup cargo-zigbuild zig +#! nix-shell --pure -i xonsh -p xonsh rustup cargo-zigbuild zig # # vim: ts=4 sw=4 et # @@ -26,13 +26,6 @@ TARGET_PLATFORMS = [ "x86_64-unknown-linux-musl", "aarch64-unknown-linux-musl", ] -# Required because of ring using a C toolchain and the C toolchain being busted for some reason -# But Zig is also busted on Apple platforms. Goofy. -# https://git.lix.systems/lix-project/lix-installer/issues/45 -ZIG_PLATFORMS = { - "x86_64-unknown-linux-musl", - "aarch64-unknown-linux-musl", -} # Create an alias for printing to stderr. printerr = functools.partial(print, file=sys.stderr) @@ -60,11 +53,18 @@ if not all_targets_present: # Build for each of our platforms. printerr("> Building any platforms that need updating.") for platform in TARGET_PLATFORMS: - cmd = 'zigbuild' if platform in ZIG_PLATFORMS else 'build' # Build... printerr(f"> Building for target {platform}") - cargo @(cmd) --release --target=@(platform) + cargo zigbuild --release --target=@(platform) + + # ... validate the output ... + if 'apple' in platform: + # CHECK: Make sure we don't have any references to the nix store in + # the libraries we link to. + if !(/usr/bin/otool -L target/@(platform)/release/lix-installer | grep "/nix/store").output: + printerr(f"ERROR: the build output for '{platform}' has nix-store dependencies, but should only depend on the MacOS platform.") + sys.exit(-3) # ... and copy the output to the "results" directory. mkdir -p ./results ```
Member
Should be fixed by CL: https://gerrit.lix.systems/c/lix-installer/+/5339
Sign in to join this conversation.
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lix-project/lix-installer#51
No description provided.