clj-commons / aleph

Asynchronous streaming communication for Clojure - web server, web client, and raw TCP/UDP
http://aleph.io
MIT License
2.54k stars 241 forks source link

aleph broken when using clojure from GUIX #736

Closed awb99 closed 2 months ago

awb99 commented 2 months ago

clojure ClassNotFoundException io.netty.channel.epoll.Epoll

On some of the machines I use, aleph cannot be used, because of some type of native dependency loading.

Reproduction:

(ns demo
  (:require
   [aleph.http :as http]))
(defn download-link [& _]
  (let [url "https://www.google.com"
        _ (println  "downloading link: " url)      
        request @(http/get url {:socket-timeout 90000
                                :connection-timeout 90000})]
    (println request)))

This error happens on some of my machines, and on some not.

I am getting crazy with this one, and havent found a solution.

I have verified that the class files needed are included: fastjar -t -f ~/.m2/repository/io/netty/netty-transport-classes-epoll/4.1.100.Final/netty-transport-classes-epoll-4.1.100.Final.jar >>

So my GUESS is, that on some machines, it detects the architecture incorrectly and loads the wrong namespace.

DerGuteMoritz commented 2 months ago

What's the architecture of the failing machines? Aleph only pulls in x86_64 and aarch_64 by default, so maybe yours is missing.

DerGuteMoritz commented 2 months ago

Then again, it doesn't seem like you're activating epoll so it should really not fail due to unavailability of the native library.

BTW it seems like you're a few versions behind (judging from the 4.1.100 .Final in your example). Maybe upgrading to 0.8.1 helps?

awb99 commented 2 months ago

Wow! I am surprised to get so many replys in such a short time! I always was sort of fearful to use aleph once it moved to clj-commons, fearing that it will be sort of abandoned. I have identitfied the issue now in this repo: https://github.com/awb99/clojure-guix-broken The issue is that GUIX operating system / package manager clojure is somehow broken, so that it would not load the binary classes of Epoch. I have submitted this issue in guix: https://issues.guix.gnu.org/73432

DerGuteMoritz commented 2 months ago

Wow! I am surprised to get so many replys in such a short time! I always was sort of fearful to use aleph once it moved to clj-commons, fearing that it will be sort of abandoned.

Aleph is still alive and somewhat kicking :smile: Happy to help!

I have identitfied the issue now in this repo: https://github.com/awb99/clojure-guix-broken The issue is that GUIX operating system / package manager clojure is somehow broken, so that it would not load the binary classes of Epoch. I have submitted this issue in guix: https://issues.guix.gnu.org/73432

Glad you figured out the root cause! I'll go ahead and close this issue here then as there's not much we can do about it. If it turns out we do need to change something on our end to make support Guix possible/easier, we can always re-open it. Cheers!

awb99 commented 2 months ago

Thanks @DerGuteMoritz There IS something that is still relevant: the topic is reproduceable builds. In the binary files from netty, there could be malware. So it still would be a good idea to have some kind of idea, how to build the content of the netty binary jars from scratch.

DerGuteMoritz commented 2 months ago

That should be answerable via the Netty docs hopefully, no? FWIW, we're using Nix with https://github.com/bevuta/clojure-nix-locker which generates a lockfile with checksums for every dependency, so at least you would notice when upstream tampers with a known version (TOFU). Building it yourself would of course be even nicer (but then again, see the recent XZ Utils debacle ...).