question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Install on Heroku fails with pip error

See original GitHub issue
  • I am on the latest Poetry version.

  • I have searched the issues of this repo and believe that this is not a duplicate.

  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

  • OS version and name:

  • Poetry version: 1.1.7

  • pyproject.toml

Issue

We use Poetry on Heroku to install our packages. For this, we list poetry==1.1.7 as sole dependency in our requirements.txt, and have a post-compile hook that looks like this:

python -m poetry config virtualenvs.create false
python -m poetry install --no-dev 2>&1

Additionally, we invalidate the cache in the pre-compile hook to ensure we always start with a clean environment and don’t have any old packages lying around:

echo "taint cache" > "$CACHE_DIR/.heroku/requirements.txt"

All in all this seems to work fine, however, we spuriously encounter errors like these:



-----> Running post-compile hook

-----> Installing dependencies with Poetry...

      Skipping virtualenv creation, as specified in config file.

      Installing dependencies from lock file

      

      Package operations: 91 installs, 7 updates, 4 removals

      

        • Removing packaging (20.9)

        • Removing pexpect (4.8.0)

        • Removing ptyprocess (0.7.0)

        • Removing pyparsing (2.4.7)

        • Updating six (1.16.0 -> 1.15.0)

        • Updating cffi (1.14.6 -> 1.14.5)

        • Installing jmespath (0.10.0)

        • Installing python-dateutil (2.8.1)

        • Updating urllib3 (1.26.6 -> 1.26.5)

        • Installing botocore (1.20.34)

        • Updating certifi (2021.5.30 -> 2020.12.5)

        • Installing chardet (3.0.4)

        • Updating cryptography (3.4.7 -> 3.4.6)

        • Installing defusedxml (0.7.1)

        • Installing et-xmlfile (1.0.1)

        • Updating idna (3.2 -> 2.10)

        • Installing multidict (5.1.0)

      

        EnvCommandError

      

        Command ['/app/.heroku/python/bin/python', '-m', 'pip', 'install', '--no-deps', '/app/.cache/pypoetry/artifacts/36/92/90/7beba42c3a6efbfdc30dc864c33286fa23817b3942b21ccaf319f18ed3/multidict-5.1.0-cp38-cp38-manylinux2014_x86_64.whl'] errored with the following return code 1, and output: 

        Processing /app/.cache/pypoetry/artifacts/36/92/90/7beba42c3a6efbfdc30dc864c33286fa23817b3942b21ccaf319f18ed3/multidict-5.1.0-cp38-cp38-manylinux2014_x86_64.whl

        Installing collected packages: multidict

        ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/tmp/build_8c19dde7/.heroku/python/lib/python3.8/site-packages/~dna-3.2.dist-info'

        

        WARNING: You are using pip version 20.2.4; however, version 21.1.3 is available.

        You should consider upgrading via the '/app/.heroku/python/bin/python -m pip install --upgrade pip' command.

This error is not specific to a single package, we saw it happen for different packages.

The error always is the No such file or directory for the .dist-info.

The file/directory that is not found always has the first character substituted by ~ which might be a name constructed by pip’s AdjacentTempDirectory.

As the error is only occurring spuriously and as I have no interactive access to the build environment, I am not really sure how I should best debug this further.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
cfracommented, Aug 3, 2021

@finswimmer this is a build on Heroku, not an interactive environment.

I cannot modify the environment and rerun from a specific step, I can just rerun the complete build.

Also, I cannot delete the ~dna-3.2.dist-info directory, as the directory is not there, as can be seen from the “No such file or directory error” in the log.

As for where the ~ is coming from:

Pip uses a class AdjacentTempDirectory to shuffle things around when it installs packages.

That class creates a temporary directory adjacent to another path.

For this, it replaces the first character of the path with ~.

Specifically, looking at my error log above, AdjacentTempDirectory will create a directory ~dna-3.2.dist-info when it is asked to create a directory adjacent to idna-3.2.dist-info.

Also, note that immediately prior to the error that happens when attempting to install multidict, we are updating idna.

So my assumption would be that the update and the install are being run in parallel which is apparently unsafe.

I think the pip updating idna creates a temporary directory ~dna-3.2.dist-info that is collected by the pip installing multidict, however the pip updating idna removes/renames that directory so that it just “vanishes” from the perspective of the pip installing multidict, leading to the “No such file or directory error” that can be seen above.

2reactions
uSpikecommented, Dec 6, 2021

I mentioned it in #4568 but I am seeing this issue as well. @cfra analysis looks sound. It seems that executing multiple pip operations in parallel where packages have shared dependencies is not safe for parallel execution.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Heroku pip install suddenly started to return an error
Heroku deploy started to return this error when trying to deploy a python app: -----> Installing requirements with pip Collecting ...
Read more >
Python Dependencies via Pip - Heroku Dev Center
This guide outlines how to fully utilize Heroku's support for specifying dependencies for your Python application via pip .
Read more >
Why does my app "fail to detect" a buildpack? - Heroku Help
This error message means that Heroku was unable to automatically detect the type of app you're trying to deploy: Ruby, Node, Python, PHP,...
Read more >
Heroku Error Codes
Whenever your app experiences an error, Heroku will return a standard error page with the HTTP status code 503.
Read more >
Python updated pip (new dependency resolver)
Dependency versions are now fully validated during installation and the pip install step will fail with a ResolutionImpossible error if ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found