如何在$ WORKON_HOME之外的版本控制下保持virtualenvwrapper挂钩

时间:2013-06-25 17:32:23

标签: python version-control symlink virtualenvwrapper

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

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

然而,当我尝试在~/Repos/dotfiles/virtualenvwrapper_hooks/下移动virtualenvwrapper挂钩然后将它们符号化回~/.virtualenvs/下的原始文件名时,我在打开一个新的终端窗口时出现以下错误:

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'

Symlinking整个目录(rm -rf ~/.virtualenvs ; ln -sF ...)也不起作用,因为当我尝试tab-complete命令时,它会返回:

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

如果没有在~/.virtualenvs中创建Git仓库,我想知道我有什么其他选择来保持这些钩子在版本控制下?

1 个答案:

答案 0 :(得分:1)

我想出来了!

令我沮丧的是,当我尝试对整个目录进行符号链接时,我意外地指出了相对路径而不是绝对路径。 Symlinking绝对路径(protip:$PWD/将选项卡完成到OS X中的完整路径)将起作用:)