haruki7049 / lisp-webserver-with-nix

MIT License
0 stars 0 forks source link

Use openssl library for runtime dependent #1

Open haruki7049 opened 1 month ago

haruki7049 commented 1 month ago

How to reproduce

Commit: f244842eab995a794ac35e5fe27e399cb4f2fa21

# In /with-nix-flakes directory...
nix build
./result/bin/lisp-webserver

Error is:

Unhandled SIMPLE-ERROR in thread #<SB-THREAD:THREAD tid=61208 "main thread" RUNNING
                                    {10002D8143}>:
  Error opening shared object "libcrypto.so.3":
  libcrypto.so.3: cannot open shared object file: No such file or directory.

Backtrace for: #<SB-THREAD:THREAD tid=61208 "main thread" RUNNING {10002D8143}>
0: (SB-DEBUG::DEBUGGER-DISABLED-HOOK #<SIMPLE-ERROR "Error opening ~:[runtime~;shared object ~:*~S~]:
  ~A." {10002D90F3}> #<unused argument> :QUIT T)
1: (SB-DEBUG::RUN-HOOK *INVOKE-DEBUGGER-HOOK* #<SIMPLE-ERROR "Error opening ~:[runtime~;shared object ~:*~S~]:
  ~A." {10002D90F3}>)
2: (INVOKE-DEBUGGER #<SIMPLE-ERROR "Error opening ~:[runtime~;shared object ~:*~S~]:
  ~A." {10002D90F3}>)
3: (ERROR "Error opening ~:[runtime~;shared object ~:*~S~]:
  ~A." "libcrypto.so.3" "libcrypto.so.3: cannot open shared object file: No such file or directory")
4: (SB-SYS:DLOPEN-OR-LOSE #S(SB-ALIEN::SHARED-OBJECT :PATHNAME #P"libcrypto.so.3" :NAMESTRING "libcrypto.so.3" :HANDLE NIL :DONT-SAVE NIL))
5: (SB-ALIEN::TRY-REOPEN-SHARED-OBJECT #S(SB-ALIEN::SHARED-OBJECT :PATHNAME #P"libcrypto.so.3" :NAMESTRING "libcrypto.so.3" :HANDLE NIL :DONT-SAVE NIL))
6: (SB-SYS:REOPEN-SHARED-OBJECTS)
7: (SB-IMPL::FOREIGN-REINIT)
8: (SB-IMPL::REINIT T)
9: ((FLET SB-UNIX::BODY :IN SB-IMPL::START-LISP))
10: ((FLET "WITHOUT-INTERRUPTS-BODY-3" :IN SB-IMPL::START-LISP))
11: (SB-IMPL::%START-LISP)

unhandled condition in --disable-debugger mode, quitting

nix-shell -p nix-info --run "nix-info -m" 's result

 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.27, NixOS, 24.05 (Uakari), 24.05.20240414.f32598c`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.2`
 - nixpkgs: `/nix/store/83pgzk2zgc2iji8d65479wijairr0vgy-source`
haruki7049 commented 1 month ago

@hraban I'm sorry to mention this, but could you help me out a little? In case you are wondering, I have limited knowledge of CommonLisp and English, so it would be helpful if you could take that into account when you talk to me.

hraban commented 1 month ago

I couldn't reproduce this bug. However sometimes a bug can be hidden on Mac while it shows up on NixOS. This is because Mac has more global libraries available, especially for stuff like crypto.

However I did run into a different problem which I solved like this:

diff --git i/with-nix-flakes/flake.nix w/with-nix-flakes/flake.nix
index 7c40da9..f8b3e08 100644
--- i/with-nix-flakes/flake.nix
+++ w/with-nix-flakes/flake.nix
@@ -19,6 +19,7 @@
         src = pkgs.lib.cleanSource ./.;
         lispDependencies = with pkgs.lispPackagesLite; [
           clack
+          clack-handler-hunchentoot
           hunchentoot
         ];
         meta = with lib; {
diff --git i/with-nix-flakes/lisp-webserver.asd w/with-nix-flakes/lisp-webserver.asd
index 2f1b2d9..1627962 100644
--- i/with-nix-flakes/lisp-webserver.asd
+++ w/with-nix-flakes/lisp-webserver.asd
@@ -7,4 +7,4 @@
   :build-pathname "bin/lisp-webserver"
   :entry-point "lisp-webserver:main"
   :components ((:file "main"))
-  :depends-on ("clack" "hunchentoot"))
+  :depends-on ("clack" "hunchentoot" "clack-handler-hunchentoot"))

(source: https://stackoverflow.com/questions/54203075/hunchentoot-is-unknown-handler )

Now I can run your app:

$ nix run 
Hunchentoot server is started.
Listening on 127.0.0.1:8080.
$

It immediately exits because clack doesn't keep the app alive, so if nothing else keeps the app alive it quits. But that's not a problem with Nix, that's just how Clack works.

I can try on a NixOS virtual machine later but for now I don't see anything immediately wrong with this app.