Can't install XPT2046 Touchscreen library

I am trying to add Paul Stoffregen’s XPT2046 Touchscreen library to a project but the installation fails.

My platformio.ini file:

[env:esp32dev]
  platform = espressif32
  board = esp32dev
  framework = arduino
  lib_deps =
    https://github.com/PaulStoffregen/XPT2046_Touchscreen.git

What happens when I save platformio.ini:

Resolving esp32dev dependencies...
Library Manager: Installing git+https://github.com/PaulStoffregen/XPT2046_Touchscreen.git
git version 2.50.1
Cloning into '/Users/dpatterson/.platformio/.cache/tmp/pkg-installing-cobcs9qw'...
fatal: not a git repository: '?]1337;SetBadgeFormat=LW4gbWFjcHJvLTIwMTkuZHBjCnRtcC9wa2ctaW5zdGFsbGluZy1jb2Jjczlxdy8uZ2l0Cgo=?/Users/dpatterson/.platformio/.cache/tmp/pkg-installing-cobcs9qw/.git'
fatal: /usr/local/opt/git/libexec/git-core/git-submodule cannot be used without a working tree.
VCSBaseException: VCS: Could not process command ['git', 'clone', '--recursive', '--depth', '1', 'https://github.com/PaulStoffregen/XPT2046_Touchscreen.git', '/Users/dpatterson/.platformio/.cache/tmp/pkg-installing-cobcs9qw']

Suggestions?

TIA

D.

Does

git clone https://github.com/PaulStoffregen/XPT2046_Touchscreen.git

on a regular terminal / command line work?

PlatofrmIO is just invoking your system’s git command.

Yes. Cloning from the command line works.

From a commandline within your project folder

rm -rf /Users/dpatterson/.platformio/.cache/
rm -rf .pio

And build again.

Still get the same error.

Then something is wrong in the shell environment for PlatformIO.

Does the git clone command work in a PlatformIO Core CLI still?

Yes. Cloning works from there.

Iv’e used git lib_deps before without issue.

Is there a way to see the actual command issued by PIO?

The exact comman executed is there as the command args array:

Except that isn’t the actual command. That is what the command is built from.

Anyway, I have figured out where some of the strangeness of the error message is coming from. In

fatal: not a git repository: '?]1337;SetBadgeFormat=LW4gbWFjcHJvLTIwMTkuZHBjCnRtcC9wa2ctaW5zdGFsbGluZy1mcXl0NHppZi8uZ2l0Cgo=?

The “?]1337;SetBadgeFormat=…” is the output of a bash function that is part of my standard setup. The apparent garbage following it is actually base64-encoded text that decodes to “tmp/pkg-installing-fqyt4zif/.git”. That’s the temporary directory that the repository is being cloned to.

What I don’t know is how that is getting into the command stream. The function in question is called by my cd function when I change directories to update the iTerm “badge” with the current directory.

I tried issuing pio pkg install -l https://github.com/PaulStoffregen/XPT2046_Touchscreen.git and it fails with the same error.

How on earth is the output from a bash printf getting into the command input stream?

When you have the minimal Python script

import subprocess
cmd = [
    'git', 'clone', 
    '--recursive', '--depth', '1', 
    'https://github.com/PaulStoffregen/XPT2046_Touchscreen.git', 
    'git_clone_test']
subprocess.run(cmd, shell=True)

And you execute it in this iTerminal terminal, does it also fail?

Does it still fail with shell=False and git replaced to the path of git, likely /usr/bin/git?

That fails with a git usage error.

Okay, that’s weird.

Specifying shell=False works.

I don’t know enough about Python internals to understand what’s happening here.