rust-lang / docker-rust

The official Docker images for Rust
438 stars 88 forks source link

official docker image linking error #113

Closed happy-machine closed 2 years ago

happy-machine commented 2 years ago

My very simple cli program wont compile in the official rust image but will compile on mac. The official image shouldn't need tinkering to build.

to reproduce

build docker image from latest official image:

FROM rust:1.63
RUN apt-get update -y && apt-get install -y vim tmux htop nano gcc-multilib libgpgme-dev unixodbc unixodbc-dev
WORKDIR /
CMD ["sleep", "86400"]

cargo new test

use this cargo.toml:

[package]
name = "test"
version = "0.1.0"
edition = "2021"
author = "NA"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
crossterm = { version = "0.19", features = [ "serde" ] }
serde = {version = "1.0", features = ["derive"] }
serde_json = "1.0"
chrono = { version = "0.4", features = ["serde"] }
rand = { version = "0.7.3", default-features = false, features = ["std"] }
tui = { version = "0.14", default-features = false, features = ['crossterm', 'serde'] }
thiserror = "1.0"
clipboard = "0.5.0"
itertools = "0.10.3"

cargo build --release or cargo run

result:

error: linking withccfailed: exit status: 1

note: /usr/bin/ld: cannot find -lxcb-shape
          /usr/bin/ld: cannot find -lxcb-xfixes

Note: have tried also installing gcc-multilib libgpgme-dev unixodbc unixodbc-dev to no effect and running RUSTFLAGS='-L /db2-query/clidriver/lib' cargo build --release

to no effect.

quorth0n commented 2 years ago

The error message is telling you to install the lxcb-shape library. apt install libxcb-shape0-dev

happy-machine commented 2 years ago

Thanks for your help. I don't mean this to sound critical i appreciate that you guys are doing amazing things with no doubt limited resources.

I installed that (which didnt fix the build but led me to my next missing dependency) and then after some further searching around discovered i also needed libxcb-composite0-dev as you have made clear it is not transparent what is missing.

My issue is more to do with the behaviour of cargo as a dependency management tool. I would expect as is the case with NPM or PYPY that cargo would manage the installation of sub-dependencies? and that i shouldn't need to install these things on top of the official docker image?

sfackler commented 2 years ago

My issue is more to do with the behaviour of cargo as a dependency management tool.

That would probably be better directed to https://github.com/rust-lang/cargo.

and that i shouldn't need to install these things on top of the official docker image?

Are you requesting that the official docker image install every -dev package in existence?

happy-machine commented 2 years ago

This program which builds fine on mac will also not run after cargo finally gave me: Finished release [optimized] target(s)

thread 'main' panicked at 'calledResult::unwrap()on anErrvalue: XcbConn(ClosedParseErr)

refers to: let mut ctx: ClipboardContext = ClipboardProvider::new().unwrap();

happy-machine commented 2 years ago

My issue is more to do with the behaviour of cargo as a dependency management tool.

That would probably be better directed to https://github.com/rust-lang/cargo.

I will do so