python-poetry / poetry

Python packaging and dependency management made easy
https://python-poetry.org
MIT License
31.76k stars 2.27k forks source link

POETRY_CACHE_DIR isn't applied during dependencies resolution #2519

Closed AlexisBRENON closed 2 years ago

AlexisBRENON commented 4 years ago

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)
sr-rolando commented 4 years ago

Setting HOME (right were you're setting POETRY_CACHE_DIR) is not an option?

AlexisBRENON commented 4 years ago

Setting HOME is an option (the one used for the moment) but not a clean one; overriding HOME can have some weird effects on Jenkins...

Le mer. 15 juil. 2020 22:01, Señor Rolando notifications@github.com a écrit :

Setting HOME (right were you're setting POETRY_CACHE_DIR) is not an option?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/python-poetry/poetry/issues/2519#issuecomment-658978536, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOCWHXY3IABVJS4WXAAOC3R3YDK5ANCNFSM4NYMEM3A .

dylrich commented 4 years ago

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.

usinelogicielle commented 2 years ago

Hi,

I have the same problem. When I run "poetry config list", I'm not sure the cache-dir is overidden.

poetry config --list
2022-06-03 09:30:03  cache-dir = "/home/il/jenkins/.cache/pypoetry"  # /tmp/srv_jenkins/workspace/url_feature_check_confluence_url/pypoetry
abn commented 2 years ago

Should be resolved with #5672.

github-actions[bot] commented 8 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.