Skip to content

Instantly share code, notes, and snippets.

@deanmlittle
Last active August 25, 2024 15:53
Show Gist options
  • Save deanmlittle/1feddf18a00cbe95bf62b72937f0a553 to your computer and use it in GitHub Desktop.
Save deanmlittle/1feddf18a00cbe95bf62b72937f0a553 to your computer and use it in GitHub Desktop.
Make Rust Analyzer recognize target_os="solana"

To make Rust analyzer target target_os="solana" try the following:

  1. Find active_release_dir from your config file with cat ~/.config/solana/install/config.yml (or whatever your config directory is)
  2. Create a .vscode/settings.json file in your project workspace and add the following:
{
    "rust-analyzer.cargo.target": "sbf-solana-solana",
    "rust-analyzer.cargo.extraEnv": {
        "CARGO": "<your_active_release_directory>/bin/sdk/sbf/dependencies/platform-tools/rust/bin/cargo",
        "RUSTC": "<your_active_release_directory>/bin/sdk/sbf/dependencies/platform-tools/rust/bin/rustc"
    }
}

Rust analyzer should now successfully target target_os="solana"!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment