Search code examples
amazon-web-servicesdigital-oceansolanaanchor-solana

avm install 0.28.0 gives "cannot compile `libsecp256k1` (lib) error" on AWS EC2 Ubuntu and Digital Ocean Ubuntu droplet, no issues locally


So I'm trying to setup a solana anchor project with a smart contract and client, and I cannot get anchor installed properly on either AWS EC2 instances nor on Digital ocean ubuntu droplets. Please see attached image:

enter image description here

I have zero issues running the install commands on my local ubuntu environment. I have tried a handful of different things such as downloading anchor via npm package manager, installing libsecp256k1 seprately, and a lot more. See my ChatGPT convo linked here: https://chat.openai.com/share/aad43512-5b68-4f1e-98cf-36a7645e4b82

The project I am trying to utilize is linked below. I am using this as a basis for a solana smart contract.

https://www.youtube.com/watch?v=3GHlk6vosQw

https://github.com/chang47/Anchor-Mint-and-Transfer-Smart-Contract

Here are the resources I have been following for install commands:

https://www.anchor-lang.com/docs/installation

https://lorisleiva.com/create-a-solana-dapp-from-scratch/getting-started-with-solana-and-anchor

Here is the dockerized version of my install commands I am running. The error occurs on "avm install 0.28.0"

# Use an official Node.js runtime as the base image
FROM node:14

# Set a working directory inside the container
WORKDIR /app

# Install necessary dependencies
RUN apt-get update && \
apt-get install -y \
build-essential \
curl \
libssl-dev \
pkg-config \
libsecp256k1-dev \
&& rm -rf /var/lib/apt/lists/*

# RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -y | sh

# Install Rust using the official install script
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o rustup-init.sh \
&& sh rustup-init.sh -y --default-toolchain stable --profile minimal \
&& rm rustup-init.sh

# Add Rust binaries to PATH
ENV PATH="/root/.cargo/bin:${PATH}"


# RUN source "$HOME/.cargo/env"
RUN sh -c "$(curl -sSfL https://release.solana.com/v1.16.7/install)"
ENV PATH="/root/.local/share/solana/install/active_release/bin:$PATH"


RUN cargo install --git https://github.com/coral-xyz/anchor avm --locked --force
# Install the Anchor CLI
#RUN cargo install --git https://github.com/project-serum/anchor --branch avm --locked
RUN avm install 0.28.0
RUN avm use latest

Solution

  • According to https://github.com/paritytech/libsecp256k1/issues/94, you need at least 2GB of RAM to compile the library. Given that, you can either download pre-built binaries or get a machine with more RAM.