Skip to content

fix: requirements.txt checksum mismatch on Windows - #856

Merged
karawoo merged 6 commits into
mainfrom
fix-windows-line-endings
Sep 30, 2026
Merged

karawoo merged 6 commits into
mainfrom
fix-windows-line-endings

Conversation

@karawoo

@karawoo karawoo commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Intent

On Windows, write-manifest wrote requirements.txt in text mode, which changed \n to \r\n. This resulted in a file whose checksum did not match the one that rsconnect calculated, which could cause deployment to fail. This fixes it by writing the file as bytes.

Fixes #855

Type of Change

  • Bug Fix
  • New Feature
  • Breaking Change

Approach

  • Write the environment file with to_bytes, the same function buffer_checksum uses, so the file and the checksum always match.
  • Read an existing requirements file with newline="" so that CRLF line endings stay in the contents. Before, a CRLF file got an LF checksum on all platforms. This was the cause of write-manifest on Windows creates an inaccurate checksum #429.

Automated Tests

The new test_bundle.py tests patch open in rsconnect.bundle to use Windows text-mode defaults, so they fail on any OS without the fix.

Directions for Reviewers

Checklist

  • I have updated CHANGELOG.md to cover notable changes.
  • I have updated all related GitHub issues to reflect their current state.
  • I have run the rsconnect-python-tests-at-night workflow in Connect against this feature branch.

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-09-30 15:02 UTC

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
8956 7732 86% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
rsconnect/bundle.py 88% 🟢
rsconnect/subprocesses/inspect_environment.py 88% 🟢
TOTAL 88% 🟢

updated for commit: 13a1258 by action🐍

allows prerelease tests to pass
@karawoo
karawoo requested a review from a team September 29, 2026 19:17

@marcosnav marcosnav left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While chatting with the 🤖 on this one, it seems that rsconnect still gets the CRLF case wrong.

Tests call detect_environment() directly and skip main() and pass. But, main() in rsconnect/subprocesses/inspect_environment.py runs every line through strip_ref().

That calls .strip() on each line, which removes the \r that the newline="" change now keeps.

I verified this by changing the tests slightly to go through the subprocess. Calling Environment.create_python_environment(str(tmp_path)) catches this.

Comment thread tests/test_environment.py Outdated
Comment thread tests/test_bundle.py
@karawoo

karawoo commented Sep 30, 2026

Copy link
Copy Markdown
Contributor Author

ahh good catch, thanks @marcosnav, I will update

@karawoo
karawoo requested a review from marcosnav September 30, 2026 02:54

@marcosnav marcosnav left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@karawoo
karawoo merged commit f051fbc into main Sep 30, 2026
25 checks passed
@karawoo
karawoo deleted the fix-windows-line-endings branch September 30, 2026 15:02
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.

Checkum mismatch in write-manifest shiny for requirements.txt

2 participants