|
| 1 | +# Fix for Issue #63: Version Mismatch in Windows Binary |
| 2 | + |
| 3 | +## Problem Analysis |
| 4 | +The user reported downloading "shimmy 1.4.2" which shows version "0.1.0" and lacks the `gpu-info` command. Investigation reveals: |
| 5 | + |
| 6 | +1. **No v1.4.2 tag exists** - latest was v1.4.1, current is v1.5.5 |
| 7 | +2. The binary was likely built from an incorrect source or development state |
| 8 | +3. Version 0.1.0 suggests it was built from a very early commit or with corrupted build environment |
| 9 | + |
| 10 | +## Root Cause |
| 11 | +The issue stems from the binary being built without proper Cargo.toml version information being embedded. This can happen when: |
| 12 | +- Building from a source without proper Cargo.toml |
| 13 | +- Build environment not setting CARGO_PKG_VERSION correctly |
| 14 | +- Building from a Git worktree or modified state |
| 15 | + |
| 16 | +## Comprehensive Fix |
| 17 | + |
| 18 | +### 1. Version Validation at Build Time |
| 19 | +Create a build script that validates version consistency: |
| 20 | + |
| 21 | +```rust |
| 22 | +// build.rs |
| 23 | +fn main() { |
| 24 | + // Ensure version is not default |
| 25 | + let version = env!("CARGO_PKG_VERSION"); |
| 26 | + if version == "0.1.0" || version.is_empty() { |
| 27 | + panic!("Invalid version detected: {}. Check Cargo.toml", version); |
| 28 | + } |
| 29 | + |
| 30 | + // Validate semantic versioning |
| 31 | + let parts: Vec<&str> = version.split('.').collect(); |
| 32 | + if parts.len() < 3 { |
| 33 | + panic!("Version must follow semantic versioning: {}", version); |
| 34 | + } |
| 35 | + |
| 36 | + println!("cargo:rustc-env=SHIMMY_BUILD_VERSION={}", version); |
| 37 | + println!("cargo:rerun-if-changed=Cargo.toml"); |
| 38 | +} |
| 39 | +``` |
| 40 | + |
| 41 | +### 2. Runtime Version Verification |
| 42 | +Add version verification in main.rs: |
| 43 | + |
| 44 | +```rust |
| 45 | +fn verify_build_version() { |
| 46 | + let cargo_version = env!("CARGO_PKG_VERSION"); |
| 47 | + let build_version = env!("SHIMMY_BUILD_VERSION"); |
| 48 | + |
| 49 | + if cargo_version != build_version { |
| 50 | + eprintln!("Warning: Version mismatch detected!"); |
| 51 | + eprintln!(" Cargo version: {}", cargo_version); |
| 52 | + eprintln!(" Build version: {}", build_version); |
| 53 | + } |
| 54 | + |
| 55 | + if cargo_version == "0.1.0" { |
| 56 | + eprintln!("ERROR: Invalid default version detected!"); |
| 57 | + eprintln!("This binary was built incorrectly. Please download from official releases."); |
| 58 | + std::process::exit(1); |
| 59 | + } |
| 60 | +} |
| 61 | +``` |
| 62 | + |
| 63 | +### 3. Enhanced CLI with Version Validation |
| 64 | +Update CLI to include build information: |
| 65 | + |
| 66 | +```rust |
| 67 | +#[derive(Parser, Debug)] |
| 68 | +#[command( |
| 69 | + name = "shimmy", |
| 70 | + version = concat!(env!("CARGO_PKG_VERSION"), " (", env!("SHIMMY_BUILD_VERSION"), ")"), |
| 71 | + about = "Shimmy: single-binary GGUF + LoRA server" |
| 72 | +)] |
| 73 | +pub struct Cli { |
| 74 | + // ... existing fields |
| 75 | +} |
| 76 | +``` |
| 77 | + |
| 78 | +## Implementation for Backporting |
| 79 | + |
| 80 | +Since developers are forking at various stages, here's a minimal fix that can be applied to any version: |
| 81 | + |
| 82 | +### Minimal Fix (backport-friendly) |
| 83 | +1. Add version check in main(): |
| 84 | +```rust |
| 85 | +fn main() { |
| 86 | + // Version safety check - prevents 0.1.0 releases |
| 87 | + let version = env!("CARGO_PKG_VERSION"); |
| 88 | + if version == "0.1.0" { |
| 89 | + eprintln!("ERROR: This binary has incorrect version information."); |
| 90 | + eprintln!("Please rebuild from clean source or download official release."); |
| 91 | + std::process::exit(1); |
| 92 | + } |
| 93 | + |
| 94 | + // ... rest of main |
| 95 | +} |
| 96 | +``` |
| 97 | + |
| 98 | +2. Ensure Cargo.toml has correct version before building |
| 99 | +3. Add regression test to catch this in CI |
| 100 | + |
| 101 | +## For Release Process |
| 102 | +1. Always build from tagged commits |
| 103 | +2. Verify `cargo --version` output before publishing |
| 104 | +3. Include version verification in CI/CD |
| 105 | +4. Test binary version output before release |
| 106 | + |
| 107 | +## Immediate Action |
| 108 | +1. **Close Issue #63** with explanation that v1.4.2 was never officially released |
| 109 | +2. **Recommend users download from official releases** (v1.4.1 or latest v1.5.5) |
| 110 | +3. **Add build verification** to prevent future occurrences |
| 111 | +4. **Create proper v1.4.2 tag** if needed for compatibility |
| 112 | + |
| 113 | +## For Forkers |
| 114 | +If you're forking shimmy, ensure: |
| 115 | +1. Update version in Cargo.toml for your fork |
| 116 | +2. Build from clean Git state |
| 117 | +3. Test `./shimmy -V` before distributing |
| 118 | +4. Consider adding the version verification code above |
0 commit comments