【问题标题】:brew install postgresql (upgrade) error, could not link - dead links to old non-existent versionbrew install postgresql (upgrade) error, could not link - dead links to old non-existent version
【发布时间】:2014-08-01 08:23:22
【问题描述】:

警告:不要开始在终端中手动删除文件,除非 你已经先尝试了其他一切。手动删除可能会导致 卸载并安装程序崩溃。

这是 QA 风格的帖子,分享我解决问题的方法。我相信有更好的方法

我买了一台较旧的 mac air,想将其设置为用于 Ruby 和 Rails 培训。在升级过程中,我在安装 postgresql 时遇到了问题:

➜  ~  brew install postgresql
....
==> Installing postgresql
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/postgresql-9.3.5.mountain_lion.bottle.tar.gz
Already downloaded: /Library/Caches/Homebrew/postgresql-9.3.5.mountain_lion.bottle.tar.gz
==> Pouring postgresql-9.3.5.mountain_lion.bottle.tar.gz
==> Caveats
...
To reload postgresql after an upgrade:
    launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Error: An unexpected error occurred during the `brew link` step
The formula built, but is not symlinked into /usr/local
No such file or directory - /usr/local/Cellar/postgresql/9.2.3/include/server
Error: No such file or directory - /usr/local/Cellar/postgresql/9.2.3/include/server

我正在安装 postgresql 9.3.5,我不在乎找不到 9.2.3!

➜  ~  brew install postgresql
Warning: postgresql-9.3.5 already installed, it's just not linked

但是 postgres 还是坏了。

有什么问题?

【问题讨论】:

    标签: macos postgresql homebrew


    【解决方案1】:

    我遇到了类似的问题,但使用了另一个包。原来有一堆死链接指向旧版本的所有其他我的文件系统。以下是对我有帮助的:

    1. 运行brew link <appname>(例如brew link postgress);
    2. 如果成功完成则你是黄金,否则继续下一步;
    3. 查看错误消息中的路径(例如 /usr/local/Cellar/postgresql/9.2.3/include/server)通过删除 Cellar/ 转换路径/ 来自它(例如 /usr/local/include/server
    4. 在该路径下找到所有引用 Cellar// 的链接并将其删除;
    5. 转到第 1 步。

    希望有帮助

    【讨论】:

    • 感谢您在此问答式帖子中添加更多有用的说明 :)
    【解决方案2】:
    brew update 
    brew doctor
    

    永远是第一步。

    为了帮助查找文件,更新文件数据库

    sudo /usr/libexec/locate.updatedb
    

    这与 ubuntu 上的 updatedb 类似,您可能希望给它起别名。

    那么你可以执行

    locate postgresql
    

    并详细了解事物的位置。

    您可能像我一样错误地删除了文件和文件夹(抱歉,这样做很愚蠢)。我学到的是,我有一堆死符号链接。

    homebrew 主要使用/usr/,更具体地说是/usr/local/bin,并将所有源代码放在/usr/local/Cellar,将local/bin 符号链接到Cellar bin

    我所做的就是追捕那些死掉的符号链接并再次杀死它们。取消链接。

    进入/usr/local/bin/usr 中的其他人并执行

    sudo find . -type l -exec test ! -e {} \; -delete
    

    这个测试符号链接的目标是否存在,如果不存在则删除。

    要在文件夹和子文件夹中查找符号链接

    sudo ls -lR /usr | grep \^l
    # and only those pointing to something postgresql:
    sudo ls -lR /usr | grep \^l | grep postgresql
    

    这会让你更进一步。

    我什至无法安装 wget,brew install wget´ because of somewgetrcissue. I found that being a dead symlink/usr/local/etc/wgetrc`

    清理了符号链接后,我的系统工作得更好了,最后安装了 postgresql 作为一个魅力

    ➜ brew uninstall postgresql
    ➜ brew install postgresql
    ==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/postgresql-9.3.5.mountain_lion.bottle.tar.gz
    Already downloaded: /Library/Caches/Homebrew/postgresql-9.3.5.mountain_lion.bottle.tar.gz
    ==> Pouring postgresql-9.3.5.mountain_lion.bottle.tar.gz
    ==> Caveats
    If builds of PostgreSQL 9 are failing and you have version 8.x installed,
    you may need to remove the previous version first. See:
      https://github.com/Homebrew/homebrew/issues/issue/2510
    
    To migrate existing data from a previous major version (pre-9.3) of PostgreSQL, see:
      http://www.postgresql.org/docs/9.3/static/upgrading.html
    
    When installing the postgres gem, including ARCHFLAGS is recommended:
      ARCHFLAGS="-arch x86_64" gem install pg
    
    To install gems without sudo, see the Homebrew wiki.
    
    To reload postgresql after an upgrade:
        launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
        launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
    ==> /usr/local/Cellar/postgresql/9.3.5/bin/initdb /usr/local/var/postgres
    ==> Summary
    ?  /usr/local/Cellar/postgresql/9.3.5: 2927 files, 39M
    
    # and in my project
    ➜ bundle
    ➜ rake db:create
    ➜ rake db:migrate
    # YEAH!
    

    【讨论】:

    • 您也可以使用brew prune 来清理死符号链接。
    • 谢谢@TimSmith。希望那些尝试这种方法并对其有所帮助的人会告诉我们。听起来更简单:)
    【解决方案3】:

    我在 Yosemite 10.10.3 上遇到了同样的问题。

    我的步骤是:

    1. 安装最新的操作系统更新
    2. 列表项
    3. 从 xCode 安装更新
    4. 在终端运行命令:brew install postgresql
    5. 在终端运行命令:sudo brew link postgresql
    6. 在终端运行命令:gem install pg -v '0.18.1'

    然后捆绑安装就完成了。

    【讨论】:

    • 对于 2017 年检查此答案的任何人:-您不能再将 sudo 与 brew 一起使用-步骤 5 中有错字(链接 postgresql)
    【解决方案4】:

    我运行了 brew doctor 并遵循了相关建议。在这种情况下

    Warning: The following directories do not exist:/usr/local/include
    You should create these directories and change their ownership to your account.
      sudo mkdir -p /usr/local/include
      sudo chown -R $(whoami) /usr/local/include
    

    之后,我可以运行 brew link postgresql

    【讨论】:

      【解决方案5】:

      你可以试试这个

      /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 &
      

      【讨论】:

      • 请解释您的陈述是如何帮助解决问题的
      • 这是来自 postgresql 文档的命令。如果它说 postgresql 已经安装,您可以尝试从 postgres 目录运行它,如果成功,您将看到 postgresql 服务器的进程 pid
      【解决方案6】:

      '/usr/local/Cellar/postgresql@9.6/9.6.21/bin/pg_ctl -D /usr/local/var/postgresql@9.6 start && brew services start postgresql' 返回我 postgre 未安装

      brew 安装 postgresql 返回我未链接

      brew 服务启动 postgresql 退回给我root找不到

      psql postgres

      【讨论】:

        猜你喜欢
        • 2020-04-26
        • 2021-08-06
        • 2017-02-24
        • 2017-09-04
        • 2021-04-20
        • 2022-01-13
        • 2020-12-24
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多