0

我正在使用cygwin内置的 git 和 python 来进行 Android 回购工具。

如果我设置CYGWIN=winsymlinks,一切正常。

如果我设置CYGWIN=winsymlinks:nativestrict告诉 cygwin 制作 Windows 本机符号链接并以管理员身份运行 cygwin,在 repo init 过程中,我会收到错误消息:

Traceback (most recent call last):
File "/cygdrive/d/repo/test/.repo/repo/main.py", line 506, in <module>
  _Main(sys.argv[1:])
File "/cygdrive/d/repo/test/.repo/repo/main.py", line 482, in _Main
  result = repo._Run(argv) or 0
File "/cygdrive/d/repo/test/.repo/repo/main.py", line 161, in _Run
  result = cmd.Execute(copts, cargs)
File "/cygdrive/d/repo/test/.repo/repo/subcmds/init.py", line 390, in Execute
  self._SyncManifest(opt)
File "/cygdrive/d/repo/test/.repo/repo/subcmds/init.py", line 239, in _SyncManifest
  m.Sync_LocalHalf(syncbuf)
File "/cygdrive/d/repo/test/.repo/repo/project.py", line 1196, in Sync_LocalHalf
  self._InitWorkTree()
File "/cygdrive/d/repo/test/.repo/repo/project.py", line 2293, in _InitWorkTree
  copy_all=False)
File "/cygdrive/d/repo/test/.repo/repo/project.py", line 2276, in _ReferenceGitDir
  os.symlink(os.path.relpath(src, os.path.dirname(dst)), dst)
OSError: [Errno 2] No such file or directory
4

1 回答 1

1

这是预期的行为,并且源于 NTFS 符号链接和 POSIX 符号链接模型之间的不兼容。来自 Cygwin 对CYGWIN 环境变量的帮助:

winsymlinks:native和之间的区别在于winsymlinks:nativestrict:如果文件系统支持本机符号链接并且 Cygwin 由于某种原因无法创建本机符号链接,它将回退到创建 Cygwin 默认符号链接 with winsymlinks:native,而 with系统调用winsymlinks:nativestrictsymlink(2)立即失败。

顺便说一句,你说你正在使用CYGWIN=winsymlinks,但我在帮助页面上没有看到这个确切的选项,所以我们只能猜测它对应于哪个变体(:lnk:native:nativestrict或其他东西)。

于 2015-05-21T01:16:08.190 回答