Skip to content

update: explain the manual Windows update instead of failing on Unix paths - #84

Open
Ahmar004 wants to merge 3 commits into
prooflinedev:mainfrom
Ahmar004:fix/windows-update-notice
Open

Ahmar004 wants to merge 3 commits into
prooflinedev:mainfrom
Ahmar004:fix/windows-update-notice

Conversation

@Ahmar004

Copy link
Copy Markdown

Fixes #83

The problem in one sentence

On Windows the CLI tells you to run proofline update, but that command always fails there, with errors that send you the wrong way, and it never shows the manual update steps the README describes.

Why it happens, step by step

  1. A background check saves the newest version number in a cache file once a day. On the next run in a console window, suggestion() (src/update.rs) prints proofline X is available; run 'proofline update' on every OS.
  2. proofline update calls install(). Its first step, destination(), looks for the Unix installer folder: PROOFLINE_INSTALL_DIR, or else $HOME/.local/bin. A normal Windows PowerShell has no HOME variable, so the command stops with set HOME or PROOFLINE_INSTALL_DIR.
  3. With HOME or PROOFLINE_INSTALL_DIR set, install_path() expects <folder>/proofline, with no .exe. The Windows binary is proofline.exe, so this check can never pass, and the error says the binary is "outside the installer directory", even when that folder is the one holding it.
  4. Past that, target() would say "no official Proofline release is built for windows", which is false: every release ships proofline-x86_64-pc-windows-msvc.tar.gz.
  5. The README ("Windows installation") already says self-update doesn't install Windows binaries and gives the verified manual steps. The CLI never showed them.

Who is affected

Everyone who installed the official Windows release. They see the notice on every interactive command until they update, and the command it names can't help them.

What this PR changes (src/update.rs, ~50 lines)

  • install(): on Windows it now stops first, before any path check or download. It returns an error that lists the README's steps:

    1. Close Proofline.
    2. Download the archive and SHA256SUMS.
    3. Check the hash with Get-FileHash -Algorithm SHA256.
    4. Create an empty folder (mkdir proofline-new, another name if it already exists).
    5. Extract into it (tar -xzf … -C proofline-new), so an interrupted extract can't damage the installed copy.
    6. Only then replace this binary, whose path comes from current_exe(). If the path can't be read, the step says to find it with (Get-Command proofline).Source.

    The exit status stays non-zero because nothing was updated, so a script doesn't think the update worked.

  • Which download links: the notice's version comes from https://proofline.sh/cli/latest, and release.yml publishes that file before GitHub marks the release as latest. If the local update cache holds a newer version (the one the notice showed), the steps link to that version's pinned files, https://proofline.sh/cli/download/<version>/…, the same files the Unix updater verifies. Otherwise they point to the GitHub releases/latest page and print this binary's version, with "stop if that release is not newer", so nobody downgrades by accident. The cached value has already passed version() (only digits and dots) before it goes into a URL.

  • notice(): the notice text moved into a small function. On Windows it reads proofline X is available; 'proofline update' shows how to install it. On Linux and macOS it is the same text as before.

  • windows_steps(): builds the steps text. It is a plain function, so its test runs on Linux CI too.

  • Linux and macOS behave exactly as before. destination(), install_path() and target() are unchanged.

Why not the obvious alternatives

  • Real Windows self-update. Windows can't overwrite a running .exe, so this needs a rename-aside step, cleanup on the next start, and zip/tar handling. That's a feature with its own risks, and the README says self-update doesn't install Windows binaries, so it should be the maintainer's call (offered in the issue).
  • Fixing only the notice. Users who already run proofline update would still get the misleading errors.
  • Looking up the latest version over the network first. The cached version already names the release the notice announced, so a network call would only add a failure point to a command that prints steps, and the tests would no longer run offline.

How I tested it (Windows 11, Rust 1.100.0)

Reproduced first on main (105f387), with proofline.exe copied into a folder as the README says:

Setup main this PR
plain PowerShell (no HOME) set HOME or PROOFLINE_INSTALL_DIR the 6 manual steps with this binary's path and version, exit 1
cache says 9.0.0 (same error) steps link to https://proofline.sh/cli/download/9.0.0/…, exit 1
HOME=%USERPROFILE% …outside the installer directory C:\Users\…\.local/bin… same steps, exit 1
PROOFLINE_INSTALL_DIR=<the folder holding proofline.exe> …outside the installer directory <that same folder>… same steps, exit 1
notice in a real console window (cache says 9.0.0) proofline 9.0.0 is available; run 'proofline update' proofline 9.0.0 is available; 'proofline update' shows how to install it

The notice only appears when both output streams are a console, so I ran the binary in a new PowerShell window and read its screen buffer ($host.UI.RawUI.GetBufferContents).

The printed steps work: I followed them for v0.5.2 from both sources, GitHub releases/latest and the pinned https://proofline.sh/cli/download/0.5.2/…. Get-FileHash gave e5631d11…500a, which matches its line in SHA256SUMS. mkdir proofline-new then tar -xzf … -C proofline-new exited 0, and proofline-new\proofline.exe --version prints proofline 0.5.2.

New tests, written before the fix:

  • tests/update.rs::windows_update_explains_the_manual_steps (Windows only): runs the real binary from a README-style folder, with and without HOME, and with a cached newer version. It checks that the update fails, prints nothing on stdout, names the right download links, SHA256SUMS, Get-FileHash, the new-folder extract and the binary's own path, never shows the old set HOME or PROOFLINE_INSTALL_DIR / "outside the installer directory" errors, and leaves the binary untouched. Fails on main (…missing from proofline: set HOME or PROOFLINE_INSTALL_DIR), passes now.
  • src/update/tests.rs::windows_notices_point_to_the_manual_steps (every OS): checks both notice texts (the Unix one is unchanged), that suggestion() picks the wording of the platform it runs on, and the steps with and without a known path and version. Mutation check: hard-coding the Unix wording in suggestion() makes it fail.
  • detached_discovery… now expects the platform's notice text after the refresh, and no notice of any version before it. It times out on Windows because of the pipe issue that Windows: don't make scripts wait for the background update check #79 fixes. With Windows: don't make scripts wait for the background update check #79 merged into a throwaway branch, all of update::tests (9/9) passes on Windows.
  • The existing cached_update_preserves_schema_help_and_source_installation still passes. On Windows the update still fails, prints nothing on stdout and leaves the files untouched.

Whole suite: cargo fmt --check clean. cargo test --locked --no-fail-fast gives the same 8 failures on main and on this branch, none of them about the update command's output: tests/mcp.rs (5), tests/agent_install.rs, tests/local_patch.rs and update::tests::detached_discovery… (the Windows pipe issue fixed in #79). cargo clippy --all-targets reports the same 3 errors as on main, all in src/agent/tests.rs, which this PR doesn't touch.

Proofline review log

Fork review PR: Ahmar004#3 (2 rounds, the cap for this contribution). 12 findings: 9 fixed, 3 accepted risk (all "CI doesn't run the Windows tests", which needs a workflow change and so an issue, per the README).

Round Finding What I made of it Outcome
1 Serious: tar -xzf in the current folder can overwrite the installed proofline.exe Correct; an interrupted extract would also break it. Fixed in 92a28dd: extract into proofline-new, replace only after success
1 detached_discovery test still wants the Unix wording Correct (hidden on Windows by the C-1 timeout). Fixed in 92a28dd; 9/9 with #79 merged
1 No path when current_exe() fails Correct. Fixed in 92a28dd: (Get-Command proofline).Source
1 releases/latest can be older than the version in the notice Correct: release.yml publishes cli/latest before gh release edit --latest. Fixed in 92a28dd: pinned proofline.sh links from the cached version
1 CI never runs the Windows integration test True, but the README says workflow changes go through an issue. Ran it locally: RED on main, GREEN here. Accepted risk; goes in the CI issue
1 Tests would pass if suggestion always used the Unix wording Correct. Fixed in 92a28dd, mutation-checked
1 !stderr.contains("HOME") fails if the temp path contains HOME Correct. Fixed in 92a28dd: checks the exact old error
2 Serious: mkdir proofline-new; tar … still extracts when the folder already exists Partly: only a staged copy could be overwritten, never the installed one, but the step should be exact. Fixed in af2f6b2: separate "create an empty folder" step
2 The GitHub fallback can downgrade a newer binary Correct: with no cached newer version, you may already be on the newest one. Fixed in af2f6b2: prints this version, "stop if not newer"
2 Pre-refresh check rejects only a 9.0.0 notice Correct. Fixed in af2f6b2: rejects any is available;
2 CI doesn't run the notice test on Windows (×2) Same workflow-scope point as round 1. Accepted risk; goes in the CI issue

…paths

On Windows the update notice said "run 'proofline update'", but that
command could never work there. It looked for the Unix installer folder
($HOME/.local/bin or PROOFLINE_INSTALL_DIR) and a binary called
"proofline" without ".exe". So it failed with "set HOME or
PROOFLINE_INSTALL_DIR", or with "this binary is outside the installer
directory", even when PROOFLINE_INSTALL_DIR was the folder holding
proofline.exe. It never showed the manual steps from the README.

On Windows, install() now stops before any path check or download. It
returns an error that lists the README's steps: close Proofline,
download proofline-x86_64-pc-windows-msvc.tar.gz and SHA256SUMS from
the latest GitHub release, check the hash with Get-FileHash, extract
the archive and replace this binary (its path is printed). The exit
status stays non-zero because nothing was updated. The Windows notice
now says "'proofline update' shows how to install it". Linux and macOS
behave exactly as before.

Tests: windows_update_explains_the_manual_steps (tests/update.rs,
Windows only, runs the real binary from a README-style folder with and
without HOME) fails on main and passes now.
windows_notices_point_to_the_manual_steps (src/update/tests.rs, runs on
every OS) checks both notice texts and the steps.
…fely

Proofline review, round 1:
- Extracting with 'tar -xzf' in the current folder could overwrite the
  installed proofline.exe (and leave it broken if interrupted). The steps
  now extract into a new 'proofline-new' folder and replace the binary
  only after that succeeded.
- The notice's version comes from https://proofline.sh/cli/latest, which
  the release workflow publishes before GitHub marks the release as
  latest, so 'releases/latest' could still be the old version. When the
  local cache holds the newer version the notice showed, the steps now
  link to that version's pinned downloads on proofline.sh (the same
  files the Unix updater verifies). Still no network call.
- When the binary's own path can't be read, the steps say how to find
  it: '(Get-Command proofline).Source'.
- Tests: the cached-discovery test now accepts the Windows wording; a
  new assertion checks that suggestion() picks the platform's wording;
  the Windows integration test also covers the pinned links and checks
  for the exact old error instead of any "HOME".
Proofline review, round 2:
- Without a cached newer version, the steps point to GitHub's latest
  release, which may not be newer than the running binary. They now
  print this binary's version and say to stop if the release isn't
  newer.
- In PowerShell, 'mkdir proofline-new; tar ...' runs tar even when
  mkdir failed because the folder exists, so an older staged copy could
  be reused. Creating the empty folder is now its own step (pick another
  name if it exists), before extracting.
- The cached-discovery test now rejects any "is available;" notice
  before the refresh, not only one for 9.0.0.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

On Windows the update notice says "run 'proofline update'", but that command can't work there and gives misleading errors

1 participant