Error: parent directory is world writable but not sticky

mingaixin發表於2017-01-18

在本地安裝pyenv的時候,出現瞭如下的報錯:

➜   brew install pyenv
==> Downloading https://github.com/yyuu/pyenv/archive/v20160310.tar.gz
Already downloaded: /Library/Caches/Homebrew/pyenv-20160310.tar.gz
Error: parent directory is world writable but not sticky
Please report this bug:
    https://git.io/brew-troubleshooting
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/tmpdir.rb:92:in `mktmpdir'
/usr/local/Library/Homebrew/utils/fork.rb:6:in `safe_fork'
/usr/local/Library/Homebrew/formula_installer.rb:572:in `build'
/usr/local/Library/Homebrew/formula_installer.rb:231:in `install'
/usr/local/Library/Homebrew/cmd/install.rb:214:in `install_formula'
/usr/local/Library/Homebrew/cmd/install.rb:93:in `block in install'
/usr/local/Library/Homebrew/cmd/install.rb:93:in `each'
/usr/local/Library/Homebrew/cmd/install.rb:93:in `install'
/usr/local/Library/brew.rb:83:in `<main>'

解決方法:
先檢視自己本機 /private/tmp 的資料夾的讀寫許可權,在我的mac機器上如下:

➜  ls -ld /tmp
lrwxr-xr-x@ 1 root  wheel  11 11 13  2014 /tmp -> private/tmp
➜  ls -ld /private/tmp
drwxrwxrwt  13 root  wheel  442  1 18 09:07 /private/tmp

為了解決這個 'sticky' permission of /private/tmp ,需要執行如下的命令:
sudo chmod +t /private/tmp/

執行完之後,再安裝就成功了:

➜  brew install pyenv
==> Downloading https://github.com/yyuu/pyenv/archive/v20160310.tar.gz
Already downloaded: /Library/Caches/Homebrew/pyenv-20160310.tar.gz
==> Caveats
To use Homebrew's directories rather than ~/.pyenv add to your profile:
  export PYENV_ROOT=/usr/local/var/pyenv

To enable shims and autocompletion add to your profile:
  if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi
==> Summary
?  /usr/local/Cellar/pyenv/20160310: 469 files, 2M, built in 0 seconds

相關文章