# Solana self-learning

By [Untitled](https://paragraph.com/@0x9b05b71fe3b7c5a84d8bbcc1f77fb81a94543771) · 2024-02-26

---

I’m learning solana and rust with [the fascinating turorial by Rareskills](https://www.rareskills.io/solana-tutorial). And I ran into many issues in the process, so I decided to made a daily log to record my solana journey and meet anyone who’s interesting in learning solana. Ps: most of the contents I wrote here cames from the tutorial by Rareskills, I’m recording the issues and how I fixed it during the study process.

Join my tg! :

[https://t.me/solanastudygroup](https://t.me/solanastudygroup)

Ok let’s dive in [day1](https://www.rareskills.io/post/hello-world-solana):

### Install environments

Install rust and yarn

    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
    npm install --global yarn
    

Install Solana

    sh -c "$(curl -sSfL https://release.solana.com/stable/install)"
    

Install Anchor(Solana devlopment frame)

    cargo install --git https://github.com/coral-xyz/anchor avm --locked --force
    
    avm install latest
    avm use latest
    

### Initialize and build an Anchor Program

    anchor init day_1
    

Be sure to do: anchor init day\_1, not anchor init day1, use day\_1 instead of day1. Cuz Anchor seems to silently insert underscores on Mac machines sometimes. Im on wsl2 of windows and still have wired things happened when named my project with day1. The error goes:

    Error: target/idl/day_1.json doesn't exist. Did you run `anchor build`?
    

Continue to build:

    cd day1
    anchor build
    

Another error:

    error[E0658]: use of unstable library feature 'build_hasher_simple_hash_one'
    

The solution is:

    cargo update -p ahash@0.8.9 --precise 0.8.6
    

Draft saved

[Permalink](https://mirror.xyz/0x9B05B71fe3b7c5a84D8bbCc1f77fb81a94543771/3XXQXw_NmNmzC3pa-wVy-XeUhJI_cZY3C7maqVo6Uag)

Open Settings Panel

Publish

Remove header image

0x9B05…3771

0x9B05

Draft

Another error:

    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
    

The solution is:

    cargo add solana-program@=1.17.0 
    cargo update -p solana-program
    

Lets run anchor build again. And boom it build successfully!

Configure Solana to run on localhost

    solana config set --url localhost
    

Key sync

    anchor keys sync
    

Run test:

    anchor test --skip-local-validator
    

If everything went well, you’ll see:

![](https://storage.googleapis.com/papyrus_images/6f8c47d9f8573dd56a3a8fc57af261990420408e7998ffbb7e6704e46243ee4a.png)

### Add logging hello world to the code

Let’s edit the code and add one line to lib.rs

    nano ./programs/day_1/src/lib.rs
    

    use anchor_lang::prelude::*;
    
    declare_id!("...");
    
    #[program]
    pub mod day_1 {
        use super::*;
    
        pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
            msg!("Hello, world!"); // **** NEW LINE HERE ****
            Ok(())
        }
    }
    
    #[derive(Accounts)]
    pub struct Initialize {}
    

And run test again:

    anchor test --skip-local-validator
    

List the log file and open it with nano

    ls .anchor/program-logs/
    # you'll see the file *****.log, open it
    nano .anchor/program-logs/*****.log
    

You’ll see

![](https://storage.googleapis.com/papyrus_images/9c44266a946345a6f895f4cb8729bcef106e179e0fed28dc47ef294f094080df.png)

That’s it! Thanks. Join my tg if you have any problems and wants to discuss with me

[https://t.me/solanastudygroup](https://t.me/solanastudygroup)

---

*Originally published on [Untitled](https://paragraph.com/@0x9b05b71fe3b7c5a84d8bbcc1f77fb81a94543771/solana-self-learning)*
