Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Fails on Arch Linux, Crystal 0.35.1 #22

Closed
sempervictus opened this issue Dec 18, 2020 · 2 comments
Closed

Build Fails on Arch Linux, Crystal 0.35.1 #22

sempervictus opened this issue Dec 18, 2020 · 2 comments

Comments

@sempervictus
Copy link

Build is failing with

$ shards install
Resolving dependencies
Fetching https://github.com/PercussiveElbow/docker-crystal.git
Fetching https://github.com/PercussiveElbow/net_sample.cr.git
Installing docker (0.0.2 at 4fa2f79)
Installing net_sample (0.2.5 at d1af25f)

$ crystal build --static src/docker-escape.cr --error-trace
In src/docker-escape.cr:89:1

 89 | main()
      ^---
Error: instantiating 'main()'


In src/docker-escape.cr:14:9

 14 | auto()
      ^---
Error: instantiating 'auto()'


In src/docker-escape.cr:47:3

 47 | attempt_unix_socket_breakout()
      ^---------------------------
Error: instantiating 'attempt_unix_socket_breakout()'


In src/docker-escape.cr:67:5

 67 | socket_breakout("/var/run/docker.sock")
      ^--------------
Error: instantiating 'socket_breakout(String)'


In src/breakouts/socket/socket_breakout.cr:8:18

 8 | client = setup_docker_client(socket,port)
              ^------------------
Error: instantiating 'setup_docker_client(String, Int32)'


In src/breakouts/socket/socket_breakout.cr:26:33

 26 | client = Docker::Client.new(socket,port,false)
                              ^--
Error: instantiating 'Docker::Client.class#new(String, Int32, Bool)'


In lib/docker/src/docker.cr:26:40

 26 | @client = HTTP::Client.new(sock) 
                             ^--
Error: no overload matches 'HTTP::Client.new' with type UNIXSocket

Overloads are:
 - HTTP::Client.new(host : String, port = nil, tls : TLSContext = nil)
 - HTTP::Client.new(uri : URI, tls : TLSContext = nil)
 - HTTP::Client.new(uri : URI, tls : TLSContext = nil, &block)
 - HTTP::Client.new(host : String, port = nil, tls : TLSContext = nil, &block)
@PercussiveElbow
Copy link
Owner

PercussiveElbow commented Dec 20, 2020

This is expected for the moment. Essentially with the way the HTTP component of Crystal 0.35.1 works there's no easy way to use normal HTTP::Client calls with Unix sockets. This meant having to handle Docker API calls to TCP and Unix sockets individually within the codebase which was a bit of a pain for maintaining and made things a bit less portable.

In the past few weeks the Crystal core team appear to have reworked the HTTP library to include the needed functionality, but this has not yet made it's way to a formal stable Crystal release and so only is available in nightly builds. Therefore if you'd like to compile you need to use a alpine-nightly container like so (crystallang/crystal:nightly-alpine-build). For further info on the underlying Crystal changes please see here: crystal-lang/crystal#2735

The Dockerfile within the repo should help as an example: https://github.com/PercussiveElbow/docker-escape-tool/blob/master/Dockerfile

Thanks for raising this though I've now added a note to the readme because this is indeed likely to cause confusion.

tldr: solution
Compile with Crystal nightly until a new stable Crystal release hits soon-ish.

@PercussiveElbow
Copy link
Owner

Closing as the release of Crystal 1.0 a few months ago fixed the need to compile with nightly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants