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

Node launcher does not handle quoted arguments #404

Closed
devversion opened this issue Nov 2, 2018 · 5 comments
Closed

Node launcher does not handle quoted arguments #404

devversion opened this issue Nov 2, 2018 · 5 comments
Labels
bug Can Close? We will close this in 30 days if there is no further activity

Comments

@devversion
Copy link
Contributor

Considering that we have a nodejs_binary that I want to run through Bazel (e.g. bazel run or through a genrule).

Now if my NodeJS script accepts a lot of CLI arguments which I need to group into a single argument in favor of making it work on Windows (there is an argument limit on windows)

  C:/Program Files/Git/usr/bin/bash.exe bazel-out/x64_windows-fastbuild/genfiles/src/material-examples/example-module.genrule_script.sh
The command line is too long.

So, instead of passing the arguments as individual ones, I now group them into one argument in order to work around this issue:

 $(location //tools/example-module:bin) --sourceFiles $(SRCS) --outputFile=$@
 # Changed to -->
 $(location //tools/example-module:bin) --sourceFiles "$(SRCS)" --outputFile=$@

Now, the command line is too long error is gone and it actually runs the :bin target which is a nodejs_binary. Unfortunately this script (the actual `node_launcher.sh) doesn't work either.

  C:/Program Files/Git/usr/bin/bash.exe bazel-out/x64_windows-fastbuild/genfiles/src/material-examples/example-module.genrule_script.sh
/usr/bin/bash: -c: line 0: unexpected EOF while looking for matching `"'
/usr/bin/bash: -c: line 1: syntax error: unexpected end of file

The $(SRCS) resolves into multiple source files (retrieved through a Bazel glob). I'm assuming that the node_launcher.sh script somehow expects the arguments to not include any quote.

@alexeagle
Copy link
Collaborator

maybe related to bazelbuild/bazel#4778 ?
argument parsing on Windows is a mess

@alexeagle alexeagle added the bug label Nov 19, 2018
@devversion
Copy link
Contributor Author

devversion commented Nov 19, 2018

@alexeagle Based on my understanding it's caused by

https://github.com/bazelbuild/rules_nodejs/blob/997f2a1d5b531cb8331c8760600ced1853636f23/internal/node/node_launcher.sh#L124

Where it wraps all passed arguments ($@) as a single argument. I can have a look into making this better. We should just concat the arguments, rather than wrapping them into a single argument I think.

@devversion
Copy link
Contributor Author

I see how it could be caused by the max length restriction of arguments on Windows, but usually it throws an explicit exception in case the argument limit has been exceeded. I will dig more into it.

alexeagle pushed a commit to alexeagle/rules_nodejs that referenced this issue Oct 17, 2020
…bazel/src/main/protobuf:worker_protocol.proto target in npm @bazel/typescript generated bazel workspace

Closes bazel-contrib#404

PiperOrigin-RevId: 232380639
alexeagle pushed a commit to alexeagle/rules_nodejs that referenced this issue Oct 18, 2020
…bazel/src/main/protobuf:worker_protocol.proto target in npm @bazel/typescript generated bazel workspace

Closes bazel-contrib#404

PiperOrigin-RevId: 232380639
@github-actions
Copy link

This issue has been automatically marked as stale because it has not had any activity for 90 days. It will be closed if no further activity occurs in two weeks. Collaborators can add a "cleanup" or "need: discussion" label to keep it open indefinitely. Thanks for your contributions to rules_nodejs!

@github-actions github-actions bot added the Can Close? We will close this in 30 days if there is no further activity label Nov 18, 2020
@github-actions
Copy link

github-actions bot commented Dec 2, 2020

This issue was automatically closed because it went two weeks without a reply since it was labeled "Can Close?"

@github-actions github-actions bot closed this as completed Dec 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Can Close? We will close this in 30 days if there is no further activity
Projects
None yet
Development

No branches or pull requests

2 participants