### Async Solc Installation with svm-rs Library Source: https://context7.com/alloy-rs/svm-rs/llms.txt Programmatically install a Solidity compiler version using the async `install` function. It downloads, verifies checksums, and returns the path to the installed binary. Requires the `tokio` runtime. ```rust use semver::Version; use svm_rs::{install, blocking_install, SvmError}; // Async installation #[tokio::main] async fn main() -> Result<(), SvmError> { let version: Version = "0.8.26".parse()?; // Install and get path to binary let solc_path = install(&version).await?; println!("Installed at: {}", solc_path.display()); // Output: Installed at: /home/user/.svm/0.8.26/solc-0.8.26 Ok(()) } // Blocking installation (requires feature = "blocking") #[cfg(feature = "blocking")] fn install_blocking() -> Result<(), SvmError> { let version: Version = "0.8.10".parse()?; let path = blocking_install(&version)?; println!("Installed at: {}", path.display()); Ok(()) } // Parallel async installation is safe — file locking prevents corruption #[tokio::main] async fn parallel_install() -> Result<(), SvmError> { let v: Version = "0.8.10".parse()?; let v2 = v.clone(); let t = tokio::task::spawn(async move { install(&v2).await }); install(&v).await?; t.await.unwrap()?; Ok(()) } ``` -------------------------------- ### Install Solc Versions with svm CLI Source: https://context7.com/alloy-rs/svm-rs/llms.txt Use the `svm install` command to download and install one or more Solidity compiler versions. The `--non-interactive` flag is useful for CI/CD pipelines. ```sh svm install 0.8.26 svm install 0.8.26 0.8.10 0.7.6 svm install 0.8.26 --non-interactive # Expected output: # ╲ Installing Solc: 0.8.26 # Downloaded Solc: 0.8.26 # Setting 0.8.26 as the global version ``` -------------------------------- ### svm install Source: https://context7.com/alloy-rs/svm-rs/llms.txt Downloads and installs the specified solc version(s). It sets the global default if none is set and can prompt to switch the global version if one is already installed. Use `--non-interactive` for automated environments. ```APIDOC ## svm install ### Description Downloads and installs the specified `solc` version(s), sets the global default when none is set yet, and prompts to switch global version if already installed. Use `--non-interactive` for CI/CD pipelines. ### Usage ```sh # Install a single version svm install 0.8.26 # Install multiple versions at once svm install 0.8.26 0.8.10 0.7.6 # Non-interactive mode (no prompts, useful in CI) svm install 0.8.26 --non-interactive ``` ### Example Output ``` # Expected output: # ╠╴ Installing Solc: 0.8.26 # Downloaded Solc: 0.8.26 # Setting 0.8.26 as the global version ``` ``` -------------------------------- ### install / blocking_install Source: https://context7.com/alloy-rs/svm-rs/llms.txt Downloads the platform-appropriate `solc` binary, verifies its SHA-256 checksum, handles file locking for parallel installations, and returns the path to the installed binary. Uses a 10-minute HTTP timeout. The `blocking` variant requires the `blocking` feature flag. ```APIDOC ### `install` / `blocking_install` — Install a Solc version programmatically #### Description Downloads the platform-appropriate `solc` binary, verifies its SHA-256 checksum, handles file locking for parallel installations, and returns the path to the installed binary. Uses a 10-minute HTTP timeout. The `blocking` variant requires the `blocking` feature flag. #### Async Installation Example ```rust use semver::Version; use svm_rs::{install, SvmError}; #[tokio::main] async fn main() -> Result<(), SvmError> { let version: Version = "0.8.26".parse()?; // Install and get path to binary let solc_path = install(&version).await?; println!("Installed at: {}", solc_path.display()); // Output: Installed at: /home/user/.svm/0.8.26/solc-0.8.26 Ok(()) } ``` #### Blocking Installation Example ```rust // Blocking installation (requires feature = "blocking") #[cfg(feature = "blocking")] fn install_blocking() -> Result<(), SvmError> { use semver::Version; use svm_rs::blocking_install; let version: Version = "0.8.10".parse()?; let path = blocking_install(&version)?; println!("Installed at: {}", path.display()); Ok(()) } ``` #### Parallel Async Installation Example ```rust // Parallel async installation is safe — file locking prevents corruption #[tokio::main] async fn parallel_install() -> Result<(), SvmError> { use semver::Version; use svm_rs::install; let v: Version = "0.8.10".parse()?; let v2 = v.clone(); let t = tokio::task::spawn(async move { install(&v2).await }); install(&v).await?; t.await.unwrap()?; Ok(()) } ``` ``` -------------------------------- ### Install svm-rs from crates.io Source: https://github.com/alloy-rs/svm-rs/blob/master/crates/svm-rs/README.md Install the svm-rs tool directly from crates.io using cargo. ```sh cargo install svm-rs ``` -------------------------------- ### Install svm-rs with cargo-binstall Source: https://github.com/alloy-rs/svm-rs/blob/master/crates/svm-rs/README.md Use cargo-binstall for a quick installation of the svm-rs tool. ```sh cargo binstall svm-rs ``` -------------------------------- ### Install svm-rs from repository Source: https://github.com/alloy-rs/svm-rs/blob/master/crates/svm-rs/README.md Install the svm-rs tool from its Git repository, ensuring the locked version is used. ```sh cargo install --locked --git https://github.com/alloy-rs/svm-rs/ ``` -------------------------------- ### svm use Source: https://context7.com/alloy-rs/svm-rs/llms.txt Switches the active global Solc version. If the specified version is not yet installed, it will prompt the user to install it first. ```APIDOC ## svm use ### Description Switches the active global Solc version. If the version is not yet installed, prompts to install it first. ### Usage ```sh svm use 0.8.10 ``` ### Example Interaction (if not installed) ``` # If not installed, prompts: # Solc 0.8.10 is not installed # Would you like to install it? [Y/n]: Y # ╠╴ Installing Solc: 0.8.10 # Downloaded Solc: 0.8.10 # Setting 0.8.10 as the global version ``` ``` -------------------------------- ### Get Solc Binary Path with svm CLI Source: https://context7.com/alloy-rs/svm-rs/llms.txt The `svm which` command prints the filesystem path of the installed `solc` binary for a given version. It will error if the version is not installed. ```sh svm which 0.8.26 # Output: # /home/user/.svm/0.8.26/solc-0.8.26 svm which 0.7.0 # Error if not installed: # Error: version 0.7.0 not installed ``` -------------------------------- ### List Locally Installed Solc Versions Source: https://context7.com/alloy-rs/svm-rs/llms.txt Reads the SVM data directory to return a sorted list of all locally installed solc versions. ```rust use svm_rs::{installed_versions, SvmError}; fn main() -> Result<(), SvmError> { let versions = installed_versions()?; if versions.is_empty() { println!("No versions installed yet."); } else { println!("Installed versions:"); for v in &versions { println!(" {}", v); } // Output: // Installed versions: // 0.7.6 // 0.8.10 // 0.8.26 } Ok(()) } ``` -------------------------------- ### List Installed Solc Versions with svm CLI Source: https://context7.com/alloy-rs/svm-rs/llms.txt The `svm list` or `svm ls` command displays the current global version, all locally installed versions, and available versions for download. ```sh svm list # or the alias: svm ls # Expected output: # Current version: 0.8.26 # # Installed versions: # 0.8.10 # 0.8.26 # # Available versions: # 0.4.11 # 0.4.12 # ... # 0.8.35 ``` -------------------------------- ### installed_versions Source: https://context7.com/alloy-rs/svm-rs/llms.txt Reads the SVM data directory and returns a sorted list of all locally installed `solc` versions. ```APIDOC ## `installed_versions` — List locally installed versions ### Description Reads the SVM data directory and returns a sorted list of all locally installed `solc` versions. ### Method `installed_versions()` ### Parameters None ### Response - `Vec`: A sorted vector of locally installed Solc versions. ### Request Example ```rust use svm_rs::{installed_versions, SvmError}; fn main() -> Result<(), SvmError> { let versions = installed_versions()?; if versions.is_empty() { println!("No versions installed yet."); } else { println!("Installed versions:"); for v in &versions { println!(" {}", v); } } Ok(()) } ``` ### Response Example ``` Installed versions: 0.7.6 0.8.10 0.8.26 ``` ``` -------------------------------- ### Switch Global Solc Version with svm CLI Source: https://context7.com/alloy-rs/svm-rs/llms.txt Use `svm use` to set the global default Solidity compiler version. If the version is not installed, it will prompt to install it. ```sh svm use 0.8.10 # If not installed, prompts: # Solc 0.8.10 is not installed # Would you like to install it? [Y/n]: Y # ╲ Installing Solc: 0.8.10 # Downloaded Solc: 0.8.10 # Setting 0.8.10 as the global version ``` -------------------------------- ### svm which Source: https://context7.com/alloy-rs/svm-rs/llms.txt Prints the filesystem path of the installed `solc` binary for a given version. ```APIDOC ## svm which ### Description Prints the filesystem path of the installed `solc` binary for a given version. ### Usage ```sh svm which 0.8.26 ``` ### Example Output ``` # Output: # /home/user/.svm/0.8.26/solc-0.8.26 ``` ### Example Error Output ``` # svm which 0.7.0 # Error if not installed: # Error: version 0.7.0 not installed ``` ``` -------------------------------- ### svm remove Source: https://context7.com/alloy-rs/svm-rs/llms.txt Removes a specific installed Solc version or all installed versions. If the removed version is the active global version, the next most recent installed version is automatically set as the global version. An alias `svm rm` is available. ```APIDOC ## svm remove (`svm rm`) ### Description Removes a specific installed version or all installed versions. When the removed version is the active global, the next most-recent installed version is automatically set as global. ### Usage ```sh # Remove a specific version (prompts for confirmation) svm remove 0.8.10 # Are you sure? [Y/n]: Y # Remove all installed versions without prompts: svm remove all # Using the alias: svm rm 0.8.26 ``` ``` -------------------------------- ### svm list Source: https://context7.com/alloy-rs/svm-rs/llms.txt Displays the currently active global version, all locally installed versions, and all versions available for download for the current platform. An alias `svm ls` is also available. ```APIDOC ## svm list (`svm ls`) ### Description Displays the currently active global version, all locally installed versions, and all versions available for download for the current platform. ### Usage ```sh svm list # or the alias: svm ls ``` ### Example Output ``` # Expected output: # Current version: 0.8.26 # # Installed versions: # 0.8.10 # 0.8.26 # # Available versions: # 0.4.11 # 0.4.12 # ... # 0.8.35 ``` ``` -------------------------------- ### Remove Solc Versions with svm CLI Source: https://context7.com/alloy-rs/svm-rs/llms.txt Remove specific installed Solidity compiler versions using `svm remove` or `svm rm`. Use `svm remove all` to remove all installed versions. Confirmation prompts are shown for single version removal. ```sh # Remove a specific version (prompts for confirmation) svm remove 0.8.10 # Are you sure? [Y/n]: Y # Remove all installed versions without prompts: svm remove all # Using the alias: svm rm 0.8.26 ``` -------------------------------- ### Uninstall a Solc Version Source: https://context7.com/alloy-rs/svm-rs/llms.txt Removes the specified solc version directory from the SVM data directory. This operation requires the version to be installed first. ```rust use semver::Version; use svm_rs::{install, remove_version, installed_versions, SvmError}; #[tokio::main] async fn main() -> Result<(), SvmError> { let version: Version = "0.8.10".parse()?; // Install first install(&version).await?; assert!(installed_versions()?.contains(&version)); // Remove it remove_version(&version)?; assert!(!installed_versions()?.contains(&version)); println!("Removed solc {}", version); Ok(()) } ``` -------------------------------- ### Fetch All Available Solc Versions Source: https://context7.com/alloy-rs/svm-rs/llms.txt Fetches the complete list of available solc versions for the current platform. The `blocking_all_versions` variant requires the `blocking` feature flag. ```rust use svm_rs::{all_versions, blocking_all_versions, platform, SvmError}; #[tokio::main] async fn main() -> Result<(), SvmError> { let versions = all_versions().await?; println!("Total available: {}", versions.len()); // Output: Total available: 120 (varies by platform) // Get the latest available version if let Some(latest) = versions.last() { println!("Latest: {}", latest); // Output: Latest: 0.8.35 } // Check if a specific version exists let target: semver::Version = "0.8.26".parse()?; if versions.contains(&target) { println!("0.8.26 is available for this platform"); } Ok(()) } // Fetch releases for a specific platform (not the current host) #[tokio::main] async fn fetch_for_platform() -> Result<(), SvmError> { use svm_rs::{Platform, releases::all_releases}; let releases = all_releases(Platform::LinuxAarch64).await?; println!("Linux aarch64 versions: {}", releases.releases.len()); Ok(()) } ``` -------------------------------- ### Fetch Release Metadata with svm-rs Source: https://context7.com/alloy-rs/svm-rs/llms.txt Fetches the full release manifest for a given platform, including artifact filenames and checksums. Requires `semver` and `tokio` dependencies. Ensure `svm_rs` is included. ```rust use semver::Version; use svm_rs::{Platform, releases::all_releases, SvmError}; #[tokio::main] async fn main() -> Result<(), SvmError> { let releases = all_releases(Platform::LinuxAmd64).await?; // Check artifact filename for a specific version let version: Version = "0.8.26".parse()?; if let Some(artifact) = releases.get_artifact(&version) { println!("Artifact: {}", artifact); // Output: Artifact: solc-linux-amd64-v0.8.26+commit.8a97fa7a } // Get SHA-256 checksum bytes if let Some(checksum) = releases.get_checksum(&version) { println!("SHA-256: {}", hex::encode(&checksum)); } // Enumerate all available versions (sorted) let versions = releases.into_versions(); println!("First: {}, Last: {}", versions[0], versions.last().unwrap()); // Output: First: 0.4.0, Last: 0.8.35 Ok(()) } ``` -------------------------------- ### all_versions / blocking_all_versions Source: https://context7.com/alloy-rs/svm-rs/llms.txt Fetches the full list of available `solc` versions for the current platform from the official release list. Returns a sorted `Vec`. The `blocking` variant requires the `blocking` feature flag. ```APIDOC ## `all_versions` / `blocking_all_versions` — Fetch available versions ### Description Fetches the full list of available `solc` versions for the current platform from the official release list. Returns a sorted `Vec`. ### Method `all_versions()` (async) `blocking_all_versions()` (sync, requires `blocking` feature flag) ### Parameters None ### Response - `Vec`: A sorted vector of available Solc versions. ### Request Example ```rust use svm_rs::{all_versions, blocking_all_versions, platform, SvmError}; #[tokio::main] async fn main() -> Result<(), SvmError> { let versions = all_versions().await?; println!("Total available: {}", versions.len()); if let Some(latest) = versions.last() { println!("Latest: {}", latest); } Ok(()) } ``` ### Response Example ``` Total available: 120 (varies by platform) Latest: 0.8.35 ``` ``` -------------------------------- ### svm-rs CLI Usage Source: https://github.com/alloy-rs/svm-rs/blob/master/crates/svm-rs/README.md Overview of the available commands and options for the svm-rs command-line interface. Use this to manage Solidity compiler versions. ```sh Solc version manager Usage: svm Commands: help Print this message or the help of the given subcommand(s) install Install Solc versions [aliases: i] list List all Solc versions [aliases: ls] remove Remove a Solc version, or "all" to remove all versions [aliases: rm] use Set a Solc version as the global default which Display which binary will be run for a given version Options: -h, --help Print help -V, --version Print version ``` -------------------------------- ### SVM Path Utilities Source: https://context7.com/alloy-rs/svm-rs/llms.txt Provides utility functions to resolve filesystem paths for the SVM data directory, a specific version's directory, or its binary file. ```rust use svm_rs::{data_dir, version_path, version_binary}; fn main() { // SVM home directory: ~/.svm or $XDG_DATA_HOME/svm let home = data_dir(); println!("SVM home: {}", home.display()); // Output: SVM home: /home/user/.svm // Directory for a specific version: ~/.svm/0.8.26/ let dir = version_path("0.8.26"); println!("Version dir: {}", dir.display()); // Output: Version dir: /home/user/.svm/0.8.26 // Exact binary path: ~/.svm/0.8.26/solc-0.8.26 let bin = version_binary("0.8.26"); println!("Binary: {}", bin.display()); // Output: Binary: /home/user/.svm/0.8.26/solc-0.8.26 // Use the binary directly with std::process::Command let output = std::process::Command::new(bin) .arg("--version") .output() .expect("failed to run solc"); println!("{}", String::from_utf8_lossy(&output.stdout)); // Output: solc, the solidity compiler commandline interface // Version: 0.8.26+commit.8a97fa7a... } ``` -------------------------------- ### Detect and Parse Platform with svm-rs Source: https://context7.com/alloy-rs/svm-rs/llms.txt Detects the current host platform automatically or parses a platform string. Ensure the `svm_rs` crate is included in your dependencies. ```rust use svm_rs::{platform, Platform}; use std::str::FromStr; fn main() { // Detect the current platform automatically let current = platform(); println!("Current platform: {}", current); // Output (on Linux x86_64): Current platform: linux-amd64 // All supported platform variants: let platforms = [ Platform::LinuxAmd64, Platform::LinuxAarch64, Platform::MacOsAmd64, Platform::MacOsAarch64, Platform::WindowsAmd64, Platform::WindowsAarch64, Platform::AndroidAarch64, ]; for p in platforms { println!("{}", p); } // Parse from string let p = Platform::from_str("macosx-aarch64").unwrap(); assert_eq!(p, Platform::MacOsAarch64); } ``` -------------------------------- ### Manage Global Active Solc Version Source: https://context7.com/alloy-rs/svm-rs/llms.txt Provides functions to read, write, or clear the global active Solc version stored in `~/.svm/.global-version`. ```rust use semver::Version; use svm_rs::{get_global_version, set_global_version, unset_global_version, SvmError}; fn main() -> Result<(), SvmError> { // Read the current global version match get_global_version()? { Some(v) => println!("Global version: {}", v), None => println!("No global version set"), } // Set a new global version let version: Version = "0.8.26".parse()?; set_global_version(&version)?; println!("Set global version to 0.8.26"); // Re-read to confirm assert_eq!(get_global_version()?, Some(version)); // Clear the global version (e.g., after removing all installations) unset_global_version()?; assert_eq!(get_global_version()?, None); Ok(()) } ``` -------------------------------- ### version_binary / version_path / data_dir Source: https://context7.com/alloy-rs/svm-rs/llms.txt Utility functions to resolve filesystem paths for the SVM data directory, a specific version's directory, or its binary file. ```APIDOC ## `version_binary` / `version_path` / `data_dir` — Path utilities ### Description Resolve filesystem paths for the SVM data directory, a version's directory, or its binary file. ### Method `data_dir()` `version_path(version: &str)` `version_binary(version: &str)` ### Parameters - `version_path`: `version` (&str) - The Solc version string (e.g., "0.8.26"). - `version_binary`: `version` (&str) - The Solc version string (e.g., "0.8.26"). ### Response - `data_dir()`: `PathBuf` - Path to the SVM home directory. - `version_path(version)`: `PathBuf` - Path to the directory for the specified Solc version. - `version_binary(version)`: `PathBuf` - Path to the Solc binary for the specified version. ### Request Example ```rust use svm_rs::{data_dir, version_path, version_binary}; fn main() { let home = data_dir(); println!("SVM home: {}", home.display()); let dir = version_path("0.8.26"); println!("Version dir: {}", dir.display()); let bin = version_binary("0.8.26"); println!("Binary: {}", bin.display()); // Example of using the binary path: let output = std::process::Command::new(bin) .arg("--version") .output() .expect("failed to run solc"); println!("{}", String::from_utf8_lossy(&output.stdout)); } ``` ### Response Example ``` SVM home: /home/user/.svm Version dir: /home/user/.svm/0.8.26 Binary: /home/user/.svm/0.8.26/solc-0.8.26 solc, the solidity compiler commandline interface Version: 0.8.26+commit.8a97fa7a... ``` ``` -------------------------------- ### get_global_version / set_global_version / unset_global_version Source: https://context7.com/alloy-rs/svm-rs/llms.txt Manage the active version by reading, writing, or clearing the global active Solc version stored in `~/.svm/.global-version`. ```APIDOC ## `get_global_version` / `set_global_version` / `unset_global_version` — Manage the active version ### Description Read, write, or clear the global active Solc version stored in `~/.svm/.global-version`. ### Method `get_global_version()` `set_global_version(version: &semver::Version)` `unset_global_version()` ### Parameters - `set_global_version`: `version` (semver::Version) - The version to set as global. ### Response - `get_global_version()`: `Option` - The currently set global version, or `None` if not set. ### Request Example ```rust use semver::Version; use svm_rs::{get_global_version, set_global_version, unset_global_version, SvmError}; fn main() -> Result<(), SvmError> { match get_global_version()? { Some(v) => println!("Global version: {}", v), None => println!("No global version set"), } let version: Version = "0.8.26".parse()?; set_global_version(&version)?; println!("Set global version to 0.8.26"); unset_global_version()?; Ok(()) } ``` ### Response Example ``` Global version: 0.8.26 Set global version to 0.8.26 ``` ``` -------------------------------- ### remove_version Source: https://context7.com/alloy-rs/svm-rs/llms.txt Uninstalls a Solc version by removing its directory from the SVM data directory. ```APIDOC ## `remove_version` — Uninstall a Solc version ### Description Removes the version directory for the given version from the SVM data directory. ### Method `remove_version(version: &semver::Version)` ### Parameters - `version` (semver::Version) - The Solc version to remove. ### Request Example ```rust use semver::Version; use svm_rs::{install, remove_version, installed_versions, SvmError}; #[tokio::main] async fn main() -> Result<(), SvmError> { let version: Version = "0.8.10".parse()?; install(&version).await?; remove_version(&version)?; println!("Removed solc {}", version); Ok(()) } ``` ### Response None (throws `SvmError` on failure) ### Error Handling - `SvmError`: If the version is not found or an I/O error occurs during removal. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.