我正在尝试使用 SSH 添加从 git 到诗歌的依赖性(我对 HTTPS 版本不感兴趣)。但无论我使用
poetry add
...,我都会收到错误
poetry add git+ssh://[email protected]:myorg/myproj.git
...或者如果我手动添加...
# Entry in pyproject.toml
myproj = { git = "[email protected]:myorg/myproj.git" }
# cmd
poetry install
在这两种情况下,我都会得到以下输出:
Stack trace:
11 ~\AppData\Roaming\pypoetry\venv\lib\site-packages\clikit\console_application.py:131 in run
status_code = command.handle(parsed_args, io)
10 ~\AppData\Roaming\pypoetry\venv\lib\site-packages\clikit\api\command\command.py:120 in handle
status_code = self._do_handle(args, io)
9 ~\AppData\Roaming\pypoetry\venv\lib\site-packages\clikit\api\command\command.py:171 in _do_handle
return getattr(handler, handler_method)(args, io, self)
8 ~\AppData\Roaming\pypoetry\venv\lib\site-packages\cleo\commands\command.py:92 in wrap_handle
return self.handle()
7 ~\AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\console\commands\add.py:106 in handle
requirements = self._determine_requirements(
6 ~\AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\console\commands\init.py:320 in _determine_requirements
requires = self._parse_requirements(requires)
5 ~\AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\console\commands\init.py:410 in _parse_requirements
package = Provider.get_package_from_vcs(
4 ~\AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\puzzle\provider.py:193 in get_package_from_vcs
git.clone(url, tmp_dir)
3 ~\AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\core\vcs\git.py:262 in clone
return self.run("clone", "--recurse-submodules", "--", repository, str(dest))
2 ~\AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\core\vcs\git.py:356 in run
subprocess.check_output(
1 ~\AppData\Local\Programs\Python\Python310\lib\subprocess.py:420 in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
CalledProcessError
Command '['C:\\Program Files\\Git\\cmd\\git.exe', 'clone', '--recurse-submodules', '--', '[email protected]:myorg/myproj.git', 'C:\\Users\\Adeom\\AppData\\Local\\Temp\\pypoetry-git-myprojwhjkd872g']' returned non-zero exit status 128.
at ~\AppData\Roaming\pypoetry\venv\lib\site-packages\poetry\utils\_compat.py:217 in run
213│ process.wait()
214│ raise
215│ retcode = process.poll()
216│ if check and retcode:
→ 217│ raise CalledProcessError(
218│ retcode, process.args, output=stdout, stderr=stderr
219│ )
220│ finally:
221│ # None because our context manager __exit__ does not use them.
Poetry 从来不会询问我的 SSH 密钥密码。我已经使用 ssh 从命令行测试了通过 git 进行克隆,效果很好。
我做错了什么?
您没有正确指定 git 路径。 git clone 和 pip/poetry 要求 GitHub 存储库路径的不同格式 你应该这样做
myproj = { git = "git+ssh://[email protected]/myorg/myproj.git" }
所以,具体来说:
git+ssh
:
分隔,而是由 /
分隔。我遇到了同样的问题,尝试直接使用 pip,但 pip 告诉我它找不到我的存储库。修复路径后,我上面写的内容就开始工作了。诗歌并不能真正解释正在发生的事情。
如果你的分支在GitHub上是
main
,你还需要通过添加branch=“main”来指定它,否则它会尝试做master。
我仍然有一个问题(仔细检查时不是这个问题),但是当仔细观察带有时间计数器的线时:
Resolving dependencies... (3.1s)
我注意到有一个闪光
Enter passphrase for key 'my_key_here':
所以我决定只输入密码来解锁 ssh 私钥,瞧,它起作用了......所以,时间计数器似乎掩盖了密码提示。