Foundry quick installation (Windows version)
When I checked the Foundry official document , I found that the description of the installation steps was not detailed. At first, the installation problem could not be solved, so I recorded the detailed installation process, and chose the fastest and least hard disk space download method.
The download steps given in the official document
On Windows, build from the source
If you use Windows, you need to build from the source to get Foundry.
Download and run rustup-init from rustup.rs. It will start the installation in a console.
If you encounter an error, it is most likely the case that you do not have the VS Code Installer which you can download here and install.
After this, run the following to build Foundry from the source:
cargo install --git https://github.com/foundry-rs/foundry foundry-cli anvil chisel --bins --locked
To update from the source, run the same command again.
Detailed installation steps
1. Download rustup.rs
When reading the introduction of Foundry, we can know that Foundry is a contract testing framework written in Rust language, so it is easy to know that the operation of Foundry is inseparable from the support of Rust, so we need to install Rust language first to successfully run the Foundry framework.
rustup-init installation package
After downloading and opening, we will see
To develop Rust on Windows, you need to install tools such as C++ Build Tools, and C++ Build Tools is bound by Visual Studio. To download C++ Build Tools, you must download Visual Studio, but the Visual Studio installation package is very large, and the download speed is sometimes good.
If the computer configuration is poor, or you do not want to download a file of about 10G, it is recommended to choose 3.
Choose 3 here, because the file to be downloaded is very small, and mingw-w64 is also a C/C++ compiler, which is the Windows version of GCC.
2. Install mingw-w64
2.1. Download source code files
Open mingw-w64 , select x86_64-win32-seh, about 50 M, which is much better than Visual Studio's close to 10G file.
2.2. Setting environment variables
After downloading, unzip it to any directory, then right-click "This Computer->Properties->Advanced System Settings->Environment Variables", set the PATH variable
Note: The environment variables here are set according to the specific path of your own computer
2.3. Check whether the installation is successful
win + R key to output cmd to open the command line, then enter gcc -v
When this prompt appears, it indicates that mingw-w64 is installed successfully
3. Install Rust
Open the rustup-init installation package installed in the first step, enter 3, press Enter , do not have spaces and other content when entering, and a prompt will appear
Then enter 2, press Enter , it is a custom installation, and a prompt appears
Note: Except for the first prompt that needs to be modified, the rest can be entered by default
Then come back to the prompt of the first step before, enter 1, press Enter , and then appear
Wait for it to download the file. It takes a long time to wait here, but just be patient. If there is an error in the download, reset the above settings and start the process again.
After the download is complete, press the win + R key to enter cmd, and enter rustc -V (note: it is a capital V)
When this prompt appears, Rust has been successfully installed
4. Install Foundry
Press win + R key to enter cmd, and enter the following code
cargo install --git https://github.com/foundry-rs/foundry foundry-cli anvil chisel --bins --locked
When the following error occurs, it indicates that the network connection is unstable, and the "network problem" needs to be resolved (traveling around the world)
Next we enter the following command in an empty folder
forge init 你想要取的项目名字
When the installation is successful, the following prompt will be displayed
The forge-std here may also fail to download successfully due to "network problems", and the solution is the same as above
So far, Foundry has been successfully installed, and then you can start your learning journey better...