Skip to content

Commit 698bef6

Browse files
committed
bun backtest: inject the custom-registry slot with byte I/O
On Windows, Path.write_text turned the injected bun.lock's LF into CRLF, so the LF pre-injection bytes could never match the (EOL-preserving) upstream restore: custom-registry hosted rollbackOriginalFiles failed on Windows only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018tncU7u7FK48tubFNA12UQ
1 parent 65aa074 commit 698bef6

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎scripts/backtest-bun.py‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -854,13 +854,16 @@ def install(binary, label, flags=(), cache=None):
854854
# bun writes "" for its default registry, so `.npmrc` alone never
855855
# fills the slot: inject the full-URL form bun emits for any other
856856
# registry and prove bun installs from it before the CLI runs.
857-
text = lock.read_text(encoding='utf-8')
858-
pre_injection = text.encode('utf-8')
857+
# Bytes, not text mode: Windows text I/O would turn the lock's LF
858+
# into CRLF, and the restore (which keeps the lock's line endings)
859+
# would then never match the LF pre-injection bytes.
860+
pre_injection = lock.read_bytes()
861+
text = pre_injection.decode('utf-8')
859862
injected = text.replace('["minimist@1.2.2", ""', f'["minimist@1.2.2", "{REGISTRY_SLOT}"')
860863
checks['registrySlotInjected'] = injected != text
861-
lock.write_text(injected, encoding='utf-8')
864+
lock.write_bytes(injected.encode('utf-8'))
862865
code, _ = install(bun, 'registry-accepted', ['--frozen-lockfile'])
863-
checks['registrySlotAccepted'] = code == 0 and lock.read_text(encoding='utf-8') == injected
866+
checks['registrySlotAccepted'] = code == 0 and lock.read_bytes() == injected.encode('utf-8')
864867
original = {name: (project / name).read_bytes()
865868
for name in [*files, 'bun.lock', 'bun.lockb'] if (project / name).exists()}
866869
row['originalSha256'] = {n: sha256(b) for n, b in original.items()}

0 commit comments

Comments
 (0)