Files
bun.sh/test/regression/issue
robobun c04ad1e5db Fix argv handling for standalone binaries - remove extra executable name (#22157) (#22169)
## Summary

Fixes an issue where compiled standalone binaries included an extra
executable name argument in `process.argv`, breaking code that uses
`node:util.parseArgs()` with `process.argv.slice(2)`.

## Problem

When running a compiled binary, `process.argv` incorrectly included the
executable name as a third argument:

```bash
./my-app
# process.argv = ["bun", "/$bunfs/root/my-app", "./my-app"]  # BUG
```

This caused `parseArgs()` to fail with "Unexpected argument" errors,
breaking previously valid code.

## Solution

Fixed the `offset_for_passthrough` calculation in `cli.zig` to always
skip the executable name for standalone binaries, ensuring
`process.argv` only contains the runtime name and script path:

```bash  
./my-app
# process.argv = ["bun", "/$bunfs/root/my-app"]  # FIXED
```

## Test plan

- [x] Added regression test in `test/regression/issue/22157.test.ts`
- [x] Verified existing exec-argv functionality still works correctly  
- [x] Manual testing confirms the fix resolves the parseArgs issue

Fixes #22157

🤖 Generated with [Claude Code](https://claude.ai/code)

---------

Co-authored-by: Claude Bot <claude-bot@bun.sh>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Michael H <git@riskymh.dev>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-08-28 11:24:04 +00:00
..
2025-08-06 06:44:46 -07:00
2025-01-28 17:23:57 -08:00
2025-06-03 13:23:12 -07:00
2025-06-03 23:41:37 -07:00
2025-01-17 22:08:07 -08:00
2024-06-14 01:50:36 -07:00
2024-09-24 22:46:18 -07:00
2025-03-03 21:38:05 -08:00
2025-05-26 21:18:22 -07:00
2025-07-03 01:06:22 -07:00
2025-07-23 22:31:42 -07:00
2025-07-20 23:02:10 -07:00