Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always create native executables (even if they're shims) #4363

Closed
mitranim opened this issue May 24, 2021 · 1 comment
Closed

Always create native executables (even if they're shims) #4363

mitranim opened this issue May 24, 2021 · 1 comment

Comments

@mitranim
Copy link

mitranim commented May 24, 2021

Problem

Currently some packages, such as sass, install a bunch of .cmd, .ps1 and/or .bat entrypoints, but no actual executable. This works when invoking them manually from a shell. It even works in the Windows version of Make, which seems to have special support for finding and invoking .cmd/.bat files. But it doesn't work for programmatically creating a subprocess from another language.

For example, I have projects with a build script written in JS, which wants to run sass as a subprocess. For the version of sass installed by Chocolatey, this is possible, because there's sass.exe on the PATH. (The code is oversimplified.)

import * as cp from 'child_process'
const proc = cp.spawn('sass', ['some-args'], {stdio: 'inherit'})

However, Scoop, for this package and probably many others, does not install an executable entrypoint, so this would fail. It's possible to work around this by "shelling out", going through cmd, but this creates another subprocess, increasing the likelihood of process leaks and accidental daemons; see #4362.

Solution

Scoop should always create an executable. Ideally, it would be self-contained, without relying on a subprocess. When not possible, it should invoke the "real" executable with the appropriate args (ideally without cmd indirection). It should also use the job objects API to ensure correct termination of any subprocesses; see #4362.

@mitranim mitranim changed the title Always create native executables Always create native executables (even if they're shims) May 26, 2021
@rashil2000
Copy link
Member

Sass invokes a Dart executable with some appropriate arguments. So it needs to be a script.

It doesn't make sense to create .exe files for programs that provide shell files as entry points.

Besides, NodeJS's spawn supports running .cmd files directly - https://nodejs.org/docs/latest/api/child_process.html#spawning-bat-and-cmd-files-on-windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants