oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.01k stars 2.66k forks source link

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

Closed ThatOneBro closed 1 week ago

ThatOneBro commented 1 year ago

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

kzc commented 1 year ago

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

For example:

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:

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:

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

ThatOneBro commented 1 year ago

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

kzc commented 1 year ago

Could be an undocumented Github Pro thing.

kzc commented 1 year ago

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.