nixpacks icon indicating copy to clipboard operation
nixpacks copied to clipboard

Crystal HTTP server build failed (throws clang linker command failed)

Open 636f7374 opened this issue 1 year ago • 4 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Describe the bug

Describe

Crystal HTTP server build failed (throws clang linker command failed).

  • Build Logs
ubuntu@standard:~/standard$ railway up
☁️ Build logs available at https://railway.app/project/[...]/service/[...]?id=[...]&

==============
Using Nixpacks
==============


╔═══════ Nixpacks v0.3.7 ══════╗
║ Setup      │ crystal, shards ║
║──────────────────────────────║
║ Install    │ shards install  ║
║──────────────────────────────║
║ Build      │ shards build    ║
║──────────────────────────────║
║ Start      │ ./bin/crystal   ║
╚══════════════════════════════╝


#2 [internal] load .dockerignore
#2 sha256:bffaf1487f8ba39624bc9d3c006ffe233ab966e423fcdf9913f8b3b53647d546
#2 transferring context: 2B done

#2 DONE 0.2s

#1 [internal] load build definition from Dockerfile
#1 sha256:ddf8a8189ffe3d2f87d92d9cafcb05ec20ccbeac5987582ba878abefbe056ccf
#1 transferring dockerfile: 785B done
#1 DONE 0.2s

#3 [internal] load metadata for ghcr.io/railwayapp/nixpacks:debian-1660071566

#3 sha256:919667f23d6b359b99a15a599e8292aa9753487c1a876842a74b1e63bbc2dd23

#3 DONE 0.2s


#4 [1/9] FROM ghcr.io/railwayapp/nixpacks:debian-1660071566@sha256:aa5a574d94cd1c72b367921d0dd6b586b89490f81ada2e6cfba352bf300b1026
#4 sha256:39d22ddebbb5eaa0eb81412c3f116a951ecc6d6bd8e45ed70e563183e6608f18
#4 DONE 0.0s

#5 [2/9] WORKDIR /app/
#5 sha256:9f8882d19156ca9db7e2ca9a68d9040222fa9979b0458980d489f4c6e0dad02c
#5 CACHED

#6 [internal] load build context
#6 sha256:ed3fb80fb672d6b0fbb4e86de9a2155611ca1de29d31b3ff2d49ead2e79dba3d

#6 transferring context: 1.89kB done
#6 DONE 0.1s

#7 [3/8] COPY .nixpacks/setup.nix .nixpacks/setup.nix
#7 sha256:871e9ef5b90bf29c27a13de54bd963da7e6cf32d7779e17b3b418cd91a4498f0
#7 CACHED

#8 [4/8] RUN nix-env -if .nixpacks/setup.nix
#8 sha256:d3aa79528d7483f3edf10f49cead12bad8fa5f64e0732831c5eafa4ba29089f3
#8 CACHED

#9 [5/8] COPY . /app/
#9 sha256:4834dd492528fe7f1ab92f7c67c0ce6f9bf4c120ec23cec19ba02855a52bd5a8

#9 DONE 0.2s

#10 [6/8] RUN  shards install
#10 sha256:28edbed0f0525b02d860b3d3c93da20e04fc530759306fcaea0c8196d58d1cd4

#10 0.454 Resolving dependencies
#10 0.454 Writing shard.lock

#10 DONE 0.8s

#11 [7/8] COPY . /app/
#11 sha256:ff3f95632eb2ab08ae70b7ba84dad144a5274c8194e55a3426ea44123897f80a

#11 DONE 0.2s

#12 [8/8] RUN  shards build
#12 sha256:b487b01c6a011e2c581561e17fdaa13d5dbb2e25d22b0c3946a178e4c2e7588e

#12 0.424 Dependencies are satisfied
#12 0.424 Building: crystal

#12 13.49 Error target crystal failed to compile:
#12 13.49 /nix/store/dpxy5cr7cm0nch0qvq2qygs9jwnmhiy5-binutils-2.38/bin/ld: _main.o: in function `__crystal_main':
#12 13.49 /nix/store/4fdpipkga724q7hvryjgw4chvrz4r1lq-crystal-1.2.2-lib/crystal/openssl/lib_ssl.cr:261: undefined reference to `SSL_library_init'
#12 13.49 /nix/store/dpxy5cr7cm0nch0qvq2qygs9jwnmhiy5-binutils-2.38/bin/ld: /nix/store/4fdpipkga724q7hvryjgw4chvrz4r1lq-crystal-1.2.2-lib/crystal/openssl/lib_ssl.cr:261: undefined reference to `SSL_load_error_strings'
#12 13.49 /nix/store/dpxy5cr7cm0nch0qvq2qygs9jwnmhiy5-binutils-2.38/bin/ld: /nix/store/4fdpipkga724q7hvryjgw4chvrz4r1lq-crystal-1.2.2-lib/crystal/openssl/lib_ssl.cr:261: undefined reference to `OPENSSL_add_all_algorithms_noconf'
#12 13.49 /nix/store/dpxy5cr7cm0nch0qvq2qygs9jwnmhiy5-binutils-2.38/bin/ld: /nix/store/4fdpipkga724q7hvryjgw4chvrz4r1lq-crystal-1.2.2-lib/crystal/openssl/lib_ssl.cr:261: undefined reference to `ERR_load_crypto_strings'
#12 13.49 clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
#12 13.49 Error: execution of command failed with code: 1: `cc "${@}" -o /app/bin/crystal  -rdynamic -L/nix/store/2v8ma5xj9gnz49mpykl9lii28k24xljp-boehm-gc-8.0.6/lib -L/nix/store/n6qch9r475cjl1calzp5f6ymm4wzjv3n-libatomic_ops-7.6.12/lib -L/nix/store/5gi7gvp7bi8667vh5azd8r0vhj3dqxx5-pcre-8.45/lib -L/nix/store/vw8vyp26lcv8qaijz77jigq37whvwpjv-libevent-2.1.12/lib -L/nix/store/q72x2zjfhmzyhlcax2nigymly023pm98-libyaml-0.2.5/lib -L/nix/store/z18zgvspmxi88ipmk3f3nicvasfq3199-zlib-1.2.12/lib -L/nix/store/rqg79h5w8lzrw1a774z2fdkyakyjnr8n-libxml2-2.9.14/lib -L/nix/store/sxgs416j8z3x9mj97939syyp8cv6064b-openssl-1.1.1q/lib -lz `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libssl || printf %s '-lssl -lcrypto'` `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libcrypto || printf %s '-lcrypto'` -lpcre -lm -lgc -lpthread -levent -lrt -ldl`
#12 13.49

#12 ERROR: executor failed running [/bin/bash -ol pipefail -c shards build]: exit code: 1
-----
> [8/8] RUN  shards build:
-----
executor failed running [/bin/bash -ol pipefail -c shards build]: exit code: 1

Error: Docker build failed



======= Build Completed ======

Deployment failed. Check build logs for error
🚨 Build Failed! Please see output for more information

To reproduce

  • src/crystal.cr
require "http/server"

server = HTTP::Server.new do |context|
  context.response.content_type = "text/plain"
  context.response.print "Hello world!"
end

address = server.bind_tcp 8080
puts "Listening on http://#{address}"
server.listen
  • shard.yml
name: crystal
version: 0.1.0

authors:
  - none <[email protected]>

targets:
  crystal:
    main: src/crystal.cr

crystal: 1.5.0

license: MIT

Expected behavior

It should work fine, but apparently doesn't, seems to be related to OpenSSL?

Environment

$ uname -a

Linux standard 5.15.0-1014-azure #17~20.04.1-Ubuntu SMP Thu Jun 23 20:01:51 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

636f7374 avatar Aug 26 '22 08:08 636f7374

I was able to build using the current version of nixpacks using the config you posted here

Could you potentially include a repo example to test with?

JakeCooper avatar Aug 27 '22 05:08 JakeCooper

Reply

@JakeCooper The problem still exists.

I was able to build using the current version of nixpacks using the config you posted here Could you potentially include a repo example to test with?

https://github.com/636f7374/railway-bugs

Commands

cd ~/ && git clone https://github.com/636f7374/railway-bugs.git bugs && cd bugs && shards install && shards build --release

railway init

railway up

Verbose

> ubuntu@standard:~$ cd ~/ && git clone https://github.com/636f7374/railway-bugs.git bugs && cd bugs && shards install && shards build --release && railway init
Cloning into 'bugs'...
remote: Enumerating objects: 13, done.
remote: Counting objects: 100% (13/13), done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 13 (delta 1), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (13/13), 3.87 KiB | 1.29 MiB/s, done.
Resolving dependencies
Writing shard.lock
Dependencies are satisfied
Building: crystal
Use the arrow keys to navigate: ↓ ↑ → ←  and / toggles search
? Select Starting Point: 
  ▸ Empty Project
    Starter Template



✔ Starting Point: Empty Project 
✔ Enter project name: bugs█

Do you want to exit w3m? (y/n) y


✔ Environment: production
🎉 Created project bugs


> ubuntu@standard:~/bugs$ railway up
🚅 Laying tracks in the clouds... 
☁️ Build logs available at https://railway.app/project/[...]/service/[...]?id=[...]&

#1 [internal] load build definition from Dockerfile
#1 sha256:320d5345c141e32f7009003e82649c8e7ea18c47c369097a78e691ee30b50ad7
#1 transferring dockerfile: 785B done

#1 DONE 0.2s

#2 [internal] load .dockerignore
#2 sha256:a6c8e81c84051acc3faa5b894e589191ebe0c7c8c9c259b4c6493f303dd7c95a
#2 transferring context: 2B done

#2 DONE 0.3s

#3 [internal] load metadata for ghcr.io/railwayapp/nixpacks:debian-1660071566
#3 sha256:919667f23d6b359b99a15a599e8292aa9753487c1a876842a74b1e63bbc2dd23

#3 DONE 0.3s

#4 [1/9] FROM ghcr.io/railwayapp/nixpacks:debian-1660071566@sha256:aa5a574d94cd1c72b367921d0dd6b586b89490f81ada2e6cfba352bf300b1026
#4 sha256:39d22ddebbb5eaa0eb81412c3f116a951ecc6d6bd8e45ed70e563183e6608f18
#4 DONE 0.0s

#5 [2/9] WORKDIR /app/
#5 sha256:9f8882d19156ca9db7e2ca9a68d9040222fa9979b0458980d489f4c6e0dad02c
#5 CACHED

#6 [internal] load build context
#6 sha256:d822afb749694fe187f67f580281d943ac78bad0aec99577bcc5b0fcd5ccd3d1

==============
Using Nixpacks
==============


╔═══════ Nixpacks v0.3.7 ══════╗
║ Setup      │ crystal, shards ║
║──────────────────────────────║
║ Install    │ shards install  ║
║──────────────────────────────║
║ Build      │ shards build    ║
║──────────────────────────────║
║ Start      │ ./bin/crystal   ║
╚══════════════════════════════╝


#6 transferring context: 2.47MB 0.0s done
#6 DONE 0.1s

#7 [3/8] COPY .nixpacks/setup.nix .nixpacks/setup.nix
#7 sha256:1fdc21d003dc2bda4e27101b1f149f55ab66be086e1c3e58028a104d449c1f6b
#7 CACHED

#8 [4/8] RUN nix-env -if .nixpacks/setup.nix
#8 sha256:5d6aa65c06b30c4a27d672f21083cf44c8051c2c8385bb46ba90812ac727ee75
#8 CACHED

#9 [5/8] COPY . /app/
#9 sha256:0611896f7cc2bef348709a500037ac98176288966070e14725b0ab5beba01db2

#9 DONE 0.1s

#10 [6/8] RUN  shards install
#10 sha256:e9a513356b8dea5f21127e2499b171f8f374adcf9299ce6190c029c2c536d456

#10 0.464 Resolving dependencies

#10 DONE 0.6s


#11 [7/8] COPY . /app/
#11 sha256:bc67579c904034d19768b0ec17e8ca03409ca4d7a5bf96c10912665911098100



======= Build Completed ======

Deployment failed. Check build logs for error
🚨 Build Failed! Please see output for more information






> ubuntu@standard:~/bugs$ ls
LICENSE  bin  lib  shard.lock  shard.yml  src




> ubuntu@standard:~/bugs$ railway up
☁️ Build logs available at https://railway.app/project/[...]/service/[...]&

==============
Using Nixpacks
==============


╔═══════ Nixpacks v0.3.7 ══════╗
║ Setup      │ crystal, shards ║
║──────────────────────────────║
║ Install    │ shards install  ║
║──────────────────────────────║
║ Build      │ shards build    ║
║──────────────────────────────║
║ Start      │ ./bin/crystal   ║
╚══════════════════════════════╝


#1 [internal] load build definition from Dockerfile
#1 sha256:217ced199f77df8fd13ceddd17a2b635858647024501d2efd8c8e3eb740efc3f
#1 transferring dockerfile: 785B done

#1 DONE 0.2s

#2 [internal] load .dockerignore
#2 sha256:ef96c8b1cd098e7dc88a17496129d5dc22a9737a40c20dfb5897de7db9b7a17b
#2 transferring context:

#2 transferring context: 2B done

#2 DONE 0.4s


#3 [internal] load metadata for ghcr.io/railwayapp/nixpacks:debian-1660071566
#3 sha256:919667f23d6b359b99a15a599e8292aa9753487c1a876842a74b1e63bbc2dd23

#3 DONE 0.2s

#4 [1/9] FROM ghcr.io/railwayapp/nixpacks:debian-1660071566@sha256:aa5a574d94cd1c72b367921d0dd6b586b89490f81ada2e6cfba352bf300b1026
#4 sha256:39d22ddebbb5eaa0eb81412c3f116a951ecc6d6bd8e45ed70e563183e6608f18
#4 DONE 0.0s

#5 [2/9] WORKDIR /app/
#5 sha256:9f8882d19156ca9db7e2ca9a68d9040222fa9979b0458980d489f4c6e0dad02c
#5 CACHED


#6 [internal] load build context
#6 sha256:c241b2e38d963679847eb81b4e76ec8111855969862a85edd65798883ca4f6fd

#6 transferring context: 2.47MB 0.0s done

#6 DONE 0.3s


#7 [3/8] COPY .nixpacks/setup.nix .nixpacks/setup.nix
#7 sha256:5d1b41430801f789a693c835fdd048fa3f8825bc5b330122576537f49f0439e1

#7 CACHED

#8 [4/8] RUN nix-env -if .nixpacks/setup.nix
#8 sha256:6ac6de661d38e452b8f97037e0514892b07e6b5959b9b3ec40872363c31e5d1d
#8 CACHED

#9 [5/8] COPY . /app/
#9 sha256:2c29f7020c1ebd3ea3e8209067ca1e494f0f53dec6e992ba6fa4be5de33f4e25
#9 CACHED

#10 [6/8] RUN  shards install
#10 sha256:964561db2ae787c48e843dba5a744d9e56d0250faf37c90621cec303443691e9

#10 0.660 Resolving dependencies


#10 DONE 0.9s


#11 [7/8] COPY . /app/
#11 sha256:e0e3091a1083a2a91b40b4399e6cae0c34a6476a6c1925bf7de764a90f956b5c

#11 DONE 0.2s

#12 [8/8] RUN  shards build
#12 sha256:fdcce45b49cdd29e0aa9a3d6f5e609e72dadba2df63372beba8fe9c286c16e9c

#12 0.462 Dependencies are satisfied
#12 0.462 Building: crystal

#12 14.26 Error target crystal failed to compile:
#12 14.26 /nix/store/dpxy5cr7cm0nch0qvq2qygs9jwnmhiy5-binutils-2.38/bin/ld: _main.o: in function `__crystal_main':
#12 14.26 /nix/store/4fdpipkga724q7hvryjgw4chvrz4r1lq-crystal-1.2.2-lib/crystal/openssl/lib_ssl.cr:261: undefined reference to `SSL_library_init'
#12 14.26 /nix/store/dpxy5cr7cm0nch0qvq2qygs9jwnmhiy5-binutils-2.38/bin/ld: /nix/store/4fdpipkga724q7hvryjgw4chvrz4r1lq-crystal-1.2.2-lib/crystal/openssl/lib_ssl.cr:261: undefined reference to `SSL_load_error_strings'
#12 14.26 /nix/store/dpxy5cr7cm0nch0qvq2qygs9jwnmhiy5-binutils-2.38/bin/ld: /nix/store/4fdpipkga724q7hvryjgw4chvrz4r1lq-crystal-1.2.2-lib/crystal/openssl/lib_ssl.cr:261: undefined reference to `OPENSSL_add_all_algorithms_noconf'
#12 14.26 /nix/store/dpxy5cr7cm0nch0qvq2qygs9jwnmhiy5-binutils-2.38/bin/ld: /nix/store/4fdpipkga724q7hvryjgw4chvrz4r1lq-crystal-1.2.2-lib/crystal/openssl/lib_ssl.cr:261: undefined reference to `ERR_load_crypto_strings'
#12 14.26 clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
#12 14.26 Error: execution of command failed with code: 1: `cc "${@}" -o /app/bin/crystal  -rdynamic -L/nix/store/2v8ma5xj9gnz49mpykl9lii28k24xljp-boehm-gc-8.0.6/lib -L/nix/store/n6qch9r475cjl1calzp5f6ymm4wzjv3n-libatomic_ops-7.6.12/lib -L/nix/store/5gi7gvp7bi8667vh5azd8r0vhj3dqxx5-pcre-8.45/lib -L/nix/store/vw8vyp26lcv8qaijz77jigq37whvwpjv-libevent-2.1.12/lib -L/nix/store/q72x2zjfhmzyhlcax2nigymly023pm98-libyaml-0.2.5/lib -L/nix/store/z18zgvspmxi88ipmk3f3nicvasfq3199-zlib-1.2.12/lib -L/nix/store/rqg79h5w8lzrw1a774z2fdkyakyjnr8n-libxml2-2.9.14/lib -L/nix/store/sxgs416j8z3x9mj97939syyp8cv6064b-openssl-1.1.1q/lib -lz `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libssl || printf %s '-lssl -lcrypto'` `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libcrypto || printf %s '-lcrypto'` -lpcre -lm -lgc -lpthread -levent -lrt -ldl`
#12 14.26
#12 ERROR: executor failed running [/bin/bash -ol pipefail -c shards build]: exit code: 1

-----
> [8/8] RUN  shards build:
-----

executor failed running [/bin/bash -ol pipefail -c shards build]: exit code: 1

Error: Docker build failed



======= Build Completed ======

Deployment failed. Check build logs for error
🚨 Build Failed! Please see output for more information


> ubuntu@standard:~/bugs$ uname -a
Linux standard 5.15.0-1014-azure #17~20.04.1-Ubuntu SMP Thu Jun 23 20:01:51 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux


> ubuntu@standard:~/bugs$ railway whoami
👋 Hey [...]@[...].com


> ubuntu@standard:~/bugs$ cat src/crystal.cr
require "http/server"

server = HTTP::Server.new do |context|
  context.response.content_type = "text/plain"
  context.response.print "Hello world!"
end

address = server.bind_tcp 8080
puts "Listening on http://#{address}"
server.listen


> ubuntu@standard:~/bugs$ cat shard.yml
name: crystal
version: 0.1.0

authors:
  - none <[email protected]>

targets:
  crystal:
    main: src/crystal.cr

crystal: 1.5.0

license: MIT

636f7374 avatar Aug 27 '22 17:08 636f7374

Finally

No one helped? Or? This problem still exists and can't be solved, if someone encounters the same problem in the future can try to use Docker or other PaaS.

Since this issue has not received a reply, this issue will be closed automatically after one day now.

Github repository (example to test)

https://github.com/636f7374/railway-bugs

Commands

cd ~/ && git clone https://github.com/636f7374/railway-bugs.git bugs && cd bugs && shards install && shards build --release

railway init

railway up

636f7374 avatar Aug 29 '22 12:08 636f7374

No one helped?

We haven't had a chance to look into this yet. Please have some patience.

Milo123459 avatar Aug 29 '22 12:08 Milo123459