Skip to content

Commit 66f199b

Browse files
Merge pull request #750 from multiversx/troubleshoot-19
Sketch troubleshooting (e.g. Rust installation, rust-analyzer)
2 parents 79e18d9 + 0fabf97 commit 66f199b

File tree

7 files changed

+233
-5
lines changed

7 files changed

+233
-5
lines changed

docs/developers/tutorials/crowdfunding-p1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ The source code of each smart contract requires its own folder. You'll need to c
7272
```bash
7373
mkdir -p ~/MultiversX/SmartContracts
7474
cd ~/MultiversX/SmartContracts
75-
mxpy contract new crowdfunding --template empty
75+
mxpy contract new --name crowdfunding --template empty
7676
code crowdfunding
7777
```
7878

docs/developers/tutorials/staking-contract.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Both can be easily installed from the "Extensions" menu in VSCode.
6969
Run the following command in the folder in which you want your smart contract to be created:
7070

7171
```
72-
mxpy contract new staking-contract --template empty
72+
mxpy contract new --name staking-contract --template empty
7373
```
7474

7575
Open VSCode, select File -> Open Folder, and open the newly created `staking-contract` folder.

docs/sdk-and-tools/sdk-py/mxpy-cli.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ For example, in order to check if `rust` is installed you would type:
6363
mxpy deps check rust
6464
```
6565

66-
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.
66+
When installing dependecies the `--overwrite` argument can be used to overwrite an existing version.
6767

6868
For example, to install `rust`, you can simply type the command:
6969
```sh
@@ -78,7 +78,7 @@ Generally speaking, the default `rust` version installed by `mxpy` is the one re
7878

7979
Here's how to install a specific version of `rust` (example):
8080
```sh
81-
mxpy deps install rust --tag nightly-2023-04-24 --overwrite
81+
mxpy deps install rust --overwrite
8282
```
8383

8484
[comment]: # (mx-context-auto)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
id: ide-setup
3+
title: Fix IDEs configuration
4+
---
5+
6+
[comment]: # (mx-abstract)
7+
8+
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)).
9+
10+
[comment]: # (mx-context-auto)
11+
12+
## VSCode: fix configuration for Rust Analyzer
13+
14+
If `rust-analyzer` is not working properly on VSCode, you might see (one of) the following error messages:
15+
16+
```
17+
- rust-analyzer failed to load workspace: Failed to load the project.
18+
- Failed to query rust toolchain version.
19+
- error: rustup could not choose a version of cargo to run, because one wasn't specified explicitly, and no default is configured.
20+
```
21+
22+
To fix this, first **[make sure Rust is properly installed](/sdk-and-tools/troubleshooting/rust-setup)**.
23+
24+
Afterwards, check the content of the configuration file `.vscode/settings.json`.
25+
26+
Basic `.vscode/settings.json` for Linux:
27+
28+
```json
29+
{
30+
"terminal.integrated.env.linux": {
31+
"PATH": "${env:HOME}/multiversx-sdk:${env:HOME}/multiversx-sdk/vmtools:${env:PATH}",
32+
}
33+
}
34+
```
35+
36+
Basic `.vscode/settings.json` for MacOS:
37+
38+
```json
39+
{
40+
"terminal.integrated.env.osx": {
41+
"PATH": "${env:HOME}/multiversx-sdk:${env:HOME}/multiversx-sdk/vmtools:${env:PATH}",
42+
}
43+
}
44+
```
45+
46+
Then, restart VSCode. Now, `rust-analyzer` should work properly. If the problem persists, please [contact us](/developers/overview).
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
---
2+
id: rust-setup
3+
title: Fix Rust installation
4+
---
5+
6+
[comment]: # (mx-abstract)
7+
8+
When encountering issues with your Rust installation, we recommend a cleanup (uninstall) first, especially if you have multiple installations (by accident or on purpose).
9+
10+
[comment]: # (mx-context-auto)
11+
12+
## Uninstall existing Rust
13+
14+
If you've installed Rust using your OS package manager:
15+
16+
```bash
17+
# Ubuntu
18+
sudo apt remove cargo
19+
sudo apt autoremove
20+
```
21+
22+
If you've installed Rust using `rustup`:
23+
24+
```bash
25+
rustup self uninstall
26+
```
27+
28+
If you've installed Rust using `mxpy` with a version older than `v9`:
29+
30+
```bash
31+
rm -rf ~/multiversx-sdk/vendor-rust
32+
```
33+
34+
:::note
35+
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).
36+
:::
37+
38+
If you've installed Rust using `mxpy v9` or later:
39+
40+
```bash
41+
rustup self uninstall
42+
```
43+
44+
[comment]: # (mx-context-auto)
45+
46+
## Installing Rust and sc-meta
47+
48+
[comment]: # (mx-context-auto)
49+
50+
:::note
51+
`sc-meta` is universal smart contract management tool. Please follow [this](/developers/meta/sc-meta) for more information.
52+
:::
53+
54+
### With mxpy
55+
56+
```bash
57+
mxpy deps install rust --overwrite
58+
```
59+
60+
:::note
61+
In addition to Rust and `sc-meta`, the above command also installs `twiggy` and `wasm-opt`.
62+
:::
63+
64+
For more information, go to [managing dependencies using `mxpy`](/sdk-and-tools/sdk-py/mxpy-cli/#managing-dependencies).
65+
66+
[comment]: # (mx-context-auto)
67+
68+
### Without mxpy
69+
70+
As recommended on [rust-lang.org](https://www.rust-lang.org/tools/install):
71+
72+
```bash
73+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
74+
```
75+
76+
Then, choose **Proceed with installation (default)**.
77+
78+
Once Rust is installed, switch to a nightly version and install the `wasm32-unknown-unknown` target:
79+
80+
```bash
81+
rustup default nightly-2023-05-26
82+
rustup target add wasm32-unknown-unknown
83+
```
84+
85+
Afterwards, install `sc-meta`:
86+
87+
```bash
88+
cargo install multiversx-sc-meta
89+
```
90+
91+
Optionally, you may also want to install `wasm-opt` and `twiggy`:
92+
93+
```bash
94+
cargo install wasm-opt
95+
cargo install twiggy
96+
```
97+
98+
[comment]: # (mx-context-auto)
99+
100+
### Without mxpy (CI / CD)
101+
102+
For CI / CD, use the following:
103+
104+
```bash
105+
wget -O rustup.sh https://sh.rustup.rs && \
106+
chmod +x rustup.sh && \
107+
./rustup.sh --verbose --default-toolchain nightly-2023-05-26 --target wasm32-unknown-unknown -y
108+
109+
cargo install multiversx-sc-meta
110+
```
111+
112+
[comment]: # (mx-context-auto)
113+
114+
### Handle missing dependencies of sc-meta
115+
116+
`sc-meta` requires a few dependencies that are not installed by default on some systems. In this case, installation of `sc-meta` fails.
117+
118+
For a workaround, please follow this [GitHub issue](https://github.com/multiversx/mx-sdk-py-cli/issues/338).
119+
120+
## Check your Rust installation
121+
122+
You can check your Rust installation by invoking `rustup show`:
123+
124+
```
125+
$ rustup show
126+
127+
Default host: x86_64-unknown-linux-gnu
128+
rustup home: /home/ubuntu/.rustup
129+
130+
installed toolchains
131+
--------------------
132+
133+
[...]
134+
nightly-2023-05-26-x86_64-unknown-linux-gnu (default)
135+
136+
installed targets for active toolchain
137+
--------------------------------------
138+
139+
[...]
140+
wasm32-unknown-unknown
141+
142+
143+
active toolchain
144+
----------------
145+
146+
[...]
147+
nightly-2023-05-26-x86_64-unknown-linux-gnu (default)
148+
```
149+
150+
You can also check the status of your Rust installation using `mxpy`:
151+
152+
```
153+
$ mxpy deps check rust
154+
155+
INFO cli.deps: Checking dependency: module = rust, tag = nightly-2023-05-26
156+
INFO modules: which rustc: /home/ubuntu/.cargo/bin/rustc
157+
INFO modules: which cargo: /home/ubuntu/.cargo/bin/cargo
158+
INFO modules: which sc-meta: /home/ubuntu/.cargo/bin/sc-meta
159+
INFO modules: which wasm-opt: /home/ubuntu/.cargo/bin/wasm-opt
160+
INFO modules: which twiggy: /home/ubuntu/.cargo/bin/twiggy
161+
INFO cli.deps: [rust nightly-2023-05-26] is installed.
162+
```
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
id: troubleshooting
3+
title: Overview
4+
---
5+
6+
[comment]: # (mx-abstract)
7+
8+
Here you can find some common issues and their solutions, in the context of [MultiversX SDKs and Tools](/sdk-and-tools/overview).
9+
10+
1. [Fix Rust installation](/sdk-and-tools/troubleshooting/rust-setup)
11+
2. [Fix IDEs configuration](/sdk-and-tools/troubleshooting/ide-setup)

sidebars.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,18 @@ const sidebars = {
281281
"sdk-and-tools/erdcpp",
282282
"sdk-and-tools/sdk-nestjs",
283283
"sdk-and-tools/erdkotlin",
284-
"sdk-and-tools/sdk-js-wallet-cli",
284+
"sdk-and-tools/sdk-js-wallet-cli"
285285
],
286286
},
287+
{
288+
type: "category",
289+
label: "Troubleshooting",
290+
items: [
291+
"sdk-and-tools/troubleshooting/troubleshooting",
292+
"sdk-and-tools/troubleshooting/rust-setup",
293+
"sdk-and-tools/troubleshooting/ide-setup"
294+
],
295+
}
287296
],
288297
Wallet: [
289298
"wallet/overview",

0 commit comments

Comments
 (0)