Hi! As we try to adopt pants in our team, it looks...
# general
p
Hi! As we try to adopt pants in our team, it looks like it fails to run for some of team members with this error, when running
pants --version
after fresh installation on MacOS (Ventura 13.2.1, in that case):
Copy code
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "\xF2\u{e}\xB3\xA3\x90\x9B\u{16}\xD0\u{1b}\xE2/&\u{6e0}\xA2\xE3a)\xA1\x86ǝ\u{80}\xD0j\x85\\\x9A"', library/std/src/env.rs:171:83
Output of the `get-pants.sh`:
Copy code
Downloading and installing the pants launcher ...
Installed the pants launcher from <https://github.com/pantsbuild/scie-pants/releases/latest/download/scie-pants-macos-x86_64> to /Users/developer/bin/pants

Running `pants` in a Pants-enabled repo will use the version of Pants configured for that repo.
In a repo not yet Pants-enabled, it will prompt you to set up Pants for that repo.
And the same error happens when using pants installed using homebrew, output of the installer also looks ok:
Copy code
Downloading <https://github.com/pantsbuild/scie-pants/releases/download/v0.8.1/scie-pants-macos-x86_64>
==> Downloading from <https://objects.githubusercontent.com/github-production-release-asset-2e65be/572180558/4a91212e-1f66-4b1d-8926-e54572ba86c7?X-Amz-Algorithm=AWS4-HMAC-S>
##################################################################################################################################################################### 100.0%
==> Installing Cask pants
==> Linking Binary 'scie-pants-macos-x86_64' to '/usr/local/bin/pants'
🍺  pants was successfully installed!
Any ideas how to debug this?
Also happens on MacOS Monterrey 12.6.5
I'm not sure if that's pants engine issue, or scie-pants binary instead...
r
What pants version are you using? There were some issues with some alpha release https://pantsbuild.slack.com/archives/C18RRR4JK/p1684722723180499?thread_ts=1684559520.904369&amp;cid=C18RRR4JK
p
We are on 2.16rc1, but this also happens when you call 'pants --version' in a folder with no pants.toml present...
We tried updating pants launcher but it's the latest one already (0.8.1)
b
Can you extract a full backtrace? Eg
RUST_BACKTRACE=1 pants version
From the rather opaque message, I might be looking for non-UTF8 environment variables, but that’s somewhat jumping to conclusions
p
Copy code
RUST_BACKTRACE=full pants --version
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "\xED\xEE%\u{348}\u{17}.\xAF{\xE9<\xFF]\u{f}\x8E\u{ed24}r\xB1\u{14}L"', library/std/src/env.rs:171:83
stack backtrace:
   0:        0x10e36df4a - __mh_execute_header
   1:        0x10e2adf3a - __mh_execute_header
   2:        0x10e34586c - __mh_execute_header
   3:        0x10e3746e3 - __mh_execute_header
   4:        0x10e37449a - __mh_execute_header
   5:        0x10e374bab - __mh_execute_header
   6:        0x10e374895 - __mh_execute_header
   7:        0x10e3747f8 - __mh_execute_header
   8:        0x10e3747c2 - __mh_execute_header
   9:        0x10e3bfcc3 - __mh_execute_header
  10:        0x10e3c00f5 - __mh_execute_header
  11:        0x10e2eb05c - __mh_execute_header
  12:        0x10e307b0c - __mh_execute_header
  13:        0x10e30583c - __mh_execute_header
  14:        0x10e305510 - __mh_execute_header
  15:        0x10e303821 - __mh_execute_header
  16:        0x10e3020c7 - __mh_execute_header
  17:        0x10e307538 - __mh_execute_header
  18:        0x10e30583c - __mh_execute_header
  19:        0x10e303821 - __mh_execute_header
  20:        0x10e3020c7 - __mh_execute_header
  21:        0x10e301ed3 - __mh_execute_header
  22:        0x10e2f41bb - __mh_execute_header
  23:        0x10e2a7b45 - __mh_execute_header
  24:        0x10e29c5a5 - __mh_execute_header
  25:        0x10e2aa7f0 - __mh_execute_header
b
Huh, that isn’t so informative 🙁
p
right:)
I will look into env variables
b
Yeah, looking at https://github.com/rust-lang/rust/blob/master/library/std/src/env.rs suggests it is failing when attempting to convert either an env var name or value to a Unicode string, so indeed checking the output of
env
for binary/non-Unicode data might be good
That said, assuming that’s the problem, it’d be good for scie-pants to not fail like this (especially if it’s an “unrelated” env var, not actually used by pants/scie-pants), so opening an issue in https://github.com/pantsbuild/scie-pants would be great. Thanks
p
still, it has to be a variable that pants actually needs, that has some non utf-8 chars I guess?
Is there a way to use pants from sources that has debug symbols making this trace above more useful? got it https://www.pantsbuild.org/docs/running-pants-from-sources
b
I suspect this might be failing in scie-pants, before it starts executing any pants code (based on the symptoms still appearing when running without a pants.toml), so you might need to build a debug version of that repo (linked above) rather than using a debug version of pants
👍 1
p
@broad-processor-92400 that was it!
once removed, it all works
🎉 1
thanks 🙂
I will create a ticket
👍 1
b
Yay, and thanks! Btw, if those values are secret keys for some service, they should be revoked, because the error message has the full contents and these messages are public
👍 1
p
BTW I've narrowed it down to a simple test case:
Copy code
$ env $'FOO=B\xa5R' pants --version                                                                                                                                                                                                                                            

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "B\xA5R"', library/std/src/env.rs:171:83
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
e
Yeah, so this will be a trail of tears. The issue is not in scie-pants, but in scie-jump - which it uses. Fixing that you get back to Pants issues:
Copy code
File "/home/jsirois/.cache/nce/8afd13c428e19f0d41030597d3ac01dab0a107a3cbc3b2db75bc719960aa0f4f/bindings/venv-3.9/lib/python3.9/site-packages/pants/bin/remote_pants_runner.py", line 151, in _connect_and_execute
    return PyNailgunClient(port, executor).execute(command, args, modified_env)
UnicodeEncodeError: 'utf-8' codec can't encode character '\udcf0' in position 10: surrogates not allowed
That's here: https://github.com/pantsbuild/pants/blob/main/src/rust/engine/src/externs/nailgun.rs#L50 I'll get this fixed up in the scie-pants stack and then I'll file an issue against Pants.
❤️ 2
There are actually two issues in Pants, both when connecting to pantsd: https://github.com/pantsbuild/pants/issues/19199