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.

POETRY_CACHE_DIR isn't applied during dependencies resolution

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).

Issue

I try to use poetry for CI build, hence setting the POETRY_CACHE_DIR environment variable. While virtual environment is created in the right directory, a lock file try to be created in ~/.cache/.... However in CI build environment, HOME is not set so I got an error:

poetry update -vvv

Creating virtualenv ...-Bvcf6ELA-py3.8 in /tmp/jenkins-bf642f55/workspace/.../pypoetry/virtualenvs
Using virtualenv: /tmp/jenkins-bf642f55/workspace/.../pypoetry/virtualenvs/...-Bvcf6ELA-py3.8
Updating dependencies
Resolving dependencies...
   1: fact: ... is 0.0.0
   1: derived: ...
   1: fact: ... depends on kafka-python (^2.0.1)
   1: fact: ... depends on prometheus_client (^0.7.1)
   1: fact: ... depends on python-snappy (^0.5.4)
   1: fact: ... depends on msgpack (^1.0.0)
   1: fact: ... depends on pytest (^4.6)
   1: fact: ... depends on coverage (^5.0.3)
   1: fact: ... depends on pytest (^4.6)
   1: fact: ... depends on coverage (^5.0.3)
   1: selecting ... (0.0.0)
   1: derived: coverage (^5.0.3)
   1: derived: pytest (^4.6)
   1: derived: msgpack (^1.0.0)
   1: derived: python-snappy (^0.5.4)
   1: derived: prometheus_client (^0.7.1)
   1: derived: kafka-python (^2.0.1)
   1: Version solving took 0.036 seconds.
   1: Tried 1 solutions.

[LockFailed]
failed to create /.cache/pypoetry/cache/repositories/pypi/_http/2/9/a/b/8/4ea91933c570-4d0d4740.173908512058976494407

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/clikit/console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "/usr/local/lib/python3.8/site-packages/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/usr/local/lib/python3.8/site-packages/clikit/api/command/command.py", line 171, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "/usr/local/lib/python3.8/site-packages/cleo/commands/command.py", line 92, in wrap_handle
    return self.handle()
  File "/usr/local/lib/python3.8/site-packages/poetry/console/commands/update.py", line 49, in handle
    return installer.run()
  File "/usr/local/lib/python3.8/site-packages/poetry/installation/installer.py", line 74, in run
    self._do_install(local_repo)
  File "/usr/local/lib/python3.8/site-packages/poetry/installation/installer.py", line 161, in _do_install
    ops = solver.solve(use_latest=self._whitelist)
  File "/usr/local/lib/python3.8/site-packages/poetry/puzzle/solver.py", line 36, in solve
    packages, depths = self._solve(use_latest=use_latest)
  File "/usr/local/lib/python3.8/site-packages/poetry/puzzle/solver.py", line 180, in _solve
    result = resolve_version(
  File "/usr/local/lib/python3.8/site-packages/poetry/mixology/__init__.py", line 7, in resolve_version
    return solver.solve()
  File "/usr/local/lib/python3.8/site-packages/poetry/mixology/version_solver.py", line 80, in solve
    next = self._choose_package_version()
  File "/usr/local/lib/python3.8/site-packages/poetry/mixology/version_solver.py", line 350, in _choose_package_version
    dependency = min(*unsatisfied, key=_get_min)
  File "/usr/local/lib/python3.8/site-packages/poetry/mixology/version_solver.py", line 343, in _get_min
    return len(self._provider.search_for(dependency))
  File "/usr/local/lib/python3.8/site-packages/poetry/puzzle/provider.py", line 140, in search_for
    packages = self._pool.find_packages(
  File "/usr/local/lib/python3.8/site-packages/poetry/repositories/pool.py", line 148, in find_packages
    packages += repo.find_packages(
  File "/usr/local/lib/python3.8/site-packages/poetry/repositories/pypi_repository.py", line 104, in find_packages
    info = self.get_package_info(name)
  File "/usr/local/lib/python3.8/site-packages/poetry/repositories/pypi_repository.py", line 256, in get_package_info
    return self._cache.store("packages").remember_forever(
  File "/usr/local/lib/python3.8/site-packages/cachy/repository.py", line 174, in remember_forever
    val = value(callback)
  File "/usr/local/lib/python3.8/site-packages/cachy/helpers.py", line 6, in value
    return val()
  File "/usr/local/lib/python3.8/site-packages/poetry/repositories/pypi_repository.py", line 257, in <lambda>
    name, lambda: self._get_package_info(name)
  File "/usr/local/lib/python3.8/site-packages/poetry/repositories/pypi_repository.py", line 261, in _get_package_info
    data = self._get("pypi/{}/json".format(name))
  File "/usr/local/lib/python3.8/site-packages/poetry/repositories/pypi_repository.py", line 356, in _get
    json_response = self._session.get(self._base_url + endpoint)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 543, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 683, in send
    r.content
  File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 829, in content
    self._content = b''.join(self.iter_content(CONTENT_CHUNK_SIZE)) or b''
  File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 751, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File "/usr/local/lib/python3.8/site-packages/urllib3/response.py", line 576, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "/usr/local/lib/python3.8/site-packages/urllib3/response.py", line 519, in read
    data = self._fp.read(amt) if not fp_closed else b""
  File "/usr/local/lib/python3.8/site-packages/cachecontrol/filewrapper.py", line 65, in read
    self._close()
  File "/usr/local/lib/python3.8/site-packages/cachecontrol/filewrapper.py", line 52, in _close
    self.__callback(self.__buf.getvalue())
  File "/usr/local/lib/python3.8/site-packages/cachecontrol/controller.py", line 308, in cache_response
    self.cache.set(
  File "/usr/local/lib/python3.8/site-packages/cachecontrol/caches/file_cache.py", line 126, in set
    with self.lock_class(name) as lock:
  File "/usr/local/lib/python3.8/site-packages/lockfile/__init__.py", line 197, in __enter__
    self.acquire()
  File "/usr/local/lib/python3.8/site-packages/lockfile/linklockfile.py", line 21, in acquire
    raise LockFailed("failed to create %s" % self.unique_name)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
dylrichcommented, Oct 1, 2020

I had the same issue with Jenkins – setting $HOME as a hack works for now but it’d be nice if poetry fell back to the current directory if $HOME isn’t available.

0reactions
abncommented, Jun 3, 2022

Should be resolved with #5672.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration | Documentation | Poetry - Python dependency ...
If not set explicitly, poetry by default will create virtual environment under {cache-dir}/virtualenvs or use the {project-dir}/.venv directory when one is ...
Read more >
'poetry install' command fails; *.whl files are not found
It seems to be related to poetry cache. ... it works as intended if i go to User\user\AppData\Local\pypoetry and I delete the cache...
Read more >
Poetry a smart way of packaging and dependency ... - LinkedIn
Poetry is a tool for dependency management and packaging in Python. It allows you to declare the libraries your project depends on and...
Read more >
Dependency Management With Python Poetry
While this tutorial focuses on dependency management, Poetry can also help you ... in the virtualenvs/ folder of Poetry's cache directory: ...
Read more >
A Poetic Apology. Or Why Should You Use Poetry to Manage…
lock file already exists, if you now run poetry install then Poetry will resolve and install dependencies using the versions specified in such...
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