【问题标题】:Homebrew install permissions issueHomebrew 安装权限问题
【发布时间】:2012-03-21 07:50:33
【问题描述】:

我在 usr/local/ 中有一个标准的自制软件安装

当我尝试时:

Larson-2:~ larson$ brew install postgresql
Error: Cannot write to /usr/local/Cellar

当我使用 sudo 时:

Larson-2:~ larson$ sudo brew install postgresql
Cowardly refusing to `sudo brew install'

我做错了什么?

【问题讨论】:

  • 您可以sudo brew install,但您需要先更改 brew 实用程序的权限,使其归根用户所有。这是一项安全功能。
  • 似乎下面的方法改变了 brew 实用程序的权限,对吗?

标签: osx-snow-leopard homebrew package-managers


【解决方案1】:

不知何故,您对/usr/local/Cellar 的权限有限。 Brew 不喜欢使用 sudo 安装,这就是它拒绝的原因。

检查权限:

ls -ld /usr/local/Cellar

打开它们写:

sudo chmod a+w /usr/local/Cellar

【讨论】:

  • 很好,我见过其他方法,例如将 /usr/local/Cellar 的所有者更改为 whoami 或允许组在 /usr/local 上写入
  • 之后我得到了Error: Permission denied - /Library/Caches/Homebrew/Formula/...并用sudo chmod -R a+w /Library/Caches/Homebrew解决了
  • 谢谢!!我更新了目录,但是R安装还是说权限被拒绝。
【解决方案2】:

在使用brew 时不要使用sudo(出于安全原因)。

您必须简单地设置您的权限。

所以我会更进一步,将权限更改为:

sudo chgrp -R admin /usr/local /Library/Caches/Homebrew
sudo chmod -R g+w /usr/local /Library/Caches/Homebrew

然后将特定组(adminstaff)应用到应该允许使用brew 命令的用户。检查您的用户组:id -Gn)。

如果还有其他问题,请运行:brew doctor 以查看问题所在。

【讨论】:

    【解决方案3】:

    我会更改组权限:

    $ chgrp -R admin /usr/local/Cellar
    $ chmod g+w /usr/local/Cellar
    

    假设您的用户帐户在组 admin 中。

    【讨论】:

      【解决方案4】:

      如果您的计算机上有多个用户,也会发生这种情况。如果是这样,最好更改用户,因为其他所有方法都会让您处理更多的文件和文件夹,而不仅仅是 /usr/local/Cellar

      使用su userWhoInstalledBrew

      【讨论】:

        【解决方案5】:

        可以通过将目录的所有者更改为当前用户来解决问题:

        sudo chown -R $USER /usr/local
        

        此答案摘自:https://github.com/Homebrew/homebrew/issues/17884

        【讨论】:

        • High Sierra 用户的更新,/usr/local 不能再成为chowned(请参阅here)。 High Sierra 用户可能还必须重新安装 Homebrew。
        【解决方案6】:

        按照 chukcha14 在There is no Cellar file in my usr/local dir for brew 的回答中提供的建议,我这样做了:

        jaimes-mbp:SMR jaimemontoya$ brew install mongodb-community@4.2
        Warning: You are using OS X 10.15.
        We do not provide support for this pre-release version.
        You may encounter build failures or other breakages.
        Error: Could not create /usr/local/Cellar
        Check you have permission to write to /usr/local
        jaimes-mbp:SMR jaimemontoya$ sudo mkdir /usr/local/Cellar
        Password:
        jaimes-mbp:SMR jaimemontoya$ sudo chown $(whoami) /usr/local/Cellar
        jaimes-mbp:SMR jaimemontoya$ brew install mongodb-community@4.2
        Warning: You are using OS X 10.15.
        We do not provide support for this pre-release version.
        You may encounter build failures or other breakages.
        ==> Installing mongodb-community from mongodb/homebrew-brew
        ==> Downloading https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-4.2.3.tgz
        ###################################################################################### 100.0%
        Error: Failed to install plist file
        Error: The `brew link` step did not complete successfully
        The formula built, but is not symlinked into /usr/local
        Could not symlink .
        /usr/local/opt is not writable.
        
        You can try again using:
          brew link mongodb-community
        Warning: The post-install step did not complete successfully
        You can try again using `brew postinstall mongodb/brew/mongodb-community`
        ==> Caveats
        To have launchd start mongodb/brew/mongodb-community at login:
          ln -sfv /usr/local/opt/mongodb-community/*.plist ~/Library/LaunchAgents
        Then to load mongodb/brew/mongodb-community now:
          launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist
        Or, if you don't want/need launchctl, you can just run:
          mongod --config /usr/local/etc/mongod.conf
        ==> Summary
        ?  /usr/local/Cellar/mongodb-community/4.2.3: 20 files, 304M, built in 110 seconds
        jaimes-mbp:SMR jaimemontoya$ sudo mkdir /usr/local/opt
        jaimes-mbp:SMR jaimemontoya$ sudo chown $(whoami) /usr/local/opt
        jaimes-mbp:SMR jaimemontoya$ brew link mongodb-community
        Linking /usr/local/Cellar/mongodb-community/4.2.3... 13 symlinks created
        jaimes-mbp:SMR jaimemontoya$ 
        

        【讨论】:

          【解决方案7】:

          很有趣,但由于磁盘空间不足,我收到了 Error: Cannot write to /usr/local/Cellar 消息 .. :/(还剩 18MB)

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2013-01-15
            • 2018-06-24
            • 2015-02-14
            • 1970-01-01
            • 1970-01-01
            • 2019-12-13
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多