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.

I’d ditch iTerm or ask their support on why that happens.

Yeah. Not the answer.

iTerm is a very capable terminal app for the Mac that I have been using for many years.

One of its nice capabilities is to display a “badge” in the upper-right corner of the window. This badge can contain whatever text you like and is updated by sending proprietary escape sequences to the terminal.

I use this functionality in my change-directory (cd) script to update the badge with the current host name, current directory, and current git branch (if the current directory is a git repository).

It appears that the pio pkg install command script performs a cd at some point and is capturing and attempting to process the escape sequence that my cd script sends to update the badge.

iTerm, itself, has nothing to do with this problem.

I did a little digging and in platformio-core/platformio/package/manager/base.py in the call_pkg_script() function is a line that starts with with fs.cd(pkg.path):. That class does call os.chdir() in its __enter__() and __exit__() methods.

As I said, I’m no python expert so I haven’t been able to get any farther yet.

D.

CC @ivankravets weird bug on MacOS + iTerm during regular package installation, should be triggerable with pio pkg install -g -l https://github.com/PaulStoffregen/XPT2046_Touchscreen.git