tauri: [bug] nixos/nix development shell: Opening devtools does not work

Describe the bug

Hitting Ctrl+Shift+i does not bring up the devtools. Also

.setup(|app| {
    #[cfg(debug_assertions)] // only include this code on debug builds
    {
      let window = app.get_window("main").unwrap();
      window.open_devtools();
    }
    Ok(())
  })

Does not open them.

I get

(distrox:1399333): GLib-GIO-CRITICAL **: 13:57:35.131: g_settings_schema_source_lookup: assertion 'source != NULL' failed                                                                                                                                                                                                      
VM 0x7fb356406000 on pid 1399344 received NeedDebuggerBreak trap   

In the console running cargo tauri dev when hitting above key combination though. Not sure what that means.

Reproduction

#![cfg_attr(
  all(not(debug_assertions), target_os = "windows"),
  windows_subsystem = "windows"
)]

use tauri::Manager;

fn main() {
  tauri::Builder::default()
    .setup(|app| {
        let window = app.get_window("main").unwrap();
        window.open_devtools();
        Ok(())
    })
    .run(tauri::generate_context!())
    .expect("error while running tauri application");
}

Expected behavior

devtools open.

Platform and versions

Environment
› OS: NixOS 22.5.0 X64
› Node.js: 16.17.1
› npm: 8.15.0
› pnpm: Not installed!
› yarn: Not installed!
› rustup: Not installed!
› rustc: 1.65.0
› cargo: 1.65.0
› Rust toolchain:

Packages
WARNING: no lock files found, defaulting to npm
@tauri-apps/cli [NPM]: 1.2.1
@tauri-apps/api [NPM]: Not installed!
› tauri [RUST]: 1.2.1,
› tauri-build [RUST]: 1.2.1,
› tao [RUST]: 0.15.6,
› wry [RUST]: 0.22.5,

App
› build-type: bundle
› CSP: unset
› distDir: …/frontend/dist
› devPath: http://localhost:8080/
package.json not found

App directory structure
├─ types
├─ src-tauri
└─ frontend

Stack trace

No response

Additional context

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (8 by maintainers)

Most upvoted comments

I found the missing pieces: https://github.com/matthiasbeyer/distrox/pull/73/files#diff-206b9ce276ab5971a2489d75eb1b12999d4bf3843b7988cbe8d687cfde61dea0R110-R122

For the lazy: Add this to your mkShell:

{
  XDG_DATA_DIRS = let                                                                                                                                                                                                                                                                                                
    base = pkgs.lib.concatMapStringsSep ":" (x: "${x}/share") [                                                                                                                                                                                                                                                      
      pkgs.gnome.adwaita-icon-theme                                                                                                                                                                                                                                                                                  
      pkgs.shared-mime-info                                                                                                                                                                                                                                                                                          
    ];
    gsettings_schema = pkgs.lib.concatMapStringsSep ":" (x: "${x}/share/gsettings-schemas/${x.name}") [
      pkgs.glib
      pkgs.gsettings-desktop-schemas
      pkgs.gtk3
    ];
  in "${base}:${gsettings_schema}";
}

For all that stumble over this issue: After literally hours of trying, I finally found the issue.

The mkShell for building the nix shell hides XDG_DATA_DIRS from the host environment (of course). My XDG_DATA_DIRS from host is quite massive (because KDE), and I couldn’t make out the relevant part that makes it work besides /run/current-system/sw/share. Adding that inside the nix shell environment (in a shellHook) makes the devtools work for me.

That’s of course ugly and impure, but that’s all I’ve got so far. If someone knows what the exact culprint is and what I need to add to the environment to make it work without this ugly hack, please do comment here or somewhere visible for others running into this issue.

I consider this issue closed.

Honestly I don’t know. I stepped away from using tauri because of the massive pain it caused me…

Ah, okay. I just edited it in.

btw this is a NixOS specific problem and just like all other NixOS specific problems i have no idea how to fix it…

for what it’s worth, it reacts to right click -> inspect but it doesn’t open the devtools and instead shows some unparsed html.