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

Failed to run "peggy" on windows, "-S.exe" is missing, what's this? #514

Closed
fy0 opened this issue Apr 27, 2024 · 15 comments · Fixed by #555
Closed

Failed to run "peggy" on windows, "-S.exe" is missing, what's this? #514

fy0 opened this issue Apr 27, 2024 · 15 comments · Fixed by #555

Comments

@fy0
Copy link

fy0 commented Apr 27, 2024

> yarn global add peggy
> peggy
'-S' is not recognized as an internal or external command, operable program or batch file.

I searched peggy.cmd on my computer, i found it use "-S.exe" to load peggy whether "-S" exists or not:

@IF EXIST "%~dp0\-S.exe" (
  "%~dp0\-S.exe"  node --experimental-vm-modules --no-warnings "%~dp0\..\peggy\bin\peggy.js" %*
) ELSE (
  @SETLOCAL
  @SET PATHEXT=%PATHEXT:;.JS;=;%
  -S  node --experimental-vm-modules --no-warnings "%~dp0\..\peggy\bin\peggy.js" %*
)

env:

> node -v
v20.9.0

Is this situation a bug? it can works if i removed -S of ELSE case.

@hildjj
Copy link
Contributor

hildjj commented Apr 27, 2024

I haven't tried installing with yarn or on windows. Can you help us narrow this down by trying:

  • A yarn local install, then using npx, yarn run peggy, and peggy from a package.json scripts entry
  • An npm local install, then using npx and peggy from a package.json scripts entry
  • An npm global install, then using peggy by itself

I don't have easy access to a Windows dev environment at the moment, so trying out some options will help a lot. Thanks!

@hildjj
Copy link
Contributor

hildjj commented Apr 27, 2024

What version of yarn are you using? When I try yarn global add peggy on yarn@4.1.1, I get:

Usage Error: The 'yarn global' commands have been removed in 2.x - consider using 'yarn dlx' or a third-party plugin instead

@fy0
Copy link
Author

fy0 commented May 4, 2024

What version of yarn are you using? When I try yarn global add peggy on yarn@4.1.1, I get:

Usage Error: The 'yarn global' commands have been removed in 2.x - consider using 'yarn dlx' or a third-party plugin instead

Thx for reply, i use yarn 1.22.
Now it's already not a problem for me.

I forked pigeon(one of golang's peg tool), then rewrote it to generate haxe code.
Now i can use my pigeon version to generate js peg parser!

And seems yarn is not much better than npm since 2024(and 1.x is not maintained), maybe i should switch back to npm, or use pnpm to instead.

@fy0 fy0 closed this as completed May 4, 2024
@lhsantos
Copy link

lhsantos commented Sep 19, 2024

I am experiencing this issue, and I think it has nothing to do with yarn itself. I hadn't noticed it before because I normally use WSL, but when I had to test the system in the Windows host, I found this issue. Using an earlier version of peggy, such as 3.0.2 or 2.0.1 on Windows, or using the latest version on WSL (Ubuntu), both cases by running with yarn, does not cause any problems.

@hildjj
Copy link
Contributor

hildjj commented Sep 19, 2024

@lhsantos does it work with npx peggy or npm install peggy -g?

@hildjj hildjj reopened this Sep 19, 2024
@lhsantos
Copy link

For npx peggy --version with latest version installed locally, same error.
After installing peggy globally, npm install -g peggy, then running in some non node directory, npx peggy --version, same error.

@hildjj
Copy link
Contributor

hildjj commented Sep 19, 2024

npx peggy won't look for the global one. Try just peggy -version after npm install -g peggy.

@hildjj
Copy link
Contributor

hildjj commented Sep 19, 2024

Note: I'm assuming that whatever yarn version you have isn't installing the same wrapper .bat file that npm does, and trying to see if that's actually true.

@lhsantos
Copy link

npx peggy won't look for the global one. Try just peggy -version after npm install -g peggy.

Just peggy does not find the command, and I did run npx peggy in a non-node project directory, so the only one it could find would be the global one...

@lhsantos
Copy link

lhsantos commented Sep 20, 2024

npx peggy won't look for the global one. Try just peggy -version after npm install -g peggy.

Just peggy does not find the command, and I did run npx peggy in a non-node project directory, so the only one it could find would be the global one...

Ah, sorry, actually peggy --version does find the command, it just ends with the same error related to '-S.exe'

@hildjj hildjj mentioned this issue Sep 24, 2024
16 tasks
hildjj added a commit to hildjj/peggy that referenced this issue Sep 29, 2024
Handle node runtime flags manually, executing a sub-instance of node to actually run `peggy`.

Fixes peggyjs#514.
@david-sharer
Copy link

david-sharer commented Sep 30, 2024

I tested the PR on my machine and it seems to work across git bash, cmd, and powershell. Used these:

  • yarn global add classic 1.22.22
  • npm install --global 10.2.3
  • npx
  • yarn dlx (modern 4.5.0)

But then it got a bit weird.
I tested the prior commands as well, and they only seemed to work w/ npm under cmd.
... but going back to double check the older versions, they all work for me on npm now?
and I don't see the @IF EXIST "%~dp0\-S.exe" mentioned in OP anymore, instead it is IF EXIST "%dp0%\node.exe"
This is the case with 3.0.2, 4.0.0, 4.0.3, and the PR.

@hildjj
Copy link
Contributor

hildjj commented Sep 30, 2024

I thought it was supposed to have been working on NPM for quite a while. On yarn, there is this bug:

yarnpkg/berry#6305

that isn't marked fixed yet.

@david-sharer
Copy link

david-sharer commented Sep 30, 2024

IIRC it broke with npm via git bash via VS Code.

But I looked closer at the old image and it looks like despite which reporting the correct location, the error it spat out references yarn.

So I guess some environment caching nonsense was at play?

@hildjj
Copy link
Contributor

hildjj commented Sep 30, 2024

I continue to thing that this is a yarn bug. With a modern npm or pnpm, the correct command wrapper should be written.

Another way to solve this would be to document this case with "Yarn is broken. Do not use it to install peggy until bug 6305 is fixed."

@hildjj
Copy link
Contributor

hildjj commented Sep 30, 2024

Yet another approach would be to land #555 but add a new bug to remove that code if yarn's 6305 is fixed. That seems like the best short-term approach.

hildjj added a commit to hildjj/peggy that referenced this issue Sep 30, 2024
Handle node runtime flags manually, executing a sub-instance of node to actually run `peggy`.

Fixes peggyjs#514.
@hildjj hildjj closed this as completed in 2c5239e Oct 2, 2024
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

Successfully merging a pull request may close this issue.

4 participants