Brew Install Postgresql (upgrade) Error, Could Not Link - Dead Links To Old Non-existent Version


Answer :

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:

  1. Run brew link <appname> (e.g. brew link postgress);
  2. If completed successfully then you are golden, otherwise proceed with the next step;
  3. Take a look at the path in the error message (e.g. /usr/local/Cellar/postgresql/9.2.3/include/server) transform the path by removing the Cellar/<app name>/<version> from it (e.g. /usr/local/include/server)
  4. Find under that path all links referring to Cellar/<app name>/<version> and remove them;
  5. Goto step 1.

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 somewgetrcissue. 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! 

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable