eclipse-langium / langium

Next-gen language engineering / DSL framework
https://langium.org/
MIT License
754 stars 68 forks source link

cli command shown in "langium-quickstart.md" is not correct #1251

Closed tomsontom closed 1 year ago

tomsontom commented 1 year ago

Langium version: 2.0.0 Package name: langium-generator

Steps To Reproduce

  1. generate hello-world sample
  2. try running the advertised ./bin/cli which leads to the following error (on OS-X)
    ./bin/cli
    zsh: no such file or directory: ./bin/cli

The current behavior

Command shown langium-quickstart.md does not work.

The expected behavior

Command shown in langium-quickstart.md should work unversially

Possible ways to solve

If not mistaken although I think shebang-lines don't work on Windows so I think the proper way is to change the readme to use the 2nd option

sailingKieler commented 1 year ago

@tomsontom, @msujew I don't see why this is not working, esp. because of the first line in the generated bin/cli.js: https://github.com/eclipse-langium/langium/blob/6f22f22b7ff67a88061b16c46087d92c57a6d596/packages/generator-langium/templates/cli/bin/cli.js#L1 Actually, it's deliberately supposed to work without calling node explicitly.

Just gave it a try on my own:

image
msujew commented 1 year ago

@sailingKieler You fail to see it, because you have a Mac :)

It didn't work on Windows (as mentioned in the initial issue comment). Windows is fairly strict about what it accepts as an executable via the command line - which is why calling node first is necessary on Windows. Closing the issue.

sailingKieler commented 1 year ago

Indeed, I thought in that direction but the description says:

image

And the zsh: confused me 😉

msujew commented 1 year ago

Hm, I see. No idea, though using node should work anyway as expected ¯\_(ツ)_/¯

tomsontom commented 1 year ago

@sailingKieler - correct the error from above is produced on my OS-X

@msujew - on windows (unless you run in WSL) I don't think windows can do anything with #!/usr/bin/env node - at least I would be very suprised and according to https://stackoverflow.com/questions/10396305/npm-package-bin-script-for-windows it is simply ignored but I confess I have not tried but as you wrote using "node" is the safeway and works just anywhere.

sailingKieler commented 1 year ago

@tomsontom you're right, since v2.0 ./bin/cli will be generated as ./bin/cli.js. (I had v1.0.0 in my global installation.)

@msujew what's the rationale for this renaming? See https://github.com/eclipse-langium/langium/commit/eea5bc2b5621cc8a321c4b95d4ca63f0aa5324fe#diff-78f8cabeb67c251201d63c1fc548b398062430670a22c6f5664def651d1a8f1a

tomsontom commented 1 year ago

Well I think this how it is supposed to be in node/npm - if you package this up then npm automatically creates the wrapper so that the end user can really run "./bin/cli" - It is also mentionned in the stackoverflow link from above