Skip to content
This repository has been archived by the owner on Mar 4, 2022. It is now read-only.

[BUG] Windows: MinGW/Git Bash/Etc. use PATH env var instead of Path like cmd does. #142

Closed
rhbecker opened this issue Jul 7, 2017 · 6 comments
Labels

Comments

@rhbecker
Copy link

rhbecker commented Jul 7, 2017

I see the above error with the following setup:

  • builder v3.2.2
  • node v6.11.0
  • windows 10
  • executing in git-bash, cygwin, etc.

These same issues do not occur via cmd.

If you have such an environment, you can repro via npm run builder:check, which yields ...

  • 78 passing
  • 8 pending
  • 11 failing

So far, I have no explanation - only observations ...

All 11 failing tests call an npm script defined to include ...
"node test/server/fixtures/echo.js ..."
... but there are 4 tests that pass with the same script.

The difference is that the 11 failing ones invoke the script via run or concurrent, while the 4 passing ones invoke with envs.

Don't pass:

  • run({argv: ["node", "builder", "run", "echo", ...]}, ...});
  • run({argv: ["node", "builder", "concurrent", "echo", ...]}, ...});

Pass:

  • run({argv: ["node", "builder", "envs", "echo", ...]}, ...});

So, you might think any script invoked via run that calls node whatever might fail, but that is not the case. The "runs with --setup" test passes. It defines an npm script ...

"bar": "node test/server/fixtures/repeat-script.js 5 BAR_TASK >> stdout.log"

... which it calls via ...

run({argv: ["node", "builder", "run", "bar", "--setup=setup"]}, ...});

@rhbecker
Copy link
Author

rhbecker commented Jul 7, 2017

FWIW, I just tried reverting to builder v2.10.1 and that version seems to work with the tasks I'm actually trying to execute, in the git-bash / cygwin on windows 10 environment.

@dusura
Copy link

dusura commented Oct 6, 2017

A fix for this would be nice. Builder is not usable on Windows (Windows 7 in my case). As @rhbecker says, a number of tests fail on Windows.

@ryan-roemer
Copy link
Member

Can folks give me examples of real CLI commands that are failing? (The tests are a bit hacked-up / mocked-out).

I've now got a win7 VM and will try and dig into this today and next week...

@ryan-roemer
Copy link
Member

Weird. All of npm run builder:check passed on my win7 vm in cmd with node v6.11.4. Do I need to do cygwin or something?

@ryan-roemer
Copy link
Member

ryan-roemer commented Oct 6, 2017

OK, reproduced in git-bash. It reproduces on CLI too.

For scripts:

    "echo": "echo %m%",
    "bounce": "node bin\\builder.js run echo",

Internal spawn of an executable node

The command:

$ node bin/builder.js envs bounce "[{\"m\":1},{\"m\":2}]"

Passes on cmd, but fails in git-bash with:

'node' is not recognized as an internal or external command,
operable program or batch file.
[builder:proc:end:1] Command: node bin\builder.js run echo, Environment: {"m":1}
[builder:proc:error] Code: 1, Command: node bin\builder.js run echo, Environment
: {"m":1}

No spawn

The command:

$ node bin/builder.js envs echo "[{\"m\":1},{\"m\":2}]"

Works fine in both cmd and git-bash. The difference in commands is there's no further internal spawn...

@ryan-roemer
Copy link
Member

ryan-roemer commented Oct 6, 2017

Haha, it's cuh-razy time here. The narrow bug is a matter of "where is PATH in the OS shell?". A missing path is why the location of node (and other things) isn't found.

  • On Mac/Linux, it's process.env.PATH
  • On Windows + cmd it's process.env.Path (Even though both echo %PATH% and echo %Path% work the same on cmd shell, it's only Path in node land)
  • On Windows + MinGW / presumably other stuff it's process.env.PATH

The current logic detects "is Windows?" and uses Path. My plan is to update the code so if Windows is detected, search + update both Path and PATH

@ryan-roemer ryan-roemer changed the title 'node' is not recognized as an internal or external command, operable program or batch file [BUG] Windows: MinGW/Git Bash/Etc. use PATH env var instead of Path like cmd does. Oct 6, 2017
@ryan-roemer ryan-roemer added the bug label Oct 6, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants