2

I'm in the process of deploying the Solana helloworld example smart contract on Ubuntu 20.04. When running npm run build:program-rust, the package.json in the root of the repository states that this corresponds with cargo build-bpf --manifest-path=./src/program-rust/Cargo.toml --bpf-out-dir=dist/program. However, when running this command compilation is stuck without any indicators, even when appending the verbosity tag to the cargo build command.

I have a fresh installation of Ubuntu 20.04 and only took the following steps:

  • sudo apt update && sudo apt upgrade
  • Install NodeJS v14.x and build-essential
  • Install Rust: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  • Install Solana CLI: sh -c "$(curl -sSfL https://release.solana.com/v1.8.6/install)"
  • git clone https://github.com/solana-labs/example-helloworld.git

When running which cargo-build-bpf, Ubuntu points towards the directory ~/.local/share/solana/install/releases/1.8.6/solana-release/bin/cargo-build-bpf, indicating that the PATH variable has been updated correctly.

The Cargo.toml file looks as follows:

[package]
name = "solana-bpf-helloworld"
version = "0.0.1"
description = "Example template program written in Rust"
authors = ["Solana Maintainers <[email protected]>"]
repository = "https://github.com/solana-labs/solana"
license = "Apache-2.0"
homepage = "https://solana.com/"
edition = "2018"

[features]
no-entrypoint = []

[dependencies]
borsh = "0.9.3"
borsh-derive = "0.9.1"
solana-program = "~1.10.35"

[dev-dependencies]
solana-program-test = "~1.10.35"
solana-sdk = "~1.10.35"

[lib]
name = "helloworld"
crate-type = ["cdylib", "lib"]

Yesterday, I tried deleting the Cargo.lock file and run cargo update. It got stuck in trying to retrieve the Borsh crate which is also specified in the Cargo.toml file. I don't exactly know the relevance of this, but it seems worth pointing out.

2 Answers 2

1

I went out tonight and left the command running. When I came back, I was delighted to be greeted with an error message:

error: Unable to update registry `crates-io`

    Caused by:
      failed to fetch `https://github.com/rust-lang/crates.io-index`

    Caused by:
      network failure seems to have happened
      if a proxy or similar is necessary `net.git-fetch-with-cli` may help here
      https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli

    Caused by:
      SSL error: received early EOF; class=Ssl (16); code=Eof (-20)

This issue was mentioned here and while still open, the workaround did the trick for me. Simply set the mentioned environment variable to true as follows:

export CARGO_NET_GIT_FETCH_WITH_CLI=true

I will accept my own answer when I'm allowed to do so (in two days).

0

I was able to solve the problem after long hours

  1. First you need to resolve the network problem allowing the system to reach full 100%.
  • Using the external git system is more stable than using the one that is build in

export CARGO_NET_GIT_FETCH_WITH_CLI=true

Add this to your ~/.bashrc file and restart the terminal

This will switch to the external git

  1. Now increase the GIT Timeouts for slower connections

git config --global http.lowSpeedLimit 1000

git config --global http.lowSpeedTime 60

this will make GIT be very patient when downloading and dont stop easily on timeots

  1. Delete cache-inconsistencies

Once your download is reaching 100% but still failing you have to delete everythin in

cd ~/.cargo/registry

enter into this folder and use rm -rf * to delete all files and subfolders there

Once the folder is completely empty run

cargo build-bpf

This will then finally work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.