Warning: Do not start deleting files manually in Terminal unless you've tried everything else first. Manual deletion may caused uninstall and install programs to crash.
This is QA style post, sharing my path to resolve the issue. I'm sure there are better ways
I picked up an older mac air and wanted to set it up for Ruby and Rails training. During the upgrade I had issues with installing 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
I'm installing postgresql 9.3.5, I couldn't care less about 9.2.3 not being found!
โ ~ brew install postgresql
Warning: postgresql-9.3.5 already installed, it's just not linked
but postgres was still broken.
What's the problem?
I had the similar problem but with another package. Turned out there had been a bunch of dead links pointing to the old version all other my file system. Here is what helped in my case:
brew link <appname>
(e.g. brew link postgress
);Hope that helps
brew update
brew doctor
is always first steps.
to help finding files, update the files db
sudo /usr/libexec/locate.updatedb
this is similar to updatedb on ubuntu and you might want to alias it.
then you may perform
locate postgresql
and learn more about where things are.
Chances are you made the mistake of deleting the files and folders just like me (sorry, that's a stupid thing to do). What I learn is that then I have a bunch of dead symlinks.
homebrew mostly use /usr/
, more specifically /usr/local/bin
and puts all source on /usr/local/Cellar
, symlink local/bin to Cellar bin
what I did was to hunt down those dead symlinks and kill them over again. unlink.
move into the /usr/local/bin
and others in the /usr
and do
sudo find . -type l -exec test ! -e {} \; -delete
this test that the target of symlinks exists and delete if not.
To find symlinks in a folder and subfolders do
sudo ls -lR /usr | grep \^l
# and only those pointing to something postgresql:
sudo ls -lR /usr | grep \^l | grep postgresql
that'll get you a step further.
I couldn't even install wget, brew install wgetยด because of some
wgetrcissue. I found that being a dead symlink
/usr/local/etc/wgetrc`
Having cleaned up the symlinks, my system works much better and finally postgresql installed as a charm
โ 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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With