Skip to content

Compilation error when adding CrabNebula DevTools as per documentation #3152

@caipeter888

Description

@caipeter888

Description:

Following the instructions at CrabNebula DevTools, I encountered a compilation error when integrating the devtools plugin.

Reproduction:

Using the code snippet provided in the documentation:

fn main() {
    #[cfg(debug_assertions)]
    let devtools = tauri_plugin_devtools::init(); // initialize the plugin as early as possible

    let mut builder = tauri::Builder::default();

    #[cfg(debug_assertions)]
    builder = builder.plugin(devtools); // then register it with Tauri

    builder
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

I receive the following error:

error[E0658]: attributes on expressions are experimental    
 --> src\main.rs:7:5
  |
7 |     #[cfg(debug_assertions)]
  |     ^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information

For more information about this error, try `rustc --explain E0658`.
error: could not compile `tauri-app` (bin "tauri-app") due to 1 previous error

Workaround:

I found that modifying the code by wrapping the affected assignment in a block allows the code to compile successfully. The updated code is:

fn main() {
    #[cfg(debug_assertions)]
    let devtools = tauri_plugin_devtools::init(); // initialize the plugin as early as possible

    let mut builder = tauri::Builder::default();

    #[cfg(debug_assertions)]
    {
        builder = builder.plugin(devtools); // then register it with Tauri
    }

    builder
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

After this change, the application builds and runs correctly, with the output indicating that Tauri Devtools v2.0.0 is running locally.

Full tauri info output:

$ tauri info

[✔] Environment
    - OS: Windows 10.0.26100 x86_64 (X64)
    ✔ WebView2: 132.0.2957.140
    ✔ MSVC: Visual Studio 生成工具 2022
    ✔ rustc: 1.84.1 (e71f9a9a9 2025-01-27)
    ✔ cargo: 1.84.1 (66221abde 2024-11-19)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 23.7.0
    - pnpm: 10.1.0
    - yarn: 1.22.22
    - npm: 10.8.0
    - bun: 1.2.2

[-] Packages
    - tauri 🦀: 2.2.5
    - tauri-build 🦀: 2.0.5
    - wry 🦀: 0.48.1
    - tao 🦀: 0.31.1
    - @tauri-apps/api : 2.2.0
    - @tauri-apps/cli : 2.2.7

[-] Plugins
    - tauri-plugin-opener 🦀: 2.2.5
    - @tauri-apps/plugin-opener : 2.2.5

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - framework: Vue.js
    - bundler: Vite

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugDoes it fix inaccurate content or fix a bug?good first issueIs it good for beginners to take up?

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions