Repository navigation
update: explain the manual Windows update instead of failing on Unix paths #3
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
base: main
Are you sure you want to change the base?
Changes from all commits
3066bb2
92a28dd
af2f6b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -143,7 +143,50 @@ fn suggestion(cache: &Cache, args: &[std::ffi::OsString], interactive: bool) -> | |
| .latest | ||
| .as_ref() | ||
| .filter(|latest| newer(latest)) | ||
| .map(|latest| format!("proofline {latest} is available; run 'proofline update'")) | ||
| .map(|latest| notice(latest, cfg!(target_os = "windows"))) | ||
|
Comment on lines
143
to
+146
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Warning · Windows update link can serve an older release than the notice The Windows notice advertises the discovery version, but Users can verify and reinstall an older binary without getting the advertised update. Link to version-pinned downloads for the advertised release, or tell users to confirm the release version before replacing their binary.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 92a28dd. Confirmed in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Marked fixed.
Comment on lines
143
to
+146
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Warning · Notice tests miss Windows falling back to Unix wording The new tests call The tests would pass if Assert platform-specific wording from the cached invocation and run that test on Windows.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 92a28dd. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Marked fixed. |
||
| } | ||
|
|
||
| fn notice(latest: &str, windows: bool) -> String { | ||
|
Comment on lines
+146
to
+149
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Warning · CI misses regressions to Unix-only update notices on Windows The routing assertions use the test runner’s platform. Only Ubuntu runs them in CI; the Windows smoke job never checks a cached update notice. CI stays green if Run A person accepted this risk earlier. It is posted again because it cites new evidence: Also at:
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. accept risk There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accepted as a risk. |
||
| if windows { | ||
| format!("proofline {latest} is available; 'proofline update' shows how to install it") | ||
| } else { | ||
| format!("proofline {latest} is available; run 'proofline update'") | ||
| } | ||
| } | ||
|
|
||
| /// The README's verified manual update: self-update cannot replace a Windows | ||
| /// binary, and Windows has no Unix installer directory to check. | ||
| /// `latest` is the cached version the notice announced; its pinned downloads | ||
| /// exist before GitHub marks that release as the latest one. | ||
| fn windows_steps(executable: Option<&Path>, latest: Option<&str>) -> String { | ||
| const ARCHIVE: &str = "proofline-x86_64-pc-windows-msvc.tar.gz"; | ||
| let download = latest.map_or_else( | ||
| || { | ||
|
Comment on lines
+161
to
+164
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Warning · Windows update recommends an unusable executable on 32-bit Windows On 32-bit Windows, Users who follow the guide can no longer run Recommend the archive only when Windows can run it; otherwise direct users to rebuild from source. |
||
| // No newer version is known, so this may already be the newest one. | ||
| format!( | ||
| "{ARCHIVE} and SHA256SUMS from https://github.com/prooflinedev/cli/releases/latest \ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Warning · Windows update steps can reinstall an older release If a browser renames duplicate downloads, the Windows guide still hashes and extracts the unsuffixed archive and checks the unsuffixed An older matching pair can pass verification and install the older executable even with an empty extraction folder. Download both files into a fresh directory and use those exact paths for verification and extraction. |
||
| (stop if that release is not newer than this proofline {})", | ||
| env!("CARGO_PKG_VERSION") | ||
| ) | ||
| }, | ||
| |version| { | ||
| let release = format!("{RELEASES}/download/{version}"); | ||
| format!("{release}/{ARCHIVE} and {release}/SHA256SUMS") | ||
| }, | ||
| ); | ||
| let executable = executable.map_or_else( | ||
| || "the proofline.exe you ran (find it with '(Get-Command proofline).Source')".to_owned(), | ||
| |path| path.display().to_string(), | ||
| ); | ||
| format!( | ||
| "'proofline update' cannot replace proofline.exe on Windows; update it by hand:\n \ | ||
| 1. Close every running Proofline process.\n \ | ||
| 2. Download {download}\n \ | ||
| 3. Run 'Get-FileHash -Algorithm SHA256 {ARCHIVE}' and check that the hash matches the archive's line in SHA256SUMS.\n \ | ||
| 4. Create an empty folder with 'mkdir proofline-new' (choose another name if it already exists).\n \ | ||
| 5. Extract into it with 'tar -xzf {ARCHIVE} -C proofline-new'.\n \ | ||
|
Comment on lines
+186
to
+187
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Warning · Windows update tests miss regressions that reuse a staging folder The unit test checks Both tests still pass if the collision warning disappears or directory creation and extraction become one unconditional command. Assert that the guidance requires an empty folder, tells users to choose another name on collision, and puts extraction in a separate subsequent step. |
||
| 6. Only if that succeeded, replace {executable} with proofline-new\\proofline.exe." | ||
|
Comment on lines
+186
to
+188
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Serious · Windows update can overwrite files in the existing staging folder Step 4 tells users to choose another folder if Copying the printed Store the chosen folder in a PowerShell variable and use it for both extraction and the replacement source. |
||
| ) | ||
| } | ||
|
|
||
| fn prepare_check( | ||
|
|
@@ -422,6 +465,16 @@ fn replace(archive: &[u8], destination: &Path) -> anyhow::Result<()> { | |
|
|
||
| /// Updates an official installer location after verifying the pinned archive. | ||
| pub(crate) async fn install() -> anyhow::Result<()> { | ||
| if cfg!(target_os = "windows") { | ||
| let latest = cache_path() | ||
| .and_then(|path| read_cache(&path).ok()) | ||
| .and_then(|cache| cache.latest) | ||
| .filter(|latest| newer(latest)); | ||
| bail!(windows_steps( | ||
| std::env::current_exe().ok().as_deref(), | ||
| latest.as_deref() | ||
| )); | ||
| } | ||
| let (destination, target) = | ||
| tokio::task::spawn_blocking(|| Ok::<_, anyhow::Error>((destination()?, target()?))) | ||
| .await??; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -195,6 +195,58 @@ fn notices_are_suppressed_for_machine_and_hook_commands() { | |
| assert!(suggestion(&cache, &["status".into()], true).is_some()); | ||
| } | ||
|
|
||
| #[test] | ||
| fn windows_notices_point_to_the_manual_steps() { | ||
| assert_eq!( | ||
| notice("9.0.0", false), | ||
| "proofline 9.0.0 is available; run 'proofline update'" | ||
| ); | ||
| let windows = notice("9.0.0", true); | ||
| assert!( | ||
| windows.starts_with("proofline 9.0.0 is available;"), | ||
| "{windows}" | ||
| ); | ||
| assert!( | ||
| windows.contains("'proofline update' shows how"), | ||
| "{windows}" | ||
| ); | ||
| // `suggestion` itself must pick the wording of the platform it runs on. | ||
| let cache = Cache { | ||
| checked: now(), | ||
| latest: Some("9.0.0".to_owned()), | ||
| }; | ||
| assert_eq!( | ||
| suggestion(&cache, &["status".into()], true).unwrap(), | ||
| notice("9.0.0", cfg!(target_os = "windows")) | ||
| ); | ||
| let steps = windows_steps(Some(Path::new(r"C:\tools\proofline.exe")), Some("9.0.0")); | ||
| for expected in [ | ||
| "Close every running Proofline process", | ||
| "https://proofline.sh/cli/download/9.0.0/proofline-x86_64-pc-windows-msvc.tar.gz", | ||
| "https://proofline.sh/cli/download/9.0.0/SHA256SUMS", | ||
| "Get-FileHash -Algorithm SHA256 proofline-x86_64-pc-windows-msvc.tar.gz", | ||
| "mkdir proofline-new", | ||
| "tar -xzf proofline-x86_64-pc-windows-msvc.tar.gz -C proofline-new", | ||
| r"replace C:\tools\proofline.exe with proofline-new\proofline.exe", | ||
| ] { | ||
| assert!( | ||
| steps.contains(expected), | ||
| "{expected:?} missing from {steps}" | ||
| ); | ||
| } | ||
| let unknown = windows_steps(None, None); | ||
| for expected in [ | ||
| "from https://github.com/prooflinedev/cli/releases/latest", | ||
| "(Get-Command proofline).Source", | ||
| concat!("not newer than this proofline ", env!("CARGO_PKG_VERSION")), | ||
| ] { | ||
| assert!( | ||
| unknown.contains(expected), | ||
| "{expected:?} missing from {unknown}" | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| // This same test executable supplies a real child fixture. All endpoint and | ||
| // fixture-mode injection lives in cfg(test), never in the customer binary. | ||
| #[tokio::test] | ||
|
|
@@ -294,7 +346,7 @@ async fn detached_discovery_is_serialized_and_notices_arrive_on_the_next_invocat | |
| assert!( | ||
| !String::from_utf8(output.stdout) | ||
| .unwrap() | ||
| .contains("run 'proofline update'") | ||
| .contains(" is available;") | ||
| ); | ||
| } | ||
| tokio::time::timeout(Duration::from_secs(5), async { | ||
|
|
@@ -322,7 +374,7 @@ async fn detached_discovery_is_serialized_and_notices_arrive_on_the_next_invocat | |
| assert!( | ||
| String::from_utf8(output.stdout) | ||
| .unwrap() | ||
| .contains("run 'proofline update'") | ||
| .contains(¬ice("9.0.0", cfg!(target_os = "windows"))) | ||
|
Comment on lines
374
to
+377
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Warning · Tests miss a Windows notice that promises automatic updates The discovery test uses Both tests can pass if the Windows notice incorrectly promises automatic installation. Assert the full Windows notice against a fixed expected string, independent of |
||
| ); | ||
| assert_eq!(received.load(Ordering::SeqCst), 1); | ||
| server.abort(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,3 +51,84 @@ fn cached_update_preserves_schema_help_and_source_installation() { | |
| b"keep this installed CLI" | ||
| ); | ||
| } | ||
|
|
||
| // Windows binaries are installed by hand (README "Windows installation"), so | ||
| // `update` must explain those steps instead of failing on Unix installer paths. | ||
| #[cfg(windows)] | ||
| #[test] | ||
| fn windows_update_explains_the_manual_steps() { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Warning · PR checks skip the Windows update integration test The Ubuntu test job excludes Removing the Windows early return can leave PR checks green while Windows users get installer errors instead of manual update instructions. Run DetailsThe helper test checks the instruction text directly, so it still passes if
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Partly agree, no change in this PR. It's true that CI never runs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Proofline recorded no decision on this finding. To record one, reply with only
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. accept risk There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accepted as a risk. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Warning · PR checks skip the Windows update regression test Ubuntu excludes the Windows-only integration test, and Windows CI only builds and smoke-tests unrelated commands. Removing the Windows early return from Run
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. accept risk There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accepted as a risk. |
||
| let directory = tempfile::tempdir().unwrap(); | ||
| let installed = directory.path().join("bin").join("proofline.exe"); | ||
| std::fs::create_dir_all(installed.parent().unwrap()).unwrap(); | ||
| std::fs::copy(env!("CARGO_BIN_EXE_proofline"), &installed).unwrap(); | ||
| let before = std::fs::read(&installed).unwrap(); | ||
| let cache = directory.path().join("proofline").join("update.json"); | ||
| std::fs::create_dir_all(cache.parent().unwrap()).unwrap(); | ||
| let checked = SystemTime::now() | ||
| .duration_since(UNIX_EPOCH) | ||
|
Comment on lines
+65
to
+68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Warning · Windows update tests miss stale cached versions The CLI fixture tests only a missing cache or a newer version, and the helper test bypasses Windows update could recommend an older or equal release without the version warning, and these tests would still pass. Add a CLI case caching the running version and assert that stderr gives the fallback URL and version warning, not a pinned download. |
||
| .unwrap() | ||
| .as_secs(); | ||
| // Without a cached newer version the steps name the GitHub page; with | ||
| // one they pin the downloads to the version the notice announced. | ||
| for (home, cached, download) in [ | ||
| ( | ||
| None, | ||
| false, | ||
|
Comment on lines
+73
to
+76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Warning · Windows update test misses downgrade guidance from an older cache The Windows CLI test covers an empty cache and a newer cached release, so removing the The test would still pass if Seed an older cached version and assert that stderr shows the guarded fallback and no pinned links for that version. |
||
| "https://github.com/prooflinedev/cli/releases/latest", | ||
| ), | ||
| ( | ||
| Some(directory.path()), | ||
| false, | ||
| "https://github.com/prooflinedev/cli/releases/latest", | ||
| ), | ||
| ( | ||
| None, | ||
| true, | ||
| "https://proofline.sh/cli/download/9.0.0/proofline-x86_64-pc-windows-msvc.tar.gz", | ||
| ), | ||
| ] { | ||
| if cached { | ||
| std::fs::write( | ||
| &cache, | ||
| format!("{{\"checked\":{checked},\"latest\":\"9.0.0\"}}"), | ||
| ) | ||
| .unwrap(); | ||
| } | ||
| let mut command = Command::new(&installed); | ||
| command | ||
| .arg("update") | ||
| .env("PROOFLINE_NO_UPDATE_CHECK", "1") | ||
| .env("LOCALAPPDATA", directory.path()) | ||
| .env_remove("PROOFLINE_INSTALL_DIR") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Warning · Windows update test fails when the temporary path contains The test requires stderr to include the executable path but rejects any occurrence of Correct manual update instructions fail the test under a temporary directory containing Check for the specific installer diagnostic
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 92a28dd. The check is now There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Marked fixed. |
||
| .env_remove("HOME"); | ||
| if let Some(home) = home { | ||
| command.env("HOME", home); | ||
| } | ||
| let update = command.output().unwrap(); | ||
| assert!(!update.status.success()); | ||
| assert!(update.stdout.is_empty()); | ||
| let stderr = String::from_utf8(update.stderr).unwrap(); | ||
| for expected in [ | ||
| download, | ||
| "proofline-x86_64-pc-windows-msvc.tar.gz", | ||
| "SHA256SUMS", | ||
| "Get-FileHash -Algorithm SHA256", | ||
| "-C proofline-new", | ||
| &installed.display().to_string(), | ||
| ] { | ||
| assert!( | ||
| stderr.contains(expected), | ||
| "{expected:?} missing from {stderr}" | ||
| ); | ||
| } | ||
| assert!( | ||
| !stderr.contains("set HOME or PROOFLINE_INSTALL_DIR"), | ||
| "{stderr}" | ||
| ); | ||
| assert!( | ||
| !stderr.contains("outside the installer directory"), | ||
| "{stderr}" | ||
| ); | ||
| } | ||
| assert_eq!(std::fs::read(&installed).unwrap(), before); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Warning · Detached discovery test fails on Windows
The test still requires Unix-only wording after this change gives Windows a different update notice.
On Windows, the test panics after the refreshed cache yields the expected update notice.
Check for the platform-independent version announcement both before and after the cache refresh.
View finding in Proofline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 92a28dd. Correct: the assertion at
src/update/tests.rs:358still wanted the Unix text. On this machine the C-1 pipe timeout (fixed in prooflinedev#79) currently hides it. Both checks now use the platform's text (notice("9.0.0", cfg!(target_os = "windows"))after the refresh, and the platform-independentproofline 9.0.0 is available;before it). Verified by merging prooflinedev#79's branch into a throwaway branch:update::tests9/9 pass on Windows.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marked fixed.