R
Railwayโ€ข3y ago
pauldps

Crystal+Lucky+Nixpacks failing to build with openssl errors

Hi, I'm trying to deploy a simple Crystal app using the Lucky lib (which uses SSL) and the deploy is failing to build. I've confirmed that the default Nixpack for Crystal already includes openssl and pkg-config, but the deploy is failing with the following:
#13 1.084 Error target app failed to compile:
#13 1.084 <stdin>:1:10: fatal error: 'openssl/opensslv.h' file not found
#13 1.084 #include <openssl/opensslv.h>
#13 1.084 ^~~~~~~~~~~~~~~~~~~~
#13 1.084 1 error generated.
#13 1.084 Showing last frame. Use --error-trace for full trace.
#13 1.084
#13 1.084 In /nix/store/wp989av138zf83mhna2p3fd0bqgqya6v-crystal-1.2.2-lib/crystal/openssl/lib_crypto.cr:5:25
#13 1.084
#13 1.084 5 | (`printf "#include <openssl/opensslv.h>\nLIBRESSL_VERSION_NUMBER" | ${CC:-cc} $(pkg-config --cflags --silence-errors libcrypto || true) -E -`.chomp.split('\n').last != "LIBRESSL_VERSION_NUMBER") %}
#13 1.084 ^
#13 1.084 Error: error executing command: printf "#include <openssl/opensslv.h>
#13 1.084
#13 1.084 LIBRESSL_VERSION_NUMBER" | ${CC:-cc} $(pkg-config --cflags --silence-errors libcrypto || true) -E -, got exit status 1:
#13 1.084 Error target app failed to compile:
#13 1.084 <stdin>:1:10: fatal error: 'openssl/opensslv.h' file not found
#13 1.084 #include <openssl/opensslv.h>
#13 1.084 ^~~~~~~~~~~~~~~~~~~~
#13 1.084 1 error generated.
#13 1.084 Showing last frame. Use --error-trace for full trace.
#13 1.084
#13 1.084 In /nix/store/wp989av138zf83mhna2p3fd0bqgqya6v-crystal-1.2.2-lib/crystal/openssl/lib_crypto.cr:5:25
#13 1.084
#13 1.084 5 | (`printf "#include <openssl/opensslv.h>\nLIBRESSL_VERSION_NUMBER" | ${CC:-cc} $(pkg-config --cflags --silence-errors libcrypto || true) -E -`.chomp.split('\n').last != "LIBRESSL_VERSION_NUMBER") %}
#13 1.084 ^
#13 1.084 Error: error executing command: printf "#include <openssl/opensslv.h>
#13 1.084
#13 1.084 LIBRESSL_VERSION_NUMBER" | ${CC:-cc} $(pkg-config --cflags --silence-errors libcrypto || true) -E -, got exit status 1:
My project has a nixpacks.toml file that includes the requirements for Lucky (relevant one is libssl-dev):
[phases.setup]
aptPkgs = ['...', 'libc6-dev', 'libevent-dev', 'libpcre2-dev', 'libpng-dev', 'libssl-dev', 'libyaml-dev', 'zlib1g-dev']
[phases.setup]
aptPkgs = ['...', 'libc6-dev', 'libevent-dev', 'libpcre2-dev', 'libpng-dev', 'libssl-dev', 'libyaml-dev', 'zlib1g-dev']
I've ran out of options. The project runs fine locally. Any advice?
30 Replies
JustJake
JustJakeโ€ข3y ago
Can you try installing these things via nix instead of apt? openssl in particular requires some weird LD_PRELOAD/lib type stuff
pauldps
pauldpsOPโ€ข3y ago
I don't know which names each package translates to, although I see an openssl package in nixos.org. But I thought Nixpacks already handled openssl that way?
JustJake
JustJakeโ€ข3y ago
I don't follow. How would it unless you tell it what packages to get from where? Like ideally the provider for crystal should handle this
pauldps
pauldpsOPโ€ข3y ago
I tried to add openssl and pkg-config to the apt config, and the logs said they were already installed
JustJake
JustJakeโ€ข3y ago
But, that's why we let people do these overrides, then we go take the overrides and insert them into the provider Yea. Openssl is super annoying here. Needs to be installed via Nix Can you remove the openssl from apt and put it into nixPkgs?
pauldps
pauldpsOPโ€ข3y ago
I'll try that
JustJake
JustJakeโ€ข3y ago
I suspect it'll change your error, and you'll need to move a couple more from apt into either nixLibs or nixPkgs if THAT doesn't work, please try nixLibs
pauldps
pauldpsOPโ€ข3y ago
are Nix librs using the same names as apt?
JustJake
JustJakeโ€ข3y ago
No, nixPkgs (Nixpacks is still v0 and we're working on a lot of this) For niche languages, this ends up being more of a struggle
pauldps
pauldpsOPโ€ข3y ago
b/c nixPkgs point to nixos.org (it's the first time I've heard of it), and libssl-dev isn't available there so I'm removing libssl-dev from aptPkgs, and adding openssl to nixPkgs to test just wanted to clear that up lol
JustJake
JustJakeโ€ข3y ago
Worth clearing up it's definitely not as clear as we'd want it to be! You can leave libssl-dev in aptPkgs Just, start with openssl in nixpkgs cause that's your error right? Then we can move onto the next one
pauldps
pauldpsOPโ€ข3y ago
gotcha NG, same error ๐Ÿ˜ฆ nixpacks.toml:
[phases.setup]

nixPkgs = ['...', 'openssl']

aptPkgs = ['...', 'libc6-dev', 'libevent-dev', 'libpcre2-dev', 'libpng-dev', 'libssl-dev', 'libyaml-dev', 'zlib1g-dev']
[phases.setup]

nixPkgs = ['...', 'openssl']

aptPkgs = ['...', 'libc6-dev', 'libevent-dev', 'libpcre2-dev', 'libpng-dev', 'libssl-dev', 'libyaml-dev', 'zlib1g-dev']
JustJake
JustJakeโ€ข3y ago
Okay move it to nixLibs
pauldps
pauldpsOPโ€ข3y ago
Same error after moving to nixLibs openssl disappeared from the header:
โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• Nixpacks v0.5.6 โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘ setup โ”‚ crystal, shards, libc6-dev, libevent-dev, libpcre2-dev, libpng- โ•‘
โ•‘ โ”‚ dev, libssl-dev, libyaml-dev, zlib1g-dev โ•‘
โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• Nixpacks v0.5.6 โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘ setup โ”‚ crystal, shards, libc6-dev, libevent-dev, libpcre2-dev, libpng- โ•‘
โ•‘ โ”‚ dev, libssl-dev, libyaml-dev, zlib1g-dev โ•‘
JustJake
JustJakeโ€ข3y ago
Can you paste the full logs?
pauldps
pauldpsOPโ€ข3y ago
full as in all the 733 lines?
pauldps
pauldpsOPโ€ข3y ago
pauldps
pauldpsOPโ€ข3y ago
hm the log got cut off for some reason, let me reupload I can't copy the entire log I think the log window is using a virtual scroller and doesn't keep text selected when I scroll past it
JustJake
JustJakeโ€ข3y ago
Uhh You sure it's openssl? And not libressl? Like it looks like it's misisng LIBRESSL_VERSION_NUMBER https://search.nixos.org/packages?channel=22.05&show=libressl&from=0&size=50&sort=relevance&type=packages&query=libressl
pauldps
pauldpsOPโ€ข3y ago
๐Ÿ‘€ there's indeed a libressl in nixos, gonna try it in nixPkgs alongside openssl just to be safe
JustJake
JustJakeโ€ข3y ago
GitHub
OpenSSL Compilation Error ยท Issue #9773 ยท crystal-lang/crystal
I just started getting this error today. I believe it&#39;s from a OpenSSL system upgrade I made. I&#39;m running on Arch Linux, using asdf and Crystal 0.35.1 cc: internal compiler error: S...
JustJake
JustJakeโ€ข3y ago
You may need some environment variables there, which may only be accessible/set-able via the providers since they'll know where they're located
pauldps
pauldpsOPโ€ข3y ago
what exactly do you mean "only accessible/set-able via providers"? can't I set those variables in the project via the dashboard?
milo
miloโ€ข3y ago
This is a crystal bug btw Oh shit, sorry didnโ€™t see issue link
pauldps
pauldpsOPโ€ข3y ago
following that github issue, I added a:
cmds = ['pkg-config --cflags --libs libcrypto']
cmds = ['pkg-config --cflags --libs libcrypto']
to my nixpacks.toml file just to see the output in the build logs, and it just returns -lcrypto, without a path according to the logs, the command ran after dependencies were installed so I'm scratching my head here ๐Ÿ˜ฆ this is somewhat out of my knowledge area
JustJake
JustJakeโ€ข3y ago
Ya you'll probably need to create an issue on the repo with a repo to reproduce it + information (ideally link to this thread)
pauldps
pauldpsOPโ€ข3y ago
I'll try to get a replicable repo with the jumpstart version of Lucky. which repo should I open the issue on? railwayapp/nixpacks?
milo
miloโ€ข3y ago
Yeah, that repo please
pauldps
pauldpsOPโ€ข3y ago
in better news, I found a workaround deploying the app using a Dockerfile instead of Nixpacks the Nixpacks way seemed easier tho (if it worked lol)
Want results from more Discord servers?
Add your server