Repository navigation
Commit ec9aabc
* Start fix for #1756
Assisted-by: Claude Code:claude-opus-5-5
* Accept npm's LF shebang on CRLF bin files
On Linux and macOS npm's bin-links rewrites a bin file whose first
line is "#!...\r\n" to end in "\n". socket-patch compared the installed
bytes against the tarball's hashes, so a pristine npm install of such
a bin failed apply as drift, an overwrite with consent wrote back a
shebang env can't run ("node\r": exit 127), hosted vex omitted a
correctly patched install, and vendored vex warned the tree was out
of sync.
The hash checks now also accept npm's form of the original and the
patched content, and apply and rollback write the bytes in that form,
so the bin keeps running. An overwrite with consent of an npm bin with
an LF shebang writes the patched content the same way.
Fixes #1756
Assisted-by: Claude Code:claude-opus-5-5
* Know npm-installed Socket blobs; probe cheaply
A superseding patch may replace content an earlier Socket patch wrote.
When npm installed that earlier patch with an LF shebang, its hash
named no Socket blob, so the update was refused as a local edit. The
check now also tries npm's original form of the file.
Hashing npm's original form now reads a file whole only when its first
2 KB start with a shebang line, so a mismatched jar or wheel is not
read twice.
Refs #1756
Assisted-by: Claude Code:claude-opus-5-5
* Close npm LF-shebang gaps found in review
- Write a bin's recorded bytes when they are not valid UTF-8: npm would
replace them with U+FFFD, a form nothing can trace back to the hash.
- Roll back a bin the patch added when npm installed it with an LF
shebang, as apply and vex already count it patched.
- Keep the stale-install probe in step with vex for such bins.
- A project rollback now sees a global copy still patched in npm's
form and points at `rollback -g`.
- On Windows npm leaves bins alone, so an overwrite there writes the
patch's exact bytes.
- One helper checks the blob and builds npm's form for both writers.
Refs #1756
Assisted-by: Claude Code:claude-opus-5-5
* Restore npm's form of a bin on rollback
When a patch's own bytes already gave a CRLF-shebang bin an LF
shebang, apply wrote them as recorded, and rollback then restored the
CRLF tarball original: the bin failed with "env: 'node\r'". Rollback
and apply now both decide from the file on disk: off Windows, an npm
package's bin with an LF shebang gets npm's form of whatever is
written; elsewhere only a file that is provably npm's form of the
content it replaces does.
Refs #1756
Assisted-by: Claude Code:claude-opus-5-5
* Gate npm-fixed SocketContent test off Windows
On Windows npm leaves bin files alone, so form_for_write writes the
patch's exact CRLF bytes there and this test's NPM_BIN_AFTER assertion
fails. Windows unit tests only run in the merge queue, so the failure
would evict the PR there. Gate it like its sibling
consent_overwrite_of_npm_bin_keeps_lf_shebang.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* Keep npm's LF shebang form on Windows too
npm's bin-links rewrites a bin's CRLF shebang on Windows as well:
shim-bin.js runs fixBin right after writing the cmd-shim. The writers
assumed npm left bins alone there, so a consent overwrite or a
rollback on Windows wrote the recorded CRLF bytes instead of npm's
form. Verify accepted both, so nothing broke, but the files no longer
matched what npm installs. Drop the Windows exception and the test
gates that assumed it.
Refs #1756
Assisted-by: Claude Code:claude-opus-5-5
---------
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 4345294 commit ec9aabc
7 files changed
Lines changed: 914 additions & 16 deletions
File tree
- crates
- socket-patch-cli
- src/commands
- tests
- socket-patch-core/src
- patch
- vex
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
334 | 334 | | |
335 | 335 | | |
336 | 336 | | |
337 | | - | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
338 | 343 | | |
339 | 344 | | |
340 | 345 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1160 | 1160 | | |
1161 | 1161 | | |
1162 | 1162 | | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
0 commit comments