brew安装postgresql(升级)错误,无法链接 - 死链接到旧的不存在的版本

oma*_*oma 7 postgresql macos homebrew

警告:除非您先尝试其他所有操作,否则不要在终端中手动删除文件.手动删除可能导致卸载和安装程序崩溃.

这是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
Run Code Online (Sandbox Code Playgroud)

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

?  ~  brew install postgresql
Warning: postgresql-9.3.5 already installed, it's just not linked
Run Code Online (Sandbox Code Playgroud)

但是postgres仍然被打破了.

有什么问题?

Max*_*sky 12

我有类似的问题,但有另一个包.原来,有一堆死链接指向旧版本所有其他我的文件系统.以下是我案例中的帮助:

  1. brew link <appname>(例如brew link postgress);
  2. 如果成功完成那么你是金色的,否则继续下一步;
  3. 看一下错误消息中的路径(例如/usr/local/Cellar/postgresql/9.2.3/include/server),通过从中删除Cellar/<app name>/<version>来转换路径(例如/ usr/local/include/server)
  4. 在该路径下查找所有指向Cellar/<app name>/<version>的链接并删除它们;
  5. 转到第1步.

希望有所帮助


oma*_*oma 5

brew update 
brew doctor
Run Code Online (Sandbox Code Playgroud)

总是第一步.

帮助查找文件,更新文件db

sudo /usr/libexec/locate.updatedb
Run Code Online (Sandbox Code Playgroud)

这类似于ubuntu上的updatedb,你可能想要别名.

然后你可以表演

locate postgresql
Run Code Online (Sandbox Code Playgroud)

并了解更多关于事物的地方.

有可能你错误​​地删除了像我这样的文件和文件夹(抱歉,这是一个愚蠢的事情).我学到的是,我有一堆死的符号链接.

自制软件主要使用/usr/,更具体地说/usr/local/bin,将所有源代码放入/usr/local/Cellar,将符号链接local/bin添加到Cellar bin

我所做的就是追捕那些死亡的符号链并再次杀死它们.断开链接.

进入和做/usr/local/bin其他人/usr

sudo find . -type l -exec test ! -e {} \; -delete
Run Code Online (Sandbox Code Playgroud)

此测试表示符号链接的目标存在,如果不存在则删除.

要查找文件夹和子文件夹中的符号链接,请执行此操作

sudo ls -lR /usr | grep \^l
# and only those pointing to something postgresql:
sudo ls -lR /usr | grep \^l | grep postgresql
Run Code Online (Sandbox Code Playgroud)

那会让你更进一步.

我甚至无法安装wget,brew install wget´ because of somewgetrc issue. 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!
Run Code Online (Sandbox Code Playgroud)

  • 你也可以使用`brew prune`来清理死的符号链接. (4认同)