我正在尝试在我的 mac 上重新安装 homebrew。
我收到此错误:
michaels-1856:~ michael.snowden$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/man/man1/brew.1
==> The following directories will be made group writable:
/usr/local/bin
/usr/local/share
/usr/local/share/man
/usr/local/share/man/man1
==> The following directories will have their owner set to tomcat:
/usr/local/bin
/usr/local/share
/usr/local/share/man
/usr/local/share/man/man1
==> The following directories will have their group set to admin:
/usr/local/bin
/usr/local/share
/usr/local/share/man
/usr/local/share/man/man1
Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/bin /usr/local/share /usr/local/share/man /usr/local/share/man/man1
Password:
==> /usr/bin/sudo /usr/sbin/chown tomcat /usr/local/bin /usr/local/share /usr/local/share/man /usr/local/share/man/man1
chown: tomcat: illegal user name
Failed during: /usr/bin/sudo /usr/sbin/chown tomcat /usr/local/bin /usr/local/share /usr/local/share/man /usr/local/share/man/man1
michaels-1856:~ michael.snowden$
正是这一行让我烦恼:
chown: tomcat: illegal user name
我用谷歌搜索homebrew "the following directories will have their owner set to"
,只找到一个搜索结果,那就是自制安装脚本
据我所知,我的用户名不是 tomcat。
具体来说,这是给我带来麻烦的脚本行:
"The following directories will have their owner set to #{Tty.underline 39}#{ENV['USER']}#{Tty.reset}:"
据我所知,问题是$USER=tomcat
,但是whoami=michael.snowden
michaels-1856:~ michael.snowden$ whoami
michael.snowden
michaels-1856:~ michael.snowden$ echo $USER
tomcat
编辑
我在文件中发现的唯一引用~/.bash*
“tomcat”的内容是我在创建这篇文章后查看 tomcat 是否是有效用户的操作。
michaels-1856:~ michael.snowden$ cat ~/.bash* | grep tomcat
chown tomcat test.txt
编辑 这个问题得到了解决,但该解决方案确实特定于我的计算机设置,并且需要进行大量挖掘。
答案1
显然,某些东西覆盖了 $USER 变量。您可以花几个小时尝试追溯可能导致此问题的原因,或者按顺序运行以下命令。
export USER=`whoami`
bash -x -c ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
如果再次发生这种情况,-x 标志将显示运行了哪些命令以及它们做了什么,包括初始化或修改的任何变量。它不会具体告诉您是什么原因导致这种情况发生,但它将有助于缩小范围,确定是源文件还是正在执行的 Ruby 文件的某些部分导致了这种情况。一路上会进行一些 grep 操作。