Understanding `Error: spawnSync rescript.exe ENOENT`

I’m working on a flake.nix file, for a monorepo, and my OS is nixos.

My current hypothesis re the spawnSync error is that it has to do with write access to tmp directories, and nix is doing something that not every linux does with permissions. Is this hypothesis at all reasonable?

When my yarn command works it’s way down to rescript build -with-deps, I get this

> $ rescript build -with-deps
> warning Cannot find a suitable global folder. Tried these: "/usr/local, /homeless-shelter/.yarn"
> Error: spawnSync /nix/store/zllzvzv0m802za9y453vpl826rm5brzp-quri-squiggle-lang-modules-0.2.11/node_modules/rescript/linux/rescript.exe ENOENT

--global-folder flag from yarn doesn’t seem to interact with the rescript executable.

I should note that (modulo some patchelf work and running yarn from within an FHS shell, though I’m pretty sure the FHS is for something other than rescript), I can build and develop rescript on my machine (which is nixos), the problem is in the particular sandbox that the flake is building in)

Another question:

I’m not familiar with mkYarnPackage, but it seems like your patchelf invocation is too late. ReScript checks that the binary works during installation.