anmonteiro / lumo

Fast, cross-platform, standalone ClojureScript environment
Eclipse Public License 1.0
1.88k stars 85 forks source link

Lumo 1.10.1 doesn't run in NixOS 19.09 #492

Open thiagokokada opened 4 years ago

thiagokokada commented 4 years ago

Lumo binary (download from either GitHub Releases or npm i -g lumo-cljs) does not run in NixOS 19.09.

$ ./lumo_linux64
zsh: no such file or directory: ./lumo_linux64

It seems that it is missing libstdc++.so.6:

$ ldd ./lumo_linux64
    linux-vdso.so.1 (0x00007ffe2d4e7000)
    libdl.so.2 => /nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27/lib/libdl.so.2 (0x00007f9b13721000)
    librt.so.1 => /nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27/lib/librt.so.1 (0x00007f9b13717000)
    libstdc++.so.6 => not found
    libm.so.6 => /nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27/lib/libm.so.6 (0x00007f9b13581000)
    libgcc_s.so.1 => /nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27/lib/libgcc_s.so.1 (0x00007f9b1336b000)
    libpthread.so.0 => /nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27/lib/libpthread.so.0 (0x00007f9b1334a000)
    libc.so.6 => /nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27/lib/libc.so.6 (0x00007f9b13192000)
    /lib64/ld-linux-x86-64.so.2 => /nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27/lib64/ld-linux-x86-64.so.2 (0x00007f9b13728000)

Compiling it from source works fine:

$ build/lumo
Lumo 1.10.1
ClojureScript 1.10.520
Node.js v12.2.0
 Docs: (doc function-name-here)
       (find-doc "part-of-name-here")
 Source: (source function-name-here)
 Exit: Control+D or :cljs/quit or exit

cljs.user=> 

/etc/os-release information.

NAME=NixOS
ID=nixos
VERSION="19.09.1548.3a1861fcabc (Loris)"
VERSION_CODENAME=loris
VERSION_ID="19.09.1548.3a1861fcabc"
PRETTY_NAME="NixOS 19.09.1548.3a1861fcabc (Loris)"
LOGO="nix-snowflake"
HOME_URL="https://nixos.org/"
DOCUMENTATION_URL="https://nixos.org/nixos/manual/index.html"
SUPPORT_URL="https://nixos.org/nixos/support.html"
BUG_REPORT_URL="https://github.com/NixOS/nixpkgs/issues"
penryu commented 4 years ago

What is the output of ldd for your self-built lumo binary?

According to this page:

https://nixos.wiki/wiki/Packaging/Binaries

Downloading a binary on NixOS and trying to run it will almost never work. This is due to hard-coded paths in the executable.

...this seems to be a design "feature" of NixOS. The page also talks about the preferred solution using patchelf.

thiagokokada commented 4 years ago

What is the output of ldd for your self-built lumo binary?

$ ldd build/lumo
linux-vdso.so.1 (0x00007fffba5ac000)
libdl.so.2 => /nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27/lib/libdl.so.2 (0x00007f0e6d983000)
librt.so.1 => /nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27/lib/librt.so.1 (0x00007f0e6d979000)
libstdc++.so.6 => /nix/store/4l35nqpaiwzhfafrpby1xf7kfik7ai7c-gcc-8.3.0-lib/lib/libstdc++.so.6 (0x00007f0e6d7ee000)
libm.so.6 => /nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27/lib/libm.so.6 (0x00007f0e6d658000)
libgcc_s.so.1 => /nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27/lib/libgcc_s.so.1 (0x00007f0e6d442000)
libpthread.so.0 => /nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27/lib/libpthread.so.0 (0x00007f0e6d421000)
libc.so.6 => /nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27/lib/libc.so.6 (0x00007f0e6d269000)
/nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27/lib/ld-linux-x86-64.so.2 => /nix/store/pnd2kl27sag76h23wa5kl95a76n3k9i3-glibc-2.27/lib64/ld-linux-x86-64.so.2 (0x00007f0e6d98a000)

According to this page:

https://nixos.wiki/wiki/Packaging/Binaries

...this seems to be a design "feature" of NixOS. The page also talks about the preferred solution using patchelf.

Yeah, however truly static binaries (i.e.: Go) does work in NixOS. Something like joker:

$ ldd joker
    not a dynamic executable

I thought the idea of https://github.com/anmonteiro/lumo/issues/488 was to create a truly static binary, however I may be wrong.

penryu commented 4 years ago

Ah, I see. One workaround proposed in #488 is to build a statically linked binary, but it doesn't look like there's been a decision made about making the npm-provided Linux binary fully-statically linked.

If that is the solution chosen for lumo's dependence on glibc in #488, it should also resolve your issue... at the expense of a potentially much larger binary.

anmonteiro commented 4 years ago

Settings expectations here:

1) I don't really maintain this project anymore. I've expressed interest in onboarding people but there also doesn't seem to be much interest from other folks. 2) it's unlikely that I'll ever ship a statically linked binary for Lumo again -- we've done that before and it broke Node.js native addons that are compiled with different libc versions.

If you want a Nix derivation you can probably use https://github.com/NixOS/nixpkgs/pull/59414 which @hlolli was so kind to put together.

hlolli commented 4 years ago

Fully static library on linux with gcc only goes so far, I think musl is the best bet in that field so far, there’s a good talk on this from NixConf 2018. ld-linux and libc are in this case as for all binary cases pure by default on nixos, I guess youre already aware of that. As a nixos user, Id use lumo from nixpkgs and be satisfied to know that while you cant run lumo from npm, any consumer not using nixos will be able to run lumo as npm. I havent tried it, but it should be equally possible to patch the rpaths of a nixos binary for other linux environments, in case you intend to use a customized lumo build.

thiagokokada commented 4 years ago

It would be great if @hlolli PR could be merged, since the current version of Lumo in NixOS is quite old (and at least for me, broken, since it doesn't seem to find some dependencies).

hlolli commented 4 years ago

Yes, I'll try again to get it merged, the node packages need to be re-generated, takes around 20 mins, and there's a daily change to that file, quite annoying :)

hlolli commented 4 years ago

for what it's worth, it's now merged, but I believed it just missed the 20.03 release, but it should be on nixpkgs-unstable channel

PlumpMath commented 4 years ago

inflating: ./target/clojure/test/check/random.clj inflating: ./target/clojure/test/check/random/doubles.cljs inflating: ./target/clojure/test/check/random/longs/bit_count_impl.cljs inflating: ./target/clojure/test/check/random/longs.cljs inflating: ./target/clojure/test/check/random.cljs inflating: ./target/clojure/test/check/rose_tree.cljc creating: ./target/META-INF/maven/org.clojure/test.check/ inflating: ./target/META-INF/maven/org.clojure/test.check/pom.xml inflating: ./target/META-INF/maven/org.clojure/test.check/pom.properties java.io.FileInputStream

'user/write-transit-json

'user/process-caches

Building production bundle... Circular dependency: src/js/cljs.js -> src/js/repl.js -> src/js/cljs.js Circular dependency: src/js/cli.js -> src/js/cljs.js -> src/js/repl.js -> src/js/socketRepl.js -> src/js/cli.js Circular dependency: src/js/repl.js -> src/js/socketRepl.js -> src/js/repl.js Circular dependency: src/js/cljs.js -> src/js/repl.js -> src/js/socketRepl.js -> src/js/cljs.js internal/modules/cjs/loader.js:796 throw err; ^

Error: Cannot find module 'async' Require stack: