Hi there, I ran into a problem for which I couldn'...
# general
a
Hi there, I ran into a problem for which I couldn't find a solution yet. I'm trying to have
pyright
to work on a considerable list of files, basically what I get when I run
pants check ::
. The problem has to be related to
ARG_MAX
since I get flaky results on different architectures: for instance, it gets through on macOS, but not on Linux. It complains about
npi-cli
not being able to read the complete list form
stdin
. In our configuration, we used a workaround consisting in a piped combination of
pants list
and
xargs
, but it's far from an ideal solution since it less reliable, and it breaks the use of pants cache. By looking at the current implementation, I found out that
pyright
is called as
NodeJSToolRequest
command. Do you have any recommendation for this? I wonder whether it would be possible to split
NodeJSToolRequest
into multiple requests, or if this would break how Pants is intended to work.
b
To double-check your assumption re: `ARG_MAX`: what happens when you run this command on OSX vs Linux?
Copy code
getconf ARG_MAX
a
OSX:
Copy code
$ getconf ARG_MAX
1048576

$ gxargs --show-limits < /dev/null
Your environment variables take up 6817 bytes
POSIX upper limit on argument length (this system): 1039711
POSIX smallest allowable upper limit on argument length (all systems): 4096
Maximum length of command we could actually use: 1032894
Size of command buffer we are actually using: 131072
Maximum parallelism (--max-procs must be no greater): 2147483647
Linux:
Copy code
$ getconf ARG_MAX
2097152

$ gxargs --show-limits < /dev/null
Your environment variables take up 2010 bytes
POSIX upper limit on argument length (this system): 2093094
POSIX smallest allowable upper limit on argument length (all systems): 4096
Maximum length of command we could actually use: 2091084
Size of command buffer we are actually using: 131072
Maximum parallelism (--max-procs must be no greater): 2147483647
I might actually be wrong.
This is the error that I get:
Copy code
npm ERR! Cannot read properties of undefined (reading 'stdin')
b
Hmm, it looks like the
stdin
variable is undefined for whatever reason - my guess is that it’s due to the type of shell you’re using: https://stackoverflow.com/questions/76194360/npm-err-cannot-read-properties-of-undefined-reading-stdin-when-using-git-ba https://github.com/nodejs/help/issues/4138
a
I'm going to try that, thank you for the suggestion! However, it only happens when having very long lists of files, since I tried with
xargs
and different sizes, and it starts to break only after a certain threshold...
b
Got it - if this continues to be an issue, can you file an issue in the Pants project on Github with the details to reproduce? That way, if we need to modify the Pyright integration to support a larger number of files we can
a
No luck with this. Then yes, I will try to write a proper issue asap with a way to trigger the problem. Thanks!
I did a couple of tests more, and had a sort of success. I switched the package manager to
pnpm
and it appears that it works. This for the configuration in `pants.toml`:
Copy code
[nodejs]
package_manager = "pnpm"

[nodejs.package_managers]
pnpm = "8.14.0"
It gives me a warning though, I believe to print the name of the executable:
Copy code
._pnpm_home/store/v3/tmp/dlx-19116/node_modules/.bin/pyright: line 4: uname: command not found
e
Hi guys, little late for the party, but couple of our developers were facing the same issue on various distros (linux/windows) and even at our Gitlab runner. I managed to “fix” it with Pasquale suggestion and getting the same
uname
error. Thanks!