微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

预提交无法在Docker容器中运行

如何解决预提交无法在Docker容器中运行

我尝试在dockerized开发环境中安装pre-commit==1.20.0,只是为了允许我们手动运行pre-commit run --all-files。但是,它失败了,并且我无法破译错误。我推测作为我们的Docker容器一部分的额外索引正在触发预提交,但不确定。

这是/etc/pip.conf内容

[global]
extra-index-url=https://pkgs.dev.azure.com/COMPANY/PROJECT/_packaging/mi_r00397_shared/pypi/simple/

我知道这可行,因为通常我们必须调用pip install package --extra-index-url https://pkgs.dev.azure.com/COMPANY/PROJECT/_packaging/mi_r00397_shared/pypi/simple/ 来安装软件包,而pip.conf已成功实现并且pip install package就足够了。

我在pre-commit run --all-files上遇到的错误如下:

pre-commit run --all-files
[INFO] Installing environment for https://github.com/ambv/black.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: Command: ('/home/thomas/.cache/pre-commit/repoa3dsqwwo/py_env-python3.6/bin/python','/home/thomas/.cache/pre-commit/repoa3dsqwwo/py_env-python3.6/bin/pip','install','.')
Return code: 1
Expected return code: 0
Output:
    Looking in indexes: https://pypi.org/simple,https://pkgs.dev.azure.com/COMPANY/PROJECT/_packaging/mi_r00397_shared/pypi/simple/
    Processing /home/thomas/.cache/pre-commit/repoa3dsqwwo
      Installing build dependencies: started
      Installing build dependencies: finished with status 'error'
    User for pkgs.dev.azure.com:
Errors:
      ERROR: Command errored out with exit status 2:
       command: /home/thomas/.cache/pre-commit/repoa3dsqwwo/py_env-python3.6/bin/python /home/thomas/.cache/pre-commit/repoa3dsqwwo/py_env-python3.6/lib/python3.6/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-che1xbcz/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple --extra-index-url https://pkgs.dev.azure.com/COMPANY/PROJECT/_packaging/mi_r00397_shared/pypi/simple/ -- 'setuptools>=41.0' setuptools-scm wheel
           cwd: None
      Complete output (51 lines):
      Looking in indexes: https://pypi.org/simple,https://pkgs.dev.azure.com/COMPANY/PROJECT/_packaging/mi_r00397_shared/pypi/simple/,https://pkgs.dev.azure.com/COMPANY/PROJECT/_packaging/mi_r00397_shared/pypi/simple/
      User for pkgs.dev.azure.com: ERROR: Exception:
      Traceback (most recent call last):
        File "/home/thomas/.cache/pre-commit/repoa3dsqwwo/py_env-python3.6/lib/python3.6/site-packages/pip/_internal/cli/base_command.py",line 216,in _main
          status = self.run(options,args)
        File "/home/thomas/.cache/pre-commit/repoa3dsqwwo/py_env-python3.6/lib/python3.6/site-packages/pip/_internal/cli/req_command.py",line 182,in wrapper
          return func(self,options,args)
        File "/home/thomas/.cache/pre-commit/repoa3dsqwwo/py_env-python3.6/lib/python3.6/site-packages/pip/_internal/commands/install.py",line 325,in run
          reqs,check_supported_wheels=not options.target_dir
        File "/home/thomas/.cache/pre-commit/repoa3dsqwwo/py_env-python3.6/lib/python3.6/site-packages/pip/_internal/resolution/legacy/resolver.py",line 183,in resolve
          discovered_reqs.extend(self._resolve_one(requirement_set,req))
        File "/home/thomas/.cache/pre-commit/repoa3dsqwwo/py_env-python3.6/lib/python3.6/site-packages/pip/_internal/resolution/legacy/resolver.py",line 388,in _resolve_one
          abstract_dist = self._get_abstract_dist_for(req_to_install)
        File "/home/thomas/.cache/pre-commit/repoa3dsqwwo/py_env-python3.6/lib/python3.6/site-packages/pip/_internal/resolution/legacy/resolver.py",line 339,in _get_abstract_dist_for
          self._populate_link(req)
        File "/home/thomas/.cache/pre-commit/repoa3dsqwwo/py_env-python3.6/lib/python3.6/site-packages/pip/_internal/resolution/legacy/resolver.py",line 305,in _populate_link
          req.link = self._find_requirement_link(req)
        File "/home/thomas/.cache/pre-commit/repoa3dsqwwo/py_env-python3.6/lib/python3.6/site-packages/pip/_internal/resolution/legacy/resolver.py",line 270,in _find_requirement_link
          best_candidate = self.finder.find_requirement(req,upgrade)
        File "/home/thomas/.cache/pre-commit/repoa3dsqwwo/py_env-python3.6/lib/python3.6/site-packages/pip/_internal/index/package_finder.py",line 899,in find_requirement
          req.name,specifier=req.specifier,hashes=hashes,File "/home/thomas/.cache/pre-commit/repoa3dsqwwo/py_env-python3.6/lib/python3.6/site-packages/pip/_internal/index/package_finder.py",line 881,in find_best_candidate
          candidates = self.find_all_candidates(project_name)
        File "/home/thomas/.cache/pre-commit/repoa3dsqwwo/py_env-python3.6/lib/python3.6/site-packages/pip/_internal/index/package_finder.py",line 826,in find_all_candidates
          project_url,link_evaluator=link_evaluator,line 790,in process_project_url
          html_page = self._link_collector.fetch_page(project_url)
        File "/home/thomas/.cache/pre-commit/repoa3dsqwwo/py_env-python3.6/lib/python3.6/site-packages/pip/_internal/index/collector.py",line 643,in fetch_page
          return _get_html_page(location,session=self.session)
        File "/home/thomas/.cache/pre-commit/repoa3dsqwwo/py_env-python3.6/lib/python3.6/site-packages/pip/_internal/index/collector.py",line 455,in _get_html_page
          resp = _get_html_response(url,session=session)
        File "/home/thomas/.cache/pre-commit/repoa3dsqwwo/py_env-python3.6/lib/python3.6/site-packages/pip/_internal/index/collector.py",line 169,in _get_html_response
          "Cache-Control": "max-age=0",File "/home/thomas/.cache/pre-commit/repoa3dsqwwo/py_env-python3.6/lib/python3.6/site-packages/pip/_vendor/requests/sessions.py",line 543,in get
          return self.request('GET',url,**kwargs)
        File "/home/thomas/.cache/pre-commit/repoa3dsqwwo/py_env-python3.6/lib/python3.6/site-packages/pip/_internal/network/session.py",line 421,in request
          return super(PipSession,self).request(method,*args,**kwargs)
        File "/home/thomas/.cache/pre-commit/repoa3dsqwwo/py_env-python3.6/lib/python3.6/site-packages/pip/_vendor/requests/sessions.py",line 530,in request
          resp = self.send(prep,**send_kwargs)
        File "/home/thomas/.cache/pre-commit/repoa3dsqwwo/py_env-python3.6/lib/python3.6/site-packages/pip/_vendor/requests/sessions.py",line 650,in send
          r = dispatch_hook('response',hooks,r,**kwargs)
        File "/home/thomas/.cache/pre-commit/repoa3dsqwwo/py_env-python3.6/lib/python3.6/site-packages/pip/_vendor/requests/hooks.py",line 31,in dispatch_hook
          _hook_data = hook(hook_data,**kwargs)
        File "/home/thomas/.cache/pre-commit/repoa3dsqwwo/py_env-python3.6/lib/python3.6/site-packages/pip/_internal/network/auth.py",line 256,in handle_401
          username,password,save = self._prompt_for_password(parsed.netloc)
        File "/home/thomas/.cache/pre-commit/repoa3dsqwwo/py_env-python3.6/lib/python3.6/site-packages/pip/_internal/network/auth.py",line 226,in _prompt_for_password
          username = ask_input("User for {}: ".format(netloc))
        File "/home/thomas/.cache/pre-commit/repoa3dsqwwo/py_env-python3.6/lib/python3.6/site-packages/pip/_internal/utils/misc.py",line 259,in ask_input
          return input(message)
      EOFError: EOF when reading a line
      User for pkgs.dev.azure.com:
      ----------------------------------------
    ERROR: Command errored out with exit status 2: /home/thomas/.cache/pre-commit/repoa3dsqwwo/py_env-python3.6/bin/python /home/thomas/.cache/pre-commit/repoa3dsqwwo/py_env-python3.6/lib/python3.6/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-che1xbcz/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple --extra-index-url https://pkgs.dev.azure.com/COMPANY/PROJECT/_packaging/mi_r00397_shared/pypi/simple/ -- 'setuptools>=41.0' setuptools-scm wheel Check the logs for full command output.

Check the log at /home/thomas/.cache/pre-commit/pre-commit.log

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。