Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/viperproject/prusti-assistant
VS Code extension to verify Rust programs with the Prusti verifier.
https://github.com/viperproject/prusti-assistant
diagnostics prusti rust verification vscode-extension
Last synced: 3 months ago
JSON representation
VS Code extension to verify Rust programs with the Prusti verifier.
- Host: GitHub
- URL: https://github.com/viperproject/prusti-assistant
- Owner: viperproject
- License: mit
- Created: 2019-06-18T15:34:13.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-08-01T07:05:00.000Z (6 months ago)
- Last Synced: 2024-08-01T08:38:48.502Z (6 months ago)
- Topics: diagnostics, prusti, rust, verification, vscode-extension
- Language: TypeScript
- Homepage: http://prusti.org
- Size: 1.69 MB
- Stars: 22
- Watchers: 8
- Forks: 10
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
Prusti Assistant
================[![Latest published version for VS Code](https://img.shields.io/visual-studio-marketplace/v/viper-admin.prusti-assistant?label=VS%20Code)](https://marketplace.visualstudio.com/items?itemName=viper-admin.prusti-assistant)
[![Latest published version for Open VSX](https://img.shields.io/open-vsx/v/viper-admin/prusti-assistant?label=Open%20VSX)](https://open-vsx.org/extension/viper-admin/prusti-assistant)
[![Status of the "test and publish" job](https://github.com/viperproject/prusti-assistant/workflows/Test%20and%20publish/badge.svg)](https://github.com/viperproject/prusti-assistant/actions?query=workflow%3A"Test+and+publish"+branch%3Amaster)
[![Test coverage status](https://codecov.io/gh/viperproject/prusti-assistant/branch/master/graph/badge.svg?token=D4HOAD0KRU)](https://codecov.io/gh/viperproject/prusti-assistant)
[![Sonarcloud quality gate status](https://sonarcloud.io/api/project_badges/measure?project=viperproject_prusti-assistant&metric=alert_status)](https://sonarcloud.io/dashboard?id=viperproject_prusti-assistant)This Visual Studio Code extension provides interactive IDE features for verifying Rust programs with the [Prusti verifier](https://github.com/viperproject/prusti-dev).
For advanced use cases, consider switching to the [command-line version of Prusti](https://github.com/viperproject/prusti-dev).
## Screenshot
An example of how verification errors are reported by the extension:
![Screenshot](screenshot.png)
## Requirements
In order to use this extension, please install the following components:
* Java JDK version 11 or later, 64 bit. For example, [OpenJDK](https://jdk.java.net/).
* [Rustup version 1.23.0 or later](https://rustup.rs/). On Windows, this in turn requires the [Microsoft C++ Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/).If anything fails, check the "Troubleshooting" section below. Note that macOS running on M1 is currently not supported by this extension.
## First Usage
1. Install the requirements (listed above) and restart the IDE.
* This will ensure that programs like `rustup` are in the program path used by the IDE.
2. Install the ["Prusti Assistant"](https://marketplace.visualstudio.com/items?itemName=viper-admin.prusti-assistant) extension.
3. Open a Rust file to activate the extension.
* At its first activation, this extension will automatically download Prusti and install the required Rust toolchain.
4. Click on the "Prusti" button in the status bar.
* Alternativelly, you can run the `Prusti: verify the current crate or file` command.
* If the program is in a folder with a `Cargo.toml` file, Prusti will verify the crate in which the file is contained.
* If no `Cargo.toml` file can be found in a parent folder of the workspace, Prusti will verify the file as a standalone Rust program. No Cargo dependencies are allowed in this mode.
5. Follow the progress from the status bar.
* You should see a "Verifying crate [folder name]" or "Verifying file [name]" message while Prusti is running.
6. The result of the verification is reported in the status bar and in the "Problems" tab.
* You can open the "Problems" tab by clicking on Prusti's status bar.
* Be aware that the "Problems" tab is shared by all extensions. If you are not sure which extension generated which error, try disabling other extensions. (Related VS Code issue: [#51103](https://github.com/microsoft/vscode/issues/51103).)To update Prusti, run the command `Prusti: update verifier` in the command palette.
If anything fails, check the "Troubleshooting" section below.
## Features
### Commands
This extension provides the following commands:
* `Prusti: verify the current crate or file` to verify a Rust program. Clicking the "Prusti" button in the status bar runs this command.
* `Prusti: update verifier` to update Prusti.
* `Prusti: show version` to show the version of Prusti.
* `Prusti: restart Prusti server` to restart the Prusti server used by the extension.
* `Prusti: clear diagnostics` to clear all diagnostics generated by the extension.### Configuration
The main configuration options used by this extension are the following:
* `prusti-assistant.verifyOnSave`: Specifies if programs should be verified on save.
* `prusti-assistant.verifyOnOpen`: Specifies if programs should be verified when opened.
* `prusti-assistant.checkForUpdates`: Specifies if Prusti should check for updates at startup.
* `prusti-assistant.javaHome`: Specifies the path of the Java home folder. Leave empty to auto-detect it.
* `prusti-assistant.prustiVersion`: Allows to choose between the latest published Prusti version (the default), a fixed release specified as a GitHub tag (see the [list of releases](https://github.com/viperproject/prusti-dev/releases)), or a local build of Prusti.### Inline Code Diagnostics
This extension automatically provides inline diagnostics for Prusti errors.
### Snippets
Basic code-completion snippets are provided for Prusti annotations.
## Verification cache
By default, Prusti transparently caches verification requests. To clear the cache, it's enough to restart the Prusti server with the commands described above.
## Prusti verification flags
The verification flags of Prusti can be configured in a `Prusti.toml` file. Its location should be the following:
* When verifying a standalone Rust file, `Prusti.toml` should be placed in the same folder of the verified file.
* When verifying a Rust crate, `Prusti.toml` should be placed in the innermost folder that (1) contains a `Cargo.toml` file and (2) transitively contains the current active file in the IDE.In addition, due to a technical limitation the Prusti server reads its configuration flags from the `Prusti.toml` placed in the root of the IDE workspace (i.e. the navigation panel on the left). When modifying this file, it is necessary to manually restart the server. The server uses only a few of Prusti's flags, mainly to configure the verification cache and to decide whether to dump Viper files for debugging.
To check whether Prusti picked up the `Prusti.toml` that you wrote, try writing `make_prusti_crash=true` in it (or any other nonexistent configuration flag). When doing so, the IDE should report that Prusti crashed.
The list of the supported Prusti flags is available [here](https://viperproject.github.io/prusti-dev/dev-guide/config/flags.html), in Prusti's developer guide. Note that by setting these flags in the wrong way it is possible to get incorrect verification results. Many flags only exist of debugging reasons and to provide workarounds in selected cases.
## Troubleshooting
If Prusti fails to run, you can inspect Prusti's log from VS Code (View -> Output -> Prusti Assistant) and see if one of the following solutions applies to you.
| Problem | Solution |
|---------|----------|
| On Windows, Visual Studio is installed but the `rustup` installer still complains that the Microsoft C++ build tools are missing. | When asked which workloads to install in Visual Studio make sure "C++ build tools" is selected and that the Windows 10 SDK and the English language pack components are included. If the problem persists, check [this Microsoft guide](https://docs.microsoft.com/en-us/windows/dev-environment/rust/setup) and [this Rust guide](https://doc.rust-lang.org/book/ch01-01-installation.html#installing-rustup-on-windows). Then, restart the IDE. |
| The JVM is installed, but the extension cannot auto-detect it. | Open the settings of the IDE, search for "Prusti-assistant: Java Home" and manually set the path of the Java home folder. Alternatively, make sure that the `JAVA_HOME` environment variable is set in your OS. Then, restart the IDE. |
| Prusti crashes mentioning "Unexpected output of Z3" in the log. | Prusti is using an incompatible Z3 version. Make sure that the `Z3_EXE` environment variable is unset in your OS and in the settings of the extension. Then, restart the IDE. |
| `error[E0514]: found crate 'cfg_if' compiled by an incompatible version of rustc` | There is a conflict between Prusti and a previous Cargo compilation. Run `cargo clean` or manually delete the `target` folder. Then, rerun Prusti. |
| `error: the 'cargo' binary, normally provided by the 'cargo' component, is not applicable to the 'nightly-2021-09-20-x86_64-unknown-linux-gnu' toolchain`
or
`error[E0463]: can't find crate for std`
or
`error[E0463]: can't find crate for core` | The Rust toolchain installed by Rustup is probably corrupted (see issue [rustup/#2417](https://github.com/rust-lang/rustup/issues/2417)). [Uninstall](https://stackoverflow.com/questions/42322879/how-to-remove-rust-compiler-toolchains-with-rustup) the nightly toolchain mentioned in the error (or all installed nightly toolchains). Then, rerun Prusti. |
| `error: no override and no default toolchain set` | Rustup has probably been installed without the `default` toolchain. [Install it](https://stackoverflow.com/a/46864309/2491528), then rerun Prusti. |
| `libssl.so.1.1: cannot open shared object file: No such file or directory` on Ubuntu 22.04 | Ubuntu 22.04 deprecated `libssl1.1` and moved to `libssl3`. Consider [this solution](https://stackoverflow.com/a/72366805/2491528) as a temporary workaround to install `libssl1.1`, or compile Prusti from source code to make it use `libssl3`. |
| On macOS running on an M1 chip, the extension doesn't work and the log contains messages such as `incompatible architecture (have (arm64), need (x86_64))`. | We currently don't release precompiled arm64 binaries for macOS. Until we do so, the only option is to [compile Prusti from source code](https://github.com/viperproject/prusti-dev). |Thanks to @Pointerbender, @michaelpaper, @fcoury, @Gadiguibou, @djc for their help in reporting, debugging and solving many of these issues!
In case you still experience difficulties or encounter bugs while using Prusti Assistant, please [open an issue](https://github.com/viperproject/prusti-assistant/issues) or contact us in the [Zulip chat](https://prusti.zulipchat.com/).