Search code examples
smartcontractsstellar

Building a soroban smart contract on stellar but having target/core problems


I am following the starter tutorial from original web site Getting Started on stellar.org but encountering problems at ```` stellar contract build` ``` step.

It returns me the error shown below.

error[E0463]: can't find crate for `core`
  |
  = note: the `wasm32-unknown-unknown` target may not be installed
  = help: consider downloading the target with `rustup target add wasm32-unknown-unknown`

As suggested in the tutorial i have run the

rustup target add wasm32-unknown-unknown

command to install target, and confirmed it with

❯ rustup target list --installed

wasm32-unknown-unknown
x86_64-unknown-linux-gnu

showing that target is installed. After seeing another target is also existing, i tought that maybe it confuses the targets so i tried

cargo build --target wasm32-unknown-unknown --release

command which is stated in tutorial performs same action as stellar contract build but i hoped that typing the target clears any confusion. Still i recived same error with stellar contract build stating that "cant find core".

So i have removed the target with

rustup target remove wasm32-unknown-unknown

the used the rustup target list --installed ensure target is actually removed. Seeing that target it not there i run

cargo clean 

which stated that it removed 1 gb of data. Then i have run

rustup update
cargo update

to ensure everything is up to date

then reinstalled the target with

rustup target add wasm32-unknown-unknown

then ensured the installation with

rustup target list --installed

Trying to build again yielded same error about not finding core.

So i tried to remove target > remove tool chain > install toolchain > intstal target with commands below.

rustup target remove wasm32-unknown-unknown
rustup toolchain uninstall stable
rustup toolchain install stable
rustup target add wasm32-unknown-unknown

To get the same error message again.

What should i do to make it see the core?


Solution

  • Turns out my rust installment is corrupted. So i have solved it first removing the rust with command

    rustup self uninstall
    

    then installed with

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

    then added it to

    source "$HOME/.cargo/env.fish"
    

    that is a fish sspecific command given by rust installation. using bash or zsh there is a diffrent command. after that

    rustup update
    

    Now it works as intended.

    Rust had no problem previously on my device, so it is definitely an unique case.