Files
shopify-ai-backup/DESKTOP_BUILD_FIX_SUMMARY.md

166 lines
5.2 KiB
Markdown

# Desktop Build Fix Summary
## Problem
The Windows desktop build was failing in GitHub Actions with the error:
```
Error Input watch path is neither a file nor a directory.
```
This error occurred after the UI preparation step completed successfully, indicating that Tauri couldn't find the expected UI distribution directory.
## Root Causes Identified
1. **Incorrect distDir path**: `tauri.conf.json` specified `"distDir": "../ui-dist"` which pointed to the wrong location
- Expected: `/home/engine/project/ui-dist`
- Actual: `/home/engine/project/windows-app/ui-dist`
2. **Missing build.rs**: Tauri requires a `build.rs` file in the src-tauri directory to generate necessary build artifacts
3. **Incompatible tauri-plugin-store dependency**: The plugin version `0.6` is incompatible with Tauri 1.5 (v0.6 doesn't exist, only v2.x which is for Tauri v2)
4. **Missing tauri-build dependency**: The Cargo.toml was missing the required `tauri-build` in `[build-dependencies]`
## Changes Made
### 1. Fixed tauri.conf.json
**File**: `windows-app/tauri.conf.json`
- Changed `"distDir": "../ui-dist"` to `"distDir": "./ui-dist"`
- This ensures Tauri looks for the UI in the correct location relative to the tauri.conf.json file
### 2. Created build.rs
**File**: `windows-app/src-tauri/build.rs` (NEW)
```rust
fn main() {
tauri_build::build()
}
```
- Required by Tauri to generate build-time configuration and resources
### 3. Updated Cargo.toml
**File**: `windows-app/src-tauri/Cargo.toml`
**Removed**:
- `tauri-plugin-store = "0.6"` from dependencies
- `features = ["api-all"]` from tauri dependency (to avoid potential issues)
**Added**:
- `tauri-build = { version = "1.5", features = [] }` in `[build-dependencies]`
- Updated features to properly reference tauri:
```toml
[features]
default = ["custom-protocol"]
custom-protocol = ["tauri/custom-protocol"]
```
**Final dependencies**:
```toml
[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
anyhow = "1.0"
reqwest = { version = "0.11", features = ["json", "rustls-tls"] }
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
tauri = { version = "1.5", features = [] }
[build-dependencies]
tauri-build = { version = "1.5", features = [] }
```
### 4. Replaced tauri-plugin-store with Custom Implementation
**File**: `windows-app/src-tauri/src/main.rs`
**Removed**:
- `use tauri_plugin_store::StoreBuilder;`
- `.plugin(tauri_plugin_store::Builder::default().build())` from main()
**Added**:
- Custom `SecureStore` struct that implements file-based JSON storage:
```rust
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
struct SecureStore {
data: HashMap<String, String>,
}
```
- Implements async `load()`, `save()`, `get()`, and `insert()` methods
- Changed store file from `secure.store` to `secure.json`
- Maintains same API surface for the rest of the application
**Benefits**:
- No external plugin dependencies
- Simpler, more maintainable code
- Same functionality as before
- Works with Tauri 1.5 without version conflicts
### 5. Generated Cargo.lock
**File**: `windows-app/src-tauri/Cargo.lock` (NEW)
- Generated with `cargo generate-lockfile`
- Ensures consistent dependency versions across builds
- GitHub Actions cache now properly uses this for cache key
## GitHub Actions Workflow
**File**: `.github/workflows/windows-app.yml`
The workflow was already well-structured and didn't require changes. It now properly:
1. Checks out the code
2. Sets up Node.js and Rust
3. Caches cargo dependencies using Cargo.lock
4. Installs npm dependencies
5. Verifies UI source exists
6. Prepares UI with `npm run prepare-ui`
7. Verifies UI dist was created
8. Builds the desktop app with `npm run build`
9. Uploads build artifacts
## Testing
The changes were designed to be minimal and focused on fixing the specific build issues:
- The UI preparation script (`sync-ui.js`) remains unchanged
- The application logic in main.rs remains functionally identical
- Only the storage backend was changed from plugin to custom implementation
- All Tauri commands remain the same
## Expected Results
With these changes, the Windows build in GitHub Actions should:
1. ✅ Successfully find the UI distribution directory
2. ✅ Compile without dependency conflicts
3. ✅ Generate all required build artifacts
4. ✅ Produce Windows installer files (NSIS and MSI)
5. ✅ Upload artifacts for download
## Notes for Future Maintenance
1. **Tauri Version**: Currently using Tauri 1.5. If upgrading to Tauri 2.x in the future:
- Update Cargo.toml dependencies
- Re-evaluate tauri-plugin-store (v2.x is compatible with Tauri 2.x)
- Review tauri.conf.json schema changes
- Update GitHub Actions workflow if needed
2. **Custom SecureStore**: The current implementation is simple and adequate. For enhanced security:
- Consider encrypting the JSON file at rest
- Use OS keychain/credential manager integration
- Implement proper file permissions checks
3. **Dependencies**: Keep an eye on:
- Tauri security updates
- Rust toolchain updates
- WebView2 runtime updates on Windows
## Build Command
To build locally (on Windows):
```bash
cd windows-app
npm install
npm run prepare-ui
npm run build
```
To run in development mode:
```bash
cd windows-app
npm install
npm run prepare-ui
npm run dev
```