Troubleshooting
Relevant source files
The following files were used as context for generating this wiki page:This document provides guidance for diagnosing and resolving common issues encountered during the development, building, and operation of the Scripty application. It covers problems related to the development environment, backend Rust services, frontend React components, data persistence, and the auto-updater mechanism. The application is built using Tauri, React, and Vite, and understanding the interaction between these technologies is key to effective troubleshooting.
Build and Development Environment
Issues in this area typically stem from misconfigurations in the Vite development server, Tauri build commands, or dependency mismatches.
Key Configuration Files
| File | Purpose |
|---|---|
package.json | Defines Node.js dependencies (react, vite, @tauri-apps/api) and scripts (dev, build, tauri). |
vite.config.js | Configures the Vite development server, including port, HMR (Hot Module Replacement), and build-specific options. |
tauri.conf.json | Configures the Tauri application, including build commands, window properties, plugins, and the auto-updater. |
src-tauri/Cargo.toml | Defines Rust dependencies (crates) for the Tauri backend, such as tauri, serde, and various Tauri plugins. |
Sources: package.json, vite.config.js, src-tauri/tauri.conf.json, src-tauri/Cargo.toml
Common Problems
-
Port Conflict: The Vite server may fail to start if the configured port is in use.
- Symptom: Error message in the console indicating "port 1420 is already in use".
- Solution: The
vite.config.jsis set tostrictPort: true, which will cause Vite to exit if the port is unavailable. Ensure no other processes are using port1420. - Sources: vite.config.js:20-21
-
Rust Errors Obscured: Vite might hide compilation errors from the Rust backend.
- Symptom: The frontend loads, but backend calls fail silently or the app crashes without clear Rust error logs.
- Solution: The
vite.config.jssetsclearScreen: falseto prevent Vite from clearing the console, ensuring Rust errors are visible. - Sources: vite.config.js:17
-
Incorrect Build Commands: The Tauri build process relies on commands specified in
tauri.conf.json.- Symptom:
tauri buildfails with an error related tonpm run build. - Solution: Verify that the
beforeBuildCommand(npm run build) andbeforeDevCommand(npm run dev) are correctly defined and that the corresponding scripts exist inpackage.json. - Sources: src-tauri/tauri.conf.json:8,10, package.json:6,8
- Symptom:
The diagram below illustrates the development startup flow.
This diagram shows the sequence of commands when starting the development environment.
Sources: src-tauri/tauri.conf.json:8, package.json:6, vite.config.js:20
Backend (Rust/Tauri) Issues
The backend is responsible for interacting with the operating system, primarily by executing PowerShell commands.
Tauri Commands
The lib.rs file exposes several functions to the frontend via the Tauri invoke mechanism.
| Command | Parameters | Description |
|---|---|---|
open_terminal | content: String | Spawns a new PowerShell instance and executes the provided command string. Runs as the current user. |
open_admin_terminal | content: String | Spawns a new PowerShell instance with administrator privileges to execute the command. |
run_sys_terminal | content: String | Extracts an embedded syspwsh.exe and uses it to run a command as the SYSTEM user. |
read_ps1 | path: String | Reads the content of a .ps1 file from the specified path and returns it to the frontend. |
Sources: src-tauri/src/lib.rs:29-62
Common Problems
-
"Failed to start elevated PowerShell":
- Symptom: The
open_admin_terminalcommand fails. This typically happens if the User Account Control (UAC) prompt is denied or if there's a policy preventing elevation. - Solution: Ensure the user accepts the UAC prompt. Check system security policies. The command constructs a
Start-Processcall with the-Verb RunAsargument. - Sources: src-tauri/src/lib.rs:36-46
- Symptom: The
-
"Failed to resolve the .ps1 file":
- Symptom: When adding a new script, the application shows an error dialog.
- Solution: This error is returned by the
read_ps1Rust command whenfs::read_to_stringfails. This indicates the file path provided by the frontend's open-file dialog is invalid or the file is unreadable. The frontend displays a "File nicht gefunden" message. - Sources: src-tauri/src/lib.rs:60-63, src/components/Form/Form.jsx:24-27
-
syspwsh.exeExtraction Fails:- Symptom: The
run_sys_terminalcommand fails. - Solution: This command relies on extracting an embedded executable to the user's temporary directory (
env::temp_dir()). This can fail due to lack of permissions to write to the temp directory. The function checks if the file exists before writing. - Sources: src-tauri/src/lib.rs:11-20
- Symptom: The
The following diagram shows the sequence of a frontend component invoking a backend command.
This sequence shows how the DetailView component runs a script with admin rights.
Sources: src/components/DetailView/DetailView.jsx:21-23, src-tauri/src/lib.rs:36-46
Data Persistence
Script data (items and tags) is managed by Zustand and persisted to a JSON file on the local disk using @tauri-apps/plugin-fs.
Storage Mechanism
- State Management:
useListStore(a Zustand store) holds theitemsandtagsin memory. - Persistence: The
persistmiddleware from Zustand is used to save the state. - Storage Location: A custom storage object is implemented that uses
readTextFileandwriteTextFilefrom the Tauri FS plugin. The data is saved toscriptStorage.jsoninside the application's data directory (appDataDir).
Sources: src/Hooks/useListStore.js:1-50
The following code snippet defines the custom file storage interface for Zustand.
// src/Hooks/useListStore.js:13-27
const fileStorage = {
getItem: async (_) => {
const path = await getFileStorePath();
if (!(await exists(path))) return null;
return await readTextFile(path);
},
setItem: async (_, value) => {
const path = await getFileStorePath();
await writeTextFile(path, value);
},
removeItem: async (_) => {
const path = await getFileStorePath();
await writeTextFile(path, "");
},
};
Common Problems
-
Scripts not saving between sessions:
- Symptom: Added scripts are gone after restarting the application.
- Solution: This indicates a problem with the
setItemfunction infileStorage. Check the application's permissions. Thedefault.jsoncapability file must grant appropriatefspermissions, such asfs:allow-appdata-writeandfs:allow-write-text-file. Also, check for errors in the developer console related to file system access. - Sources: src/Hooks/useListStore.js:20-23, src-tauri/capabilities/default.json:17, 68
-
Corrupted
scriptStorage.json:- Symptom: The application fails to load, crashes on start, or displays no scripts.
- Solution: The
getItemfunction reads the file content. If the JSON is malformed,JSON.parse(used internally by Zustand's middleware) will fail. Manually locate thescriptStorage.jsonfile in the path returned byappDataDirand either fix the JSON structure or delete it to let the application create a new one. - Sources: src/Hooks/useListStore.js:14-18
Auto-Updater
The application includes an auto-updater configured via tauri.conf.json and invoked in App.jsx.
Configuration and Flow
- Enabled: The updater is activated in
tauri.conf.json. - Public Key: A
pubkeyis required to verify the signature of the update manifest. - Endpoint: The updater checks for a
latest.jsonfile at the specified URL.
// src-tauri/tauri.conf.json:49-56
"updater": {
"active": true,
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDQxRURENUVBNzg3NzAzMzUKUldRMUEzZDQ2dFh0UVl3VGRodXNtRmNWV2VFUkZpWWo0TWpnZXVMZ05XLzhYb0hkU1hPUng5NEYK",
"endpoints": [
"https://github.com/SemtexHR/ScriptTool/releases/latest/download/latest.json%22
]
}
The update check is performed on application startup.
// src/App.jsx:14-15
const update = await check();
if (update) {
// ... download and install logic
}
Common Problems
-
Update Check Fails:
- Symptom: The app never prompts for an update, even when a new version is available.
- Solution:
- Verify the
endpointsURL intauri.conf.jsonis correct and reachable. - Ensure the
pubkeymatches the key used to sign the update artifacts. - Check the developer console for network errors or errors from the
@tauri-apps/plugin-updater.
- Verify the
- Sources: src-tauri/tauri.conf.json:49-56, src/App.jsx:14
-
Download Fails or Gets Stuck:
- Symptom: The update is found, but the download progress hangs or fails.
- Solution: The
downloadAndInstallcallback provides progress events. Useconsole.logwithin this callback to debug the download progress (Started,Progress,Finished). This can help identify if the download starts at all or where it stops. Network issues or firewalls could be blocking the download. - Sources: src/App.jsx:21-34