Skip to content

Commit

Permalink
Merge pull request #18 from ManasJayanth/powershell-on-windows
Browse files Browse the repository at this point in the history
Improved shell support on Windows
  • Loading branch information
ManasJayanth authored May 29, 2024
2 parents 96bc717 + 9d3a236 commit 3b8e18b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
A tool to make it easier to package C libraries and tools for [esy](esy.sh)

Note: On Windows, it works only within mingw/cygwin environment since esy provides this environment anyway.
Note: On Windows, it works only within mingw/GitBash environment (but not cygwin) since esy provides this environment anyway.

Needs Powershell 7

## Development

Expand Down
15 changes: 14 additions & 1 deletion src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,20 @@ async function e2eShell(
});
const prefixPath = userSpecifiedPrefixPath ?? setupTemporaryEsyPrefix();
Log.info("Dropping into a shell to debug");
const bash = cp.spawn("/bin/bash", [], {
// We earlier used /bin/bash On Windows it's advisable to simply use
// bash because Windows has two environments. Cygwin and Native Shells
// (cmd and powershell)
// When in cygwin, if one spawns /bin/bash, it still won't work
// unless the node.js was linked with cygwin.dll, ie. a C-Runtime that
// understand cygwin paths.
// With Powershell and cmd, /bin/bash wont work for obvious reasons
// It's also important to disable shell with spawn, otherwise Node.js
// will launch an extra shell process to run our shell inside it
// But since we dont implement our own path resolution of the command,
// with $PATH, spawn wont work reliably with just command names.
// (Eg. esy.cmd ENOENT)
// Also, using pwsh puts a hard dependency on the new Powershell 7
const bash = cp.spawn(process.platform === "win32" ? "pwsh" : "bash", [], {
stdio: "inherit",
env: {
...process.env,
Expand Down

0 comments on commit 3b8e18b

Please sign in to comment.