Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Unable to use float values in tauri.conf.json for plugin configuration #8252

Closed
jamesWalker55 opened this issue Nov 18, 2023 · 0 comments
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@jamesWalker55
Copy link

jamesWalker55 commented Nov 18, 2023

Describe the bug

When writing a plugin, you can provide configurations through tauri.conf.json in the "plugins" section, e.g.:

{
  "build": {...},
  "package": {...},
  "tauri": {...},
  "plugins": {
    "configPlugin": {
      "audioPreview": { "enabled": true, "volume": 0.5 },
      ...
    }
  }
}

However, when the plugin section includes a float literal (e.g. 0.5), building fails with the following error:

error[E0277]: the trait bound `serde_json::Number: std::convert::From<f64>` is not satisfied
   --> src-tauri\src\main.rs:541:14
    |
541 |         .run(tauri::generate_context!())
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From<f64>` is not implemented for `serde_json::Number`
    |
    = help: the following other types implement trait `std::convert::From<T>`:
              <serde_json::Number as std::convert::From<isize>>
              <serde_json::Number as std::convert::From<i8>>
              <serde_json::Number as std::convert::From<i16>>
              <serde_json::Number as std::convert::From<i32>>
              <serde_json::Number as std::convert::From<i64>>
              <serde_json::Number as std::convert::From<usize>>
              <serde_json::Number as std::convert::From<u8>>
              <serde_json::Number as std::convert::From<u16>>
            and 3 others
    = note: required for `f64` to implement `std::convert::Into<serde_json::Number>`
    = note: this error originates in the macro `tauri::generate_context` (in Nightly builds, run with -Z macro-backtrace for more info)

Reproduction

In a Tauri application, fill the tauri.conf.json's "plugins" section with an arbitrary plugin name, containing a float value somewhere in it, e.g.

  "plugins": {
    "configPlugin": {
      "audioPreview": { "enabled": true, "volume": 0.5 },
      ...
    }
  }

Expected behavior

Building succeeds.

Platform and versions

[✔] Environment
    - OS: Windows 10.0.19045 X64
    ✔ WebView2: 119.0.2151.58
    ✔ MSVC: Visual Studio Build Tools 2019
    ✔ rustc: 1.73.0 (cc66ad468 2023-10-03)
    ✔ cargo: 1.73.0 (9c4383fb5 2023-08-26)
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 21.1.0
    - pnpm: 8.10.5
    - yarn: 1.22.19
    - npm: 10.2.0

[-] Packages
    - tauri [RUST]: 1.2.4
    - tauri-build [RUST]: 1.2.1
    - wry [RUST]: 0.23.4
    - tao [RUST]: 0.15.8
    - @tauri-apps/api [NPM]: 1.5.1
    - @tauri-apps/cli [NPM]: 1.5.6

[-] App

Stack trace

error[E0277]: the trait bound `serde_json::Number: std::convert::From<f64>` is not satisfied
   --> src-tauri\src\main.rs:541:14
    |
541 |         .run(tauri::generate_context!())
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From<f64>` is not implemented for `serde_json::Number`
    |
    = help: the following other types implement trait `std::convert::From<T>`:
              <serde_json::Number as std::convert::From<isize>>
              <serde_json::Number as std::convert::From<i8>>
              <serde_json::Number as std::convert::From<i16>>
              <serde_json::Number as std::convert::From<i32>>
              <serde_json::Number as std::convert::From<i64>>
              <serde_json::Number as std::convert::From<usize>>
              <serde_json::Number as std::convert::From<u8>>
              <serde_json::Number as std::convert::From<u16>>
            and 3 others
    = note: required for `f64` to implement `std::convert::Into<serde_json::Number>`
    = note: this error originates in the macro `tauri::generate_context` (in Nightly builds, run with -Z macro-backtrace for more info)

Additional context

No response

@jamesWalker55 jamesWalker55 added status: needs triage This issue needs to triage, applied to new issues type: bug labels Nov 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
Development

No branches or pull requests

1 participant