From f7d9c1d618775a992478c85600aa2a72abca18e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Sun, 19 Nov 2023 11:26:03 +0200 Subject: [PATCH 1/6] Sketch troubleshooting. --- .../troubleshooting/install-rust.md | 99 +++++++++++++++++++ .../troubleshooting/troubleshooting.md | 7 ++ sidebars.js | 8 ++ 3 files changed, 114 insertions(+) create mode 100644 docs/sdk-and-tools/troubleshooting/install-rust.md create mode 100644 docs/sdk-and-tools/troubleshooting/troubleshooting.md diff --git a/docs/sdk-and-tools/troubleshooting/install-rust.md b/docs/sdk-and-tools/troubleshooting/install-rust.md new file mode 100644 index 000000000..02b27f3ed --- /dev/null +++ b/docs/sdk-and-tools/troubleshooting/install-rust.md @@ -0,0 +1,99 @@ +--- +id: install-rust +title: How to install Rust +--- + +[comment]: # (mx-abstract) + +When encountering issues with your Rust installation, we recommend a cleanup (uninstall) first, especially if you have multiple installations (by accident or on purpose). + +[comment]: # (mx-context-auto) + +## Uninstall existing Rust + +If you've installed Rust using your OS package manager: + +```bash +# Ubuntu +sudo apt remove cargo +sudo apt autoremove +``` + +If you've installed Rust using `rustup`: + +```bash +rustup self uninstall +``` + +If you've installed Rust using `mxpy` with a version older than `v9`: + +```bash +rm -rf ~/multiversx-sdk/vendor-rust +``` + +:::note +Since `mxpy v9` (November of 2023), `mxpy deps install rust` does not create an isolated Rust installation anymore in `~/multiversx-sdk/vendor-rust`. Instead, [it installs Rust _globally_](https://www.rust-lang.org/tools/install). +::: + +If you've installed Rust using `mxpy v9` or later: + +```bash +rustup self uninstall +``` + +[comment]: # (mx-context-auto) + +## Installing Rust and `sc-meta` + +[comment]: # (mx-context-auto) + +### With `mxpy` + +note, prior v9. + +``` +mxpy config get "dependencies.rust.resolution" "host" +``` + +[comment]: # (mx-context-auto) + +### Without `mxpy` + +As recommended on [rust-lang.org](https://www.rust-lang.org/tools/install): + +``` +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh +``` + +Then, + +``` +source "$HOME/.cargo/env" + +rustup default nightly-2023-05-26 +rustup target add wasm32-unknown-unknown + +cargo install multiversx-sc-meta +``` + +[comment]: # (mx-context-auto) + +### Without `mxpy` (CI / CD) + +For CI / CD, use the following: + +``` +wget -O rustup.sh https://sh.rustup.rs && \ + chmod +x rustup.sh && \ + ./rustup.sh --verbose --default-toolchain nightly-2023-05-26 --target wasm32-unknown-unknown -y + +cargo install multiversx-sc-meta +``` + +[comment]: # (mx-context-auto) + +### Missing `sc-meta` dependencies + +https://github.com/multiversx/mx-sdk-py-cli/issues/338 + +Workaround: run sudo apt-get install pkg-config libssl-dev (on Ubuntu). diff --git a/docs/sdk-and-tools/troubleshooting/troubleshooting.md b/docs/sdk-and-tools/troubleshooting/troubleshooting.md new file mode 100644 index 000000000..fa524b8af --- /dev/null +++ b/docs/sdk-and-tools/troubleshooting/troubleshooting.md @@ -0,0 +1,7 @@ +--- +id: troubleshooting +title: Overview +--- + +[comment]: # (mx-abstract) + diff --git a/sidebars.js b/sidebars.js index bcd378da1..c9a16ecbe 100644 --- a/sidebars.js +++ b/sidebars.js @@ -282,6 +282,14 @@ const sidebars = { "sdk-and-tools/sdk-nestjs", "sdk-and-tools/erdkotlin", "sdk-and-tools/sdk-js-wallet-cli", + { + type: "category", + label: "Troubleshooting", + items: [ + "sdk-and-tools/troubleshooting/troubleshooting", + "sdk-and-tools/troubleshooting/install-rust" + ], + }, ], }, ], From 119d0fd2e75886fe3937ae96ac7e4348a97642ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Sun, 19 Nov 2023 12:00:55 +0200 Subject: [PATCH 2/6] Fix command. --- docs/sdk-and-tools/troubleshooting/install-rust.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sdk-and-tools/troubleshooting/install-rust.md b/docs/sdk-and-tools/troubleshooting/install-rust.md index 02b27f3ed..d6177b76d 100644 --- a/docs/sdk-and-tools/troubleshooting/install-rust.md +++ b/docs/sdk-and-tools/troubleshooting/install-rust.md @@ -52,7 +52,7 @@ rustup self uninstall note, prior v9. ``` -mxpy config get "dependencies.rust.resolution" "host" +mxpy config set "dependencies.rust.resolution" "host" ``` [comment]: # (mx-context-auto) From 33874a14455f3bd7f097305246db62bbec7ac1b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Sun, 10 Dec 2023 12:40:42 +0200 Subject: [PATCH 3/6] Update rust install troubleshooter. --- docs/sdk-and-tools/sdk-py/mxpy-cli.md | 4 +- .../troubleshooting/install-rust.md | 82 +++++++++++++++---- 2 files changed, 69 insertions(+), 17 deletions(-) diff --git a/docs/sdk-and-tools/sdk-py/mxpy-cli.md b/docs/sdk-and-tools/sdk-py/mxpy-cli.md index 320761e95..e895e3e8c 100644 --- a/docs/sdk-and-tools/sdk-py/mxpy-cli.md +++ b/docs/sdk-and-tools/sdk-py/mxpy-cli.md @@ -63,7 +63,7 @@ For example, in order to check if `rust` is installed you would type: mxpy deps check rust ``` -When installing dependecies the `--overwrite` argument can be used to overwrite an existing version. Also the `--tag` argument can be used to specify the exact version you want to install. +When installing dependecies the `--overwrite` argument can be used to overwrite an existing version. For example, to install `rust`, you can simply type the command: ```sh @@ -78,7 +78,7 @@ Generally speaking, the default `rust` version installed by `mxpy` is the one re Here's how to install a specific version of `rust` (example): ```sh -mxpy deps install rust --tag nightly-2023-04-24 --overwrite +mxpy deps install rust --overwrite ``` [comment]: # (mx-context-auto) diff --git a/docs/sdk-and-tools/troubleshooting/install-rust.md b/docs/sdk-and-tools/troubleshooting/install-rust.md index d6177b76d..be5997a95 100644 --- a/docs/sdk-and-tools/troubleshooting/install-rust.md +++ b/docs/sdk-and-tools/troubleshooting/install-rust.md @@ -43,46 +43,54 @@ rustup self uninstall [comment]: # (mx-context-auto) -## Installing Rust and `sc-meta` +## Installing Rust and sc-meta [comment]: # (mx-context-auto) -### With `mxpy` +:::note +`sc-meta` is universal smart contract management tool. Please follow [this](/developers/meta/sc-meta) for more information. +::: -note, prior v9. +### With mxpy -``` -mxpy config set "dependencies.rust.resolution" "host" +```bash +mxpy deps install rust --overwrite ``` +For more information, go to [managing dependencies using `mxpy`](/sdk-and-tools/sdk-py/mxpy-cli/#managing-dependencies). + [comment]: # (mx-context-auto) -### Without `mxpy` +### Without mxpy As recommended on [rust-lang.org](https://www.rust-lang.org/tools/install): -``` +```bash curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` -Then, +Then, choose **Proceed with installation (default)**. -``` -source "$HOME/.cargo/env" +Once Rust is installed, switch to a nightly version and install the `wasm32-unknown-unknown` target: +```bash rustup default nightly-2023-05-26 rustup target add wasm32-unknown-unknown +``` +Afterwards, install `sc-meta`: + +```bash cargo install multiversx-sc-meta ``` [comment]: # (mx-context-auto) -### Without `mxpy` (CI / CD) +### Without mxpy (CI / CD) For CI / CD, use the following: -``` +```bash wget -O rustup.sh https://sh.rustup.rs && \ chmod +x rustup.sh && \ ./rustup.sh --verbose --default-toolchain nightly-2023-05-26 --target wasm32-unknown-unknown -y @@ -92,8 +100,52 @@ cargo install multiversx-sc-meta [comment]: # (mx-context-auto) -### Missing `sc-meta` dependencies +### Missing sc-meta dependencies + +`sc-meta` requires a few dependencies that are not installed by default on some systems. In this case, installation of `sc-meta` fails. + +For a workaround, please follow this [GitHub issue](https://github.com/multiversx/mx-sdk-py-cli/issues/338). -https://github.com/multiversx/mx-sdk-py-cli/issues/338 +## Check your Rust installation -Workaround: run sudo apt-get install pkg-config libssl-dev (on Ubuntu). +You can check your Rust installation by invoking `rustup show`: + +``` +$ rustup show + +Default host: x86_64-unknown-linux-gnu +rustup home: /home/ubuntu/.rustup + +installed toolchains +-------------------- + +[...] +nightly-2023-05-26-x86_64-unknown-linux-gnu (default) + +installed targets for active toolchain +-------------------------------------- + +[...] +wasm32-unknown-unknown + + +active toolchain +---------------- + +[...] +nightly-2023-05-26-x86_64-unknown-linux-gnu (default) +``` + +You can also check the status of your Rust installation using `mxpy`: + +``` +$ mxpy deps check rust + +INFO cli.deps: Checking dependency: module = rust, tag = nightly-2023-05-26 +INFO modules: which rustc: /home/ubuntu/.cargo/bin/rustc +INFO modules: which cargo: /home/ubuntu/.cargo/bin/cargo +INFO modules: which sc-meta: /home/ubuntu/.cargo/bin/sc-meta +INFO modules: which wasm-opt: /home/ubuntu/.cargo/bin/wasm-opt +INFO modules: which twiggy: /home/ubuntu/.cargo/bin/twiggy +INFO cli.deps: [rust nightly-2023-05-26] is installed. +``` From 2e429700eb747b2e6c9a9d6166a0e1926c336caf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Sun, 10 Dec 2023 22:13:59 +0200 Subject: [PATCH 4/6] Fix sidebar. Add new page for IDEs. --- .../troubleshooting/ide-setup.md | 46 +++++++++++++++++++ .../{install-rust.md => rust-setup.md} | 13 ++++-- .../troubleshooting/troubleshooting.md | 4 ++ sidebars.js | 19 ++++---- 4 files changed, 70 insertions(+), 12 deletions(-) create mode 100644 docs/sdk-and-tools/troubleshooting/ide-setup.md rename docs/sdk-and-tools/troubleshooting/{install-rust.md => rust-setup.md} (94%) diff --git a/docs/sdk-and-tools/troubleshooting/ide-setup.md b/docs/sdk-and-tools/troubleshooting/ide-setup.md new file mode 100644 index 000000000..207916e42 --- /dev/null +++ b/docs/sdk-and-tools/troubleshooting/ide-setup.md @@ -0,0 +1,46 @@ +--- +id: ide-setup +title: Fix IDEs configuration +--- + +[comment]: # (mx-abstract) + +The issues tackled on this page are related to IDEs preferred by MultiversX builders, such as **VSCode** or **RustRover**. The issues are not strictly related to the official MultiversX VSCode extension (also known as [MultiversX IDE](https://marketplace.visualstudio.com/items?itemName=Elrond.vscode-elrond-ide)). + +[comment]: # (mx-context-auto) + +## VSCode: fix configuration for Rust Analyzer + +If `rust-analyzer` is not working properly on VSCode, you might see (one of) the following error messages: + +``` + - rust-analyzer failed to load workspace: Failed to load the project. + - Failed to query rust toolchain version. + - error: rustup could not choose a version of cargo to run, because one wasn't specified explicitly, and no default is configured. +``` + +To fix this, first **[make sure Rust is properly installed](/sdk-and-tools/troubleshooting/rust-setup)**. + +Afterwards, check the content of the configuration file `.vscode/settings.json`. + +Basic `.vscode/settings.json` for Linux: + +```json +{ + "terminal.integrated.env.linux": { + "PATH": "${env:HOME}/multiversx-sdk:${env:HOME}/multiversx-sdk/vmtools:${env:PATH}", + } +} +``` + +Basic `.vscode/settings.json` for MacOS: + +```json +{ + "terminal.integrated.env.osx": { + "PATH": "${env:HOME}/multiversx-sdk:${env:HOME}/multiversx-sdk/vmtools:${env:PATH}", + } +} +``` + +Then, restart VSCode. Now, `rust-analyzer` should work properly. If the problem persists, please [contact us](/developers/overview). diff --git a/docs/sdk-and-tools/troubleshooting/install-rust.md b/docs/sdk-and-tools/troubleshooting/rust-setup.md similarity index 94% rename from docs/sdk-and-tools/troubleshooting/install-rust.md rename to docs/sdk-and-tools/troubleshooting/rust-setup.md index be5997a95..3a6d47828 100644 --- a/docs/sdk-and-tools/troubleshooting/install-rust.md +++ b/docs/sdk-and-tools/troubleshooting/rust-setup.md @@ -1,6 +1,6 @@ --- -id: install-rust -title: How to install Rust +id: rust-setup +title: Fix Rust installation --- [comment]: # (mx-abstract) @@ -84,6 +84,13 @@ Afterwards, install `sc-meta`: cargo install multiversx-sc-meta ``` +Optionally, you may also want to install `wasm-opt` and `twiggy`: + +```bash +cargo install wasm-opt +cargo install twiggy +``` + [comment]: # (mx-context-auto) ### Without mxpy (CI / CD) @@ -100,7 +107,7 @@ cargo install multiversx-sc-meta [comment]: # (mx-context-auto) -### Missing sc-meta dependencies +### Handle missing dependencies of sc-meta `sc-meta` requires a few dependencies that are not installed by default on some systems. In this case, installation of `sc-meta` fails. diff --git a/docs/sdk-and-tools/troubleshooting/troubleshooting.md b/docs/sdk-and-tools/troubleshooting/troubleshooting.md index fa524b8af..427a67976 100644 --- a/docs/sdk-and-tools/troubleshooting/troubleshooting.md +++ b/docs/sdk-and-tools/troubleshooting/troubleshooting.md @@ -5,3 +5,7 @@ title: Overview [comment]: # (mx-abstract) +Here you can find some common issues and their solutions, in the context of [MultiversX SDKs and Tools](/sdk-and-tools/overview). + +1. [Fix Rust installation](/sdk-and-tools/troubleshooting/rust-setup) +2. [Fix IDEs configuration](/sdk-and-tools/troubleshooting/ide-setup) diff --git a/sidebars.js b/sidebars.js index 930c49e2c..039031bdf 100644 --- a/sidebars.js +++ b/sidebars.js @@ -281,17 +281,18 @@ const sidebars = { "sdk-and-tools/erdcpp", "sdk-and-tools/sdk-nestjs", "sdk-and-tools/erdkotlin", - "sdk-and-tools/sdk-js-wallet-cli", - { - type: "category", - label: "Troubleshooting", - items: [ - "sdk-and-tools/troubleshooting/troubleshooting", - "sdk-and-tools/troubleshooting/install-rust" - ], - }, + "sdk-and-tools/sdk-js-wallet-cli" ], }, + { + type: "category", + label: "Troubleshooting", + items: [ + "sdk-and-tools/troubleshooting/troubleshooting", + "sdk-and-tools/troubleshooting/rust-setup", + "sdk-and-tools/troubleshooting/ide-setup" + ], + } ], Wallet: [ "wallet/overview", From 3c466980ab1484ebce10ee16276c610824246c9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Mon, 11 Dec 2023 13:36:32 +0200 Subject: [PATCH 5/6] Fix invocation of mxpy contract new (for mxpy v9). --- docs/developers/tutorials/crowdfunding-p1.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/developers/tutorials/crowdfunding-p1.md b/docs/developers/tutorials/crowdfunding-p1.md index ff2cf6183..b1d58e2bb 100644 --- a/docs/developers/tutorials/crowdfunding-p1.md +++ b/docs/developers/tutorials/crowdfunding-p1.md @@ -72,7 +72,7 @@ The source code of each smart contract requires its own folder. You'll need to c ```bash mkdir -p ~/MultiversX/SmartContracts cd ~/MultiversX/SmartContracts -mxpy contract new crowdfunding --template empty +mxpy contract new --name crowdfunding --template empty code crowdfunding ``` From 0fabf970ef0b14e49667371717eeedaa33d2b0e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Mon, 11 Dec 2023 13:51:28 +0200 Subject: [PATCH 6/6] Fix after review. --- docs/developers/tutorials/staking-contract.md | 2 +- docs/sdk-and-tools/troubleshooting/rust-setup.md | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/developers/tutorials/staking-contract.md b/docs/developers/tutorials/staking-contract.md index dce0c703f..c2526d5ec 100644 --- a/docs/developers/tutorials/staking-contract.md +++ b/docs/developers/tutorials/staking-contract.md @@ -69,7 +69,7 @@ Both can be easily installed from the "Extensions" menu in VSCode. Run the following command in the folder in which you want your smart contract to be created: ``` -mxpy contract new staking-contract --template empty +mxpy contract new --name staking-contract --template empty ``` Open VSCode, select File -> Open Folder, and open the newly created `staking-contract` folder. diff --git a/docs/sdk-and-tools/troubleshooting/rust-setup.md b/docs/sdk-and-tools/troubleshooting/rust-setup.md index 3a6d47828..a0861d914 100644 --- a/docs/sdk-and-tools/troubleshooting/rust-setup.md +++ b/docs/sdk-and-tools/troubleshooting/rust-setup.md @@ -57,6 +57,10 @@ rustup self uninstall mxpy deps install rust --overwrite ``` +:::note +In addition to Rust and `sc-meta`, the above command also installs `twiggy` and `wasm-opt`. +::: + For more information, go to [managing dependencies using `mxpy`](/sdk-and-tools/sdk-py/mxpy-cli/#managing-dependencies). [comment]: # (mx-context-auto)