我在~/.virtualenvs(为$WORKON_HOME变量定义的目录)下创建了许多virtualenvwrapper挂钩。

我通常喜欢将这样的系统文件保留在版本控制下-例如,我有一个非常定制的bash配置文件~/Repos/dotfiles/bash_profile,它与~/.bash_profile符号链接。

但是,当我尝试将virtualenvwrapper钩子移到~/Repos/dotfiles/virtualenvwrapper_hooks/下,然后将它们符号链接回到它们在~/.virtualenvs/下的原始文件名时,在打开新的Terminal窗口时出现以下错误:

stevedore.extension error calling 'user_scripts': [Errno 62] Too many levels of symbolic links: '/Users/yiqing/.virtualenvs/postactivate'
stevedore.extension [Errno 62] Too many levels of symbolic links: '/Users/yiqing/.virtualenvs/postactivate'
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/stevedore/extension.py", line 137, in _invoke_one_plugin
    response_callback(func(e, *args, **kwds))
  File "/Library/Python/2.7/site-packages/virtualenvwrapper/hook_loader.py", line 185, in invoke
    ext.plugin(args)
  File "/Library/Python/2.7/site-packages/virtualenvwrapper/user_scripts.py", line 143, in initialize
    make_hook(get_path('$VIRTUALENVWRAPPER_HOOK_DIR', filename), comment)
  File "/Library/Python/2.7/site-packages/virtualenvwrapper/user_scripts.py", line 124, in make_hook
    f = open(filename, 'w')
IOError: [Errno 62] Too many levels of symbolic links: '/Users/yiqing/.virtualenvs/postactivate'


符号链接整个目录(rm -rf ~/.virtualenvs ; ln -sF ...)也不起作用,因为当我尝试使用Tab键完成命令时,它会返回:

NOTE: Virtual environments directory /Users/yiqing/.virtualenvs does not exist. Creating...
mkdir: /Users/yiqing/.virtualenvs: Input/output error


除了在~/.virtualenvs中创建Git存储库之外,我想知道还有哪些其他选项可以将这些挂钩保持在版本控制之下?

最佳答案

我想到了!

令我沮丧的是,当我尝试对整个目录进行符号链接时,我意外地指出了相对路径而不是绝对路径。将绝对路径符号链接(提示:$PWD/将在制表符中完整显示为OS X中的完整路径):)

08-26 04:19