"Could not find an executable for process" when file is clearly there

I’m writing an LSP extension, and I want to bundle the language server and everything it needs so that the user doesn’t have to manually install anything extra. I took inspiration from nova-rust which uses a shell script inside a Process to download and update its bundled language server when needed. I created this function to update the server and start it when it finishes:

function updateBundles(server) {
	serverPath = nova.config.get("com.johnlindop.nova-typescript.language-server-path")
	arguments = []
	if (nova.inDevMode) {
		arguments.push("-d")
	}
	if (!nova.config.get("com.johnlindop.nova-typescript.language-server-path")) {
		arguments.push("-s")
	}
	if (nova.config.get("com.johnlindop.nova-typescript.install-fallback-typescript")) {
		arguments.push("-t")
	}
	let updater = new Process(`${binPath}/update_language_server.sh`,
		{
			cwd: `${nova.extension.path}/bin`,
			shell: '/usr/bin/env zsh',
			args: arguments
		})
	updater.onDidExit(function(exitCode) {
		console.log("Starting language server")
		server.start(serverPath)
	})
	updater.start()
}

However, when I run the function, it fails with the following error:

Error: Could not find an executable for process: /Users/john/git/Nova Typescript.novaextension/bin/update_language_server.sh
    @[native code]
    updateBundles@file:///Users/john/git/Nova%20Typescript.novaextension/Scripts/main.js:107:15
    @file:///Users/john/git/Nova%20Typescript.novaextension/Scripts/main.js:8:15

If I run the script from my terminal using that exact path, it works perfectly. I’ve declared the process, requests and `filesystem: readwrite" entitlements, so the extension should be able to download what it needs?

Just wondering if the space in the path is causing an issue. You may want to try something like:

nova.path.join(binPath, "update_language_server.sh")

That didn’t seem to work. I also tried renaming the .novaextension folder to not include a space.

After looking into the implementation of nova-rust, it turns out that you can define the path to the executable relative to the Process cwd, instead of as absolute. This fixed the problem for me.

let updater = new Process(("./update_language_server.sh"),
		{
			cwd: binPath,
			shell: true,
			args: arguments
		})