Skip to content

Anchor failed to build with provided dockerfile #2589

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

Closed
yi-fan-song opened this issue Aug 2, 2023 · 5 comments
Closed

Anchor failed to build with provided dockerfile #2589

yi-fan-song opened this issue Aug 2, 2023 · 5 comments
Labels
docker Docker related issues/PRs installation error Issues related to installation errors

Comments

@yi-fan-song
Copy link

Trying to build the docker file here results in error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory.

solana-cli: v1.14.22
anchor: v0.28.0

This arised from trying to fix anchor build on ubuntu 22.04 with the same error. Upgrading solana-cli to 1.16.5 fixed it, but then all subsequent programs compiled and running on the local test validator end up with this kind of issue

@acheroncrypto
Copy link
Collaborator

The image is uploaded at backpackapp/build. We're also using Ubuntu latest in our CI with only these build dependencies.

Upgrading solana-cli to 1.16.5 fixed it

libz.so.1: cannot open shared object file is not related to your solana-cli version, it could be that you had a corrupted installation and upgrading fixed it somehow.

From this StackOverflow question:

sudo apt install zlib1g

should install the necessary build dependencies.

all subsequent programs compiled and running on the local test validator end up with solana-labs/solana#30271 kind of issue

The problem in solana-labs/solana#31960 is not yet fixed and it's not an Anchor specific issue.

@acheroncrypto acheroncrypto added docker Docker related issues/PRs installation error Issues related to installation errors labels Aug 2, 2023
@yi-fan-song
Copy link
Author

Oh my apologies, I pasted the wrong error it's libssl not libz that's giving the issue

251.2 /root/.rustup/toolchains/bpf/bin/cargo: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory

this is why I had suspicions that it had to do with the newer ubuntu versions as 22.04 comes with libssl-dev3.0.9-1 while older versions of ubuntu had libssl-dev1.1.1. Of course I can manually downgrade the version of libssl-dev, but I would prefer not to resort to doing that.
Nonetheless, I think this is actually caused by cargo-build-bpf. Correct me if I'm wrong, is anchor running cargo-build-bpf and would it be possible for anchor to use cargo-build-spf instead as cargo-build-bpf has been deprecated. cargo-build-spf supposedly has that fixed from solana-labs/solana#31128, but there is still solana-labs/solana#31693. I would test it right now, but I don't have the machine on ubuntu 22.04.

Thanks for pointing me to solana-labs/solana#31960

@acheroncrypto
Copy link
Collaborator

Nonetheless, I think this is actually caused by cargo-build-bpf. Correct me if I'm wrong, is anchor running cargo-build-bpf and would it be possible for anchor to use cargo-build-spf instead as cargo-build-bpf has been deprecated.

You can use anchor build --arch sbf to build with cargo-build-sbf but the problem is that fix requires the newer version of build tools which has the solana-labs/solana#31960 problem.

You can use this Dockerfile to build with solana 1.14.

@KS3D
Copy link

KS3D commented Sep 6, 2023

I've resolved the issue by making the following changes to the Dockerfile:

# Previous lines
ARG SOLANA_CLI
ARG ANCHOR_CLI

# Updated lines
ARG SOLANA_CLI="v1.14.26"
ARG ANCHOR_CLI="v0.28.0"

# Added these lines to download and install libssl1.1
RUN wget http://nz2.archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.19_amd64.deb
RUN dpkg -i libssl1.1_1.1.1f-1ubuntu2.19_amd64.deb

# After install anchor command
# Also, added the following line to fix the error related to rustc version
RUN solana-install init 1.16.3

@acheroncrypto
Copy link
Collaborator

This problem wasn't caused by Anchor to begin with but it should be fixed in 0.29.0 regardless since we've dropped the Solana 1.14 support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docker Docker related issues/PRs installation error Issues related to installation errors
Projects
None yet
Development

No branches or pull requests

3 participants