bun icon indicating copy to clipboard operation
bun copied to clipboard

`cwd` option in `child_process` exports not working in `MacOS 10.x`

Open ThatOneBro opened this issue 2 years ago • 2 comments

Jarred-Sumner The big caveat for the workaround proposed for posix_spawn_file_actions_addchdir_np on macOS 10.x is that the cwd option for the following calls cannot be overridden and will incorrectly use the current working directory of the calling process:

child_process.exec
child_process.execSync
child_process.spawn
child_process.spawnSync
child_process.execFile
child_process.execFileSync

as they're all based on Bun.spawn which calls:

https://github.com/oven-sh/bun/blob/451ccfd5ef4b6f1539a8a317ee96591228e4cd0a/src/bun.js/api/bun/subprocess.zig#L1231

which in turn calls:

https://github.com/oven-sh/bun/blob/451ccfd5ef4b6f1539a8a317ee96591228e4cd0a/src/bun.js/api/bun/spawn.zig#L153-L159

Until a proper fix is made for macos 10.x, an assert could be added to terminate the program if the cwd option is specified and does not match the normalized getcwd().

When I proposed the original workaround I thought it was an unimportant start-up instruction.

Originally posted by @kzc in https://github.com/oven-sh/bun/issues/1266#issuecomment-1445301325

We should at least add the aforementioned assert and terminate with error message explaining the current issue with MacOS 10.x

ThatOneBro avatar Feb 27 '23 16:02 ThatOneBro

Related question... the github code search box in their web interface doesn't work for zig file extensions?

For example:

  • https://github.com/oven-sh/bun/search?q=posix_spawn_file_actions_addchdir_np&type=code

  • https://github.com/oven-sh/bun/search?q=posix_spawn&type=code

The search only produces results for Commits and Issues - but not Code.

Strangely, text within js files within this repo cannot be found by Code search either:

  • https://github.com/oven-sh/bun/search?q=execFileSync&type=code

One such occurrence not found by github Code search:

https://github.com/oven-sh/bun/blob/f420e81e85e9597cb96799d313b75dc7da16edd6/src/bun.js/child_process.exports.js#L633

Contrast this with a global github search which will produce Code results for other projects for js files:

  • https://github.com/search?q=execFileSync&type=code

Does a repo need some sort of .github yaml file to enable github Code search?

kzc avatar Feb 27 '23 17:02 kzc

Seems to work for me but idk, maybe it's just some hiccups with search.

ThatOneBro avatar Feb 27 '23 17:02 ThatOneBro

Could be an undocumented Github Pro thing.

kzc avatar Feb 27 '23 18:02 kzc

I figured it out. Code search only works if you opt in to the Github Beta Feature "New Code Search and Code View". Traditional github code search is buggy and only works in certain repos.

kzc avatar Feb 27 '23 22:02 kzc