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

Hello world not working out-of-the-box #32361

Open
pcellix opened this issue Jul 2, 2023 · 17 comments
Open

Hello world not working out-of-the-box #32361

pcellix opened this issue Jul 2, 2023 · 17 comments
Labels
community Community contribution

Comments

@pcellix
Copy link

pcellix commented Jul 2, 2023

Problem

Hi,

After observing solana community from outside I've decided to join this community from developer side.
I wanted to start using tutorial
https://docs.solana.com/getstarted/rust
Unfortunately it does not working currently out of the box using ubuntu 20.04
The message I receive is:

Warning: cargo-build-bpf is deprecated. Please, use cargo-build-sbf
cargo-build-bpf child: /home/ubuntu/.local/share/solana/install/active_release/bin/cargo-build-sbf --arch bpf
error: package solana-program v1.16.2 cannot be built because it requires rustc 1.68.0 or newer, while the currently active rustc version is 1.62.0-dev

Proposed Solution

  1. In tutorial cargo-build-bpf should be changed to cargo-build-sbf
  2. I've added the following version of solana program to make it work: cargo add solana-program@=1.14.18

I think this should be fixed because when someone is joining the community is enthusiastic and wants to have their code running

Best regards,
Wojtek

@pcellix pcellix added the community Community contribution label Jul 2, 2023
@apfitzge
Copy link
Contributor

apfitzge commented Jul 7, 2023

error: package solana-program v1.16.2 cannot be built because it requires rustc 1.68.0 or newer, while the currently active rustc version is 1.62.0-dev

This error message sounds like your rustc/cargo version is older than v16.2 is requiring

  • Did you install rustup as described in the tutorial?
  • What is your ouptut from cargo --version

@KirillLykov
Copy link
Contributor

Looks like the same issue as #32397

@KirillLykov
Copy link
Contributor

KirillLykov commented Jul 25, 2023

@pcellix I could not reproduce your problem locally.

I followed https://docs.solana.com/getstarted/rust and cargo-build-bpf worked for me. So questions are:

  1. What is your solana-cli version? My version is 1.16.2, please post here output of solana --version
  2. Also output of RUST_LOG=debug cargo build-bpf --version
  3. What was not working version of solana-program added to your Cargo.toml by default? Mine is solana-program = "1.16.5"
  4. Also what manual did you follow to install solana-cli (or what are the commands you've executed)?

@failable
Copy link

failable commented Sep 24, 2023

Same issue. Can not even run the hello world example.

User@macOS:~/git/rust/hello_world $ rustup --version
rustup 1.26.0 (5af9b9484 2023-04-05)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.72.0 (5680fa18f 2023-08-23)`

User@macOS:~/git/rust/hello_world $ rustc --version
rustc 1.72.0 (5680fa18f 2023-08-23)

User@macOS:~/git/rust/hello_world $ cargo --version
cargo 1.72.0 (103a7ff2e 2023-08-15)

User@macOS:~/git/rust/hello_world $ solana --version
solana-cli 1.14.29 (src:695192cf ; feat:139196142)
User@macOS:~/git/rust/hello_world $ RUST_LOG=debug cargo build-bpf --version
Warning: cargo-build-bpf is deprecated. Please, use cargo-build-sbf
cargo-build-bpf child: /Users/User/.local/share/solana/install/active_release/bin/cargo-build-sbf --version --arch bpf
solana-cargo-build-sbf 1.14.29
sbf-tools v1.29

User@macOS:~/git/rust/hello_world $ RUST_LOG=debug cargo build-sbf --version
solana-cargo-build-sbf 1.14.29
sbf-tools v1.29

User@macOS:~/git/rust/hello_world $ cat Cargo.toml 
[package]
name = "hello_world"
version = "0.1.0"
edition = "2021"

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

[dependencies]
solana-program = "1.16.14"

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

The setup is strictly following https://docs.solana.com/getstarted/local .

@Gr3at
Copy link

Gr3at commented Sep 24, 2023

I think I got a more generic solution to the issue.
@KirillLykov's comment was very helpful. Specifically the RUST_LOG=debug cargo build-bpf --version command.

Some Context

I had the exact same error on the hello-world tutorial, i.e. error: package solana-program v1.16.14 cannot be built because it requires rustc 1.68.0 or newer, while the currently active rustc version is 1.62.0-dev. The error seems odd, since rustc -V reported: rustc 1.72.1 (d5c2e9c34 2023-09-13).

The command RUST_LOG=debug cargo build-bpf --version reported that i was using solana-cargo-build-sbf 1.14.29,
while in the Cargo.toml solana-program v1.16.14 crate was defined (after executing cargo add solana-program following the official docs).

This is a minor version difference 1.14 to 1.16, which shouldn't create any issues, since it's supposed to be only backward compatible API extension.

The Solution

I pinned the minor version to match the version of solana-cargo-build-sbf in Cargo.toml

# Cargo.toml
# ... other configs

[dependencies]
solana-program = "=1.14" # pin the minor version to allow update to the latest patch ([as per cargo docs](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#specifying-dependencies-from-cratesio))

# ... other configs

Run cargo build-bpf and it should work now.


Some Comments

Based on the official docs (quoting)

cargo build-bpf installs the toolchain from the currently installed solana CLI tools. You may need to upgrade those tools if you encounter any version incompatibilities.

Solana-CLI stable release points to 1.14.x (instead of the 1.16.x because it is a testnet relase) while the cargo add solana-program install the latest 1.16.x version.

This could be flagged as a Developer UX bug with straightforward mitigation actions by the solana team:

Either:

  1. make sure that minor versions are really compatible between build tools and rust crates, or
  2. or release the cargo crates as pre-releases (e.g. v1.16.x-alpha) so that cargo add will not automatically add them. Once the corresponding cli version is stable mark the crate version as stable to be installed by developers.

@KirillLykov
Copy link
Contributor

@Gr3at thanks for reproducing this and providing instructions.

This is a minor version difference 1.14 to 1.16, which shouldn't create any issues, since it's supposed to be only backward compatible API extension.

Although this is a valid assumption, there are some known problems when migrating from 14 to 16. See #31960

@Gr3at
Copy link

Gr3at commented Sep 26, 2023

@KirillLykov thanks for pointing me to the issue. The conversation there was very informative.

So, based on this comment, in my understanding it is better to work on 1.14 (crates and cli) till all core crates are properly updated to work on 1.16.

@KirillLykov
Copy link
Contributor

@KirillLykov thanks for pointing me to the issue. The conversation there was very informative.

So, based on this comment, in

Based on the testing I did, my understanding is different.
Since this question might be interesting for others, I've wrote there: #31960 (comment)

@FrackinFamous
Copy link

So does anyone have any insight for completely new person to run the very first tutorial or will Solana just leave it that way forever? So frustrating as a new user wanting to learn.

@KirillLykov
Copy link
Contributor

So does anyone have any insight for completely new person to run the very first tutorial or will Solana just leave it that way forever? So frustrating as a new user wanting to learn.

Is this still an issue? I think if you use the latest version of solana, it should just work. If you experienced some problems, please specify your version of solana cli and cargo-sbf. Also when building you onchain program specify to print debug info like RUST_LOG=debug cargo build-spf,

@FrackinFamous
Copy link

FrackinFamous commented Jan 27, 2024

I apologize. I was just terribly frustrated and was not finding anything that worked. I had to downgrade my solana install to the latest stable version 1.17.17. Why is the dev version printed on the main docs for newcomers to use instead of a stable release with no warning? That seems very odd.

[package]
name = "hello_world"
version = "0.1.0"
edition = "2021"

[dependencies]
solana-program = "1.17.17"
solana-sdk = "1.17.17"
ahash = "0.8.5"

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

After downgrading solana program and sdk and also downgrading ahash as another posted in an earlier thread on the issue, I ran.

rm Cargo.lock
cargo update
(deleting my Cargo.lock file and creating a new version, in case someone very new is reading)

then...
cargo update -p solana-sdk --precise 1.17.17
cargo update -p solana-program --precise 1.17.17

to downgrade to the stable versions.

Complied and now receiving errors for multiple versions of crates being installed. I will update ASAP.

RUST_LOG=debug cargo build-sbf
[2024-01-27T16:51:25.091062541Z INFO  cargo_build_sbf] spawn: --version
[2024-01-27T16:51:25.274730242Z INFO  cargo_build_sbf] Solana SDK: /home/frackinfamous/.local/share/solana/install/releases/1.17.17/solana-release/bin/sdk/sbf
[2024-01-27T16:51:25.274854942Z INFO  cargo_build_sbf] spawn: toolchain list -v
[2024-01-27T16:51:25.280291142Z INFO  cargo_build_sbf] spawn: +solana build --release --target sbf-solana-solana
error: package `solana-program v1.18.0` cannot be built because it requires rustc 1.72.0 or newer, while the currently active rustc version is 1.68.0-dev
Either upgrade to rustc 1.72.0 or newer, or use
cargo update -p [email protected] --precise ver

where ver is the latest version of solana-program supporting rustc 1.68.0-dev

@FrackinFamous
Copy link

I ended up restarting from scratch. Same issue.

RUST_LOG=debug cargo build-sbf
[2024-01-27T17:16:02.584833161Z INFO cargo_build_sbf] spawn: --version
[2024-01-27T17:16:02.738686760Z INFO cargo_build_sbf] Solana SDK: /home/frackinfamous/.local/share/solana/install/releases/1.17.17/solana-release/bin/sdk/sbf
[2024-01-27T17:16:02.738777760Z INFO cargo_build_sbf] spawn: toolchain list -v
[2024-01-27T17:16:02.743675360Z INFO cargo_build_sbf] spawn: +solana build --release --target sbf-solana-solana
error: package solana-program v1.18.0 cannot be built because it requires rustc 1.72.0 or newer, while the currently active rustc version is 1.68.0-dev
Either upgrade to rustc 1.72.0 or newer, or use
cargo update -p [email protected] --precise ver
where ver is the latest version of solana-program supporting rustc 1.68.0-dev

@FrackinFamous
Copy link

error: package solana-program v1.16.2 cannot be built because it requires rustc 1.68.0 or newer, while the currently active rustc version is 1.62.0-dev

This error message sounds like your rustc/cargo version is older than v16.2 is requiring

  • Did you install rustup as described in the tutorial?

  • What is your ouptut from cargo --version

It does the same thing now no matter how many times you wipe and reinstall. Switch computers. Buy new HDD or stand on your head. It now says you are running 1.68dev and need 1.72. I've never installed version 1.68dev ever. Obviously you could read the error and tell him he has the wrong version. 20 hours later and I can still read it the error on mine but it doesn't help. How is this still the standard instructional tutorial for new people and every update it just sucks the same with new numbers?

@billythedummy
Copy link
Contributor

billythedummy commented Jan 28, 2024

Related: #34987

Hope this helps: #34987 (comment), #34987 (comment)

@FrackinFamous
Copy link

Related: #34987

Hope this helps: #34987 (comment), #34987 (comment)

Starting to wrap my head around the issue but still not getting it. It 100% does not work from the tutorial if you have never had rust installed on a bare linux build and start the tutorial from scratch it does not work. I have been through it 10 times following all of what 5 steps, to a T. Still in the same spot. UGH. So I can 100% confirm this is still screwing new people post tagging whatever install they are supposed to tag.

error: package solana-program v1.18.0 cannot be built because it requires rustc 1.72.0 or newer, while the currently active rustc version is 1.68.0-dev
Either upgrade to rustc 1.72.0 or newer, or use
cargo update -p [email protected] --precise ver
where ver is the latest version of solana-program supporting rustc 1.68.0-dev
frackinfamous@localhost:~/dev/hello_world$ cargo-build-sbf --version
solana-cargo-build-sbf 1.17.19
platform-tools v1.37
rustc 1.68.0

@FrackinFamous
Copy link

active_release already points to stable release

active_release -> /home/frackinfamous/.local/share/solana/install/releases/stable-b8ac42552b7b084e60221905c239124b8135bc36/solana-release

@FrackinFamous
Copy link

Finally got it working here #34991 but great comments in this thread and #34987 lead me there too! Looks like more folks are figuring it out. Thanks everyone.

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

No branches or pull requests

7 participants