boxen / our-boxen

Copy me for your team.
https://github.com/boxen/our-boxen/
MIT License
2.58k stars 882 forks source link

homebrew 1.0.0+ is conflicting with homebrew_root #834

Open salimane opened 8 years ago

salimane commented 8 years ago

In https://github.com/boxen/our-boxen/blob/master/facts.d/example.yaml, one could set the default homebrew_root folder.

Since 1.0.0, homebrew now migrates the HOMEBREW_REPOSITORY when you run brew update.

Running boxen after a brew update reinstalls all packages.

anyone having this issue ?

jacobbednarz commented 8 years ago

I didn't experience this post upgrade to > 1.0.

I'm on vacation at the moment but will be back in another week or so if you're still having this issue.

salimane commented 8 years ago

I'm getting the following after a post upgrade to > 1.0. Basically boxen trying to recreate the folders that homebrew just migrated.

Notice: Compiled catalog for salimanes-macbook-pro-2.local in environment production in 4.38 seconds
Notice: /Stage[main]/Foreman/Exec[install foreman standalone]/returns: executed successfully
Notice: /Stage[main]/Homebrew/File[/usr/local/Library]/ensure: created
Notice: /Stage[main]/Homebrew/Exec[install homebrew to /usr/local]/returns: executed successfully
Notice: /Stage[main]/Homebrew/File[/usr/local/Library/Taps]/ensure: created
Notice: /Stage[main]/Homebrew/File[/usr/local/Library/Taps/boxen]/ensure: created
Notice: /Stage[main]/Homebrew/File[/usr/local/Library/Taps/boxen/homebrew-brews]/ensure: created
Notice: /Stage[main]/Homebrew/File[/usr/local/Library/Taps/boxen/homebrew-brews/cmd]/ensure: created
Notice: /Stage[main]/Homebrew/File[/usr/local/Library/Taps/boxen/homebrew-brews/cmd/boxen-bottle-hooks.rb]/ensure: defined content as '{md5}d4342ff99b81df9954412430a1f20c36'
Notice: /Stage[main]/Homebrew/File[/usr/local/Library/Taps/boxen/homebrew-brews/cmd/brew-boxen-install.rb]/ensure: defined content as '{md5}a4beded3206823a5c06301cf3b1c47a5'
Notice: /Stage[main]/Python::Pyenv/Repository[/opt/boxen/pyenv]/ensure: ensure changed 'update' to '8f7fb57fbbf12bdf415ea7ddfe65409d8c548b1b'
Notice: /Stage[main]/Nodejs::Build/Repository[/opt/boxen/node-build]/ensure: ensure changed 'update' to 'f3b43d2286e511471960925594f45dd48c7bf69b'
Notice: /Stage[main]/People::Salimane/Exec[install dotfiles]/returns: executed successfully
Notice: /Stage[main]/Ruby::Build/Repository[/opt/boxen/ruby-build]/ensure: ensure changed 'update' to '9a5d431b25fd0319bc02b3937707f4d0b00a9211'
Notice: /Stage[main]/Homebrew/File[/usr/local/Library/Taps/boxen/homebrew-brews/cmd/brew-boxen-latest.rb]/ensure: defined content as '{md5}17c81cf41ea3f014b34f4b83fe65e9d4'
Notice: /Stage[main]/Imagemagick/Homebrew::Formula[imagemagick]/File[/usr/local/Library/Taps/boxen/homebrew-brews/imagemagick.rb]/ensure: defined content as '{md5}01d416cb181fbf56caf748118bf50015'
jacobbednarz commented 8 years ago

@salimane did you nuke your setup before upgrading to the new OS?

salimane commented 8 years ago

@jacobbednarz no but i can do nuke and setup again to see if it will solve the problem

jacobbednarz commented 8 years ago

In our internal fork, we mandate the nuke before an OS upgrade as we've found traces left behind during the upgrade often cause edge cases. Some people have upgraded to Sierra and I don't know of anyone hitting the above issue so I'm not sure but it's worth a try if you can.

jacobbednarz commented 7 years ago

@salimane just checking if this is still an issue?

salimane commented 7 years ago

yep this is still an issue, i'm not sure if it's related to user permissions. When I do brew update, I'm getting

salimane at Salimanes-MacBook-Pro-2 (git:salimane.com)  in ~
⚛ brew update
Updated 9 taps (caskroom/cask, caskroom/eid, caskroom/fonts, caskroom/versions, homebrew/command-not-found, homebrew/core, homebrew/dupes, homebrew/versions, homebrew/x11).
==> New Formulae
bit                              homebrew/versions/mapnik2        homebrew/x11/dmenu               homebrew/x11/i3status            homebrew/x11/sxiv                sqlparse                         statik
==> Updated Formulae
abcde                            datomic                          gitversion                       jid                              lz4                              pev                              synfig
adns                             dbhash                           gnupg2 ✔                         joe                              macvim                           pgrouting                        syntaxerl
amazon-ecs-cli                   dbt                              gnutls                           jruby                            memcached                        plantuml                         tbox
ansible-cmdb                     dcmtk                            go ✔                             kibana                           metricbeat                       pod2man                          terraform ✔
ant                              diffoscope                       godep                            kobalt                           micropython                      prips                            terragrunt
antigen                          docker-machine-parallels         gofabric8                        kubernetes-cli                   mikutter                         pstoedit                         thefuck
app-engine-go-64                 doitlive                         google-java-format               languagetool                     minizip                          pwntools                         tile38
arangodb                         dwarfutils                       gosu                             leptonica                        mktorrent                        rancher-compose                  tintin
aubio                            ecl                              grafana                          lft                              mongo-c-driver                   rancid                           ttyd
autotrace                        eject                            groonga                          libdap                           mongodb                          ranger                           tvnamer
beansdb                          elasticsearch                    grsync                           libgit2                          mono                             ripgrep                          twarc
bfg                              elasticsearch@2.4                gsoap                            libgit2-glib                     mpd                              rocksdb                          typescript
bib-tool                         emscripten                       h2o                              libgphoto2                       msgpack                          rswift                           u-boot-tools
bibutils                         etcd                             hana                             liblas                           mypy                             rtv                              udunits
bind                             euca2ools                        haproxy                          libmikmod                        nexus                            ruby-build                       unittest-cpp
bitlbee                          fdk-aac                          harfbuzz                         libming                          nim                              rust                             vice
bitrise                          filebeat                         heroku ✔                         libmwaw                          node@0.12                        serd                             vim
blockhash                        fluent-bit                       homebrew/dupes/ed                libphonenumber                   node@4                           sfk                              whatmp3
cabal-install                    fontforge                        homebrew/dupes/libedit           libpng ✔                         notmuch                          shmcat                           xmlrpc-c
caf                              fonttools                        homebrew/dupes/nano              libproxy                         nss                              snort                            xxhash
carina                           fping                            homebrew/dupes/whois             libsass                          bot                          geckodriver                      homebrew/x11/x3270               libsvm                           opencore-amr                     sphinx-doc ✔                     you-get
clasp                            geoipupdate                      hunspell                         libtiff ✔                        osc                              sqldiff                          youtube-dl
cmake ✔                          ghc                              icarus-verilog                   libupnp                          osquery                          sqlite ✔                         zabbix
pdns                             syncthing
==> Deleted Formulae
dmtx-utils                                                                   gcc@6                                                                        qtplay
==> Migrating HOMEBREW_REPOSITORY (please wait)...
Error: /usr/local/Homebrew already exists.
Please remove it manually or uninstall and reinstall Homebrew into a new
location as the migration cannot be done automatically.
jacobbednarz commented 7 years ago

I'm just looking into the error response here and wondering why it's not bailing out. :confused:

Could you put in the following debugging to help identify whether something is missing here?

$ diff -Naur /opt/boxen/homebrew/bin/brew.backup /opt/boxen/homebrew/bin/brew
--- /opt/boxen/homebrew/bin/brew.backup 2017-01-24 08:08:39.000000000 +1100
+++ /opt/boxen/homebrew/bin/brew    2017-01-24 08:08:09.000000000 +1100
@@ -42,6 +42,10 @@
   fi
 fi

+echo "==========================="
+echo "REPOSITORY: ${HOMEBREW_REPOSITORY}"
+echo "PREFIX: ${HOMEBREW_PREFIX}"
+
 HOMEBREW_LIBRARY="$HOMEBREW_REPOSITORY/Library"

 source "$HOMEBREW_LIBRARY/Homebrew/brew.sh"

This should be applied to the brew executable (wherever that lives in your system now - mine was /opt/boxen/homebrew/bin/brew).

salimane commented 7 years ago

Ok this is what I've got locally

salimane at Salimanes-MacBook-Pro-2 (git:salimane.com)  in ~
⚛ diff -Naur /usr/local/bin/brew.backup /usr/local/bin/brew
--- /usr/local/bin/brew.backup  1970-01-01 01:00:00.000000000 +0100
+++ /usr/local/bin/brew 2016-11-16 18:38:00.000000000 +0100
@@ -0,0 +1,47 @@
+#!/bin/bash
+set +o posix
+
+quiet_cd() {
+  cd "$@" >/dev/null
+}
+
+symlink_target_directory() {
+  local target="$(readlink "$1")"
+  local target_dirname="$(dirname "$target")"
+  local directory="$2"
+  quiet_cd "$directory" && quiet_cd "$target_dirname" && pwd -P
+}
+
+BREW_FILE_DIRECTORY="$(quiet_cd "${0%/*}/" && pwd -P)"
+HOMEBREW_BREW_FILE="${BREW_FILE_DIRECTORY%/}/${0##*/}"
+HOMEBREW_PREFIX="${HOMEBREW_BREW_FILE%/*/*}"
+
+# Default to / prefix if unset or the bin/brew file.
+if [[ -z "$HOMEBREW_PREFIX" || "$HOMEBREW_PREFIX" = "$HOMEBREW_BREW_FILE" ]]
+then
+  HOMEBREW_PREFIX="/"
+fi
+
+HOMEBREW_REPOSITORY="$HOMEBREW_PREFIX"
+
+# Resolve the bin/brew symlink to find Homebrew's repository
+if [[ -L "$HOMEBREW_BREW_FILE" ]]
+then
+  BREW_FILE_DIRECTORY="$(symlink_target_directory "$HOMEBREW_BREW_FILE" "$BREW_FILE_DIRECTORY")"
+  HOMEBREW_REPOSITORY="${BREW_FILE_DIRECTORY%/*}"
+fi
+
+# Try to find a /usr/local HOMEBREW_PREFIX where possible (for bottles)
+if [[ -L "/usr/local/bin/brew" ]]
+then
+  USR_LOCAL_BREW_FILE_DIRECTORY="$(symlink_target_directory "/usr/local/bin/brew" "/usr/local/bin")"
+  USR_LOCAL_HOMEBREW_REPOSITORY="${USR_LOCAL_BREW_FILE_DIRECTORY%/*}"
+  if [[ "$HOMEBREW_REPOSITORY" = "$USR_LOCAL_HOMEBREW_REPOSITORY" ]]
+  then
+    HOMEBREW_PREFIX="/usr/local"
+  fi
+fi
+
+HOMEBREW_LIBRARY="$HOMEBREW_REPOSITORY/Library"
+
+source "$HOMEBREW_LIBRARY/Homebrew/brew.sh"
jacobbednarz commented 7 years ago

@salimane based on this diff, you are running it against a non-existent file 😛 (a.k.a the backup file which I generated). are you able to drop in this debugging and we'll see what it produces?

Also, did you nuke Boxen before the update?

salimane commented 7 years ago

@jacobbednarz , here is the debug output

salimane at Salimanes-MacBook-Pro-2 (git:salimane.com)  in ~
⚛ brew update
===========================
REPOSITORY: /usr/local
PREFIX: /usr/local
To restore the stashed changes to /usr/local run:
  'cd /usr/local && git stash pop'
Updated 5 taps (caskroom/cask, caskroom/versions, homebrew/command-not-found, homebrew/core, homebrew/x11).
==> New Formulae
chezscheme             feh                    geomview               i3status               morse                  openmotif              rdesktop               sxiv                   x3270                  xpa
ddd                    fox                    grace                  imake                  mscgen                 pari                   robot-framework        tgif                   xclip                  xpdf ✔
dmenu                  freeglut               gv                     libxkbcommon           mupdf                  pdf2image              rxvt-unicode           tiger-vnc              xdotool
dwm                    freerdp                i3                     mesalib-glw            nedit                  pgplot                 startup-notification   wmctrl                 xlispstat
==> Updated Formulae
apache-drill             bullet                   fdroidserver             go ✔                     libprotoident            openshift-cli            qwt                      syncthing                wimlib
aws-sdk-cpp              certbot                  gammaray                 gpsbabel                 libwandevent             openssl@1.1              qwtpolar                 sysdig ✔                 yacas
awscli ✔                 consul                   generate-json-schema     khal                     monetdb                  pdfgrep                  sonarlint                terraform ✔
bitrise                  elixir                   gitlab-ci-multi-runner   libgetdata               ngircd                   pre-commit               swiftformat              vim
==> Deleted Formulae
homebrew/x11/bochs                    homebrew/x11/freeglut                 homebrew/x11/imake                    homebrew/x11/openmotif                homebrew/x11/startup-notification     homebrew/x11/xdotool
homebrew/x11/chezscheme               homebrew/x11/freerdp                  homebrew/x11/libxkbcommon             homebrew/x11/pari                     homebrew/x11/sxiv                     homebrew/x11/xlispstat
homebrew/x11/ddd                      homebrew/x11/geomview                 homebrew/x11/mesalib-glw              homebrew/x11/pdf2image                homebrew/x11/tgif                     homebrew/x11/xpa
homebrew/x11/dmenu                    homebrew/x11/grace                    homebrew/x11/morse                    homebrew/x11/pgplot                   homebrew/x11/tiger-vnc                homebrew/x11/xpdf ✔
homebrew/x11/dwm                      homebrew/x11/gv                       homebrew/x11/mscgen                   homebrew/x11/rdesktop                 homebrew/x11/wmctrl
homebrew/x11/feh                      homebrew/x11/i3                       homebrew/x11/mupdf                    homebrew/x11/robot-framework          homebrew/x11/x3270
homebrew/x11/fox                      homebrew/x11/i3status                 homebrew/x11/nedit                    homebrew/x11/rxvt-unicode             homebrew/x11/xclip
==> Migrating HOMEBREW_REPOSITORY (please wait)...
Error: /usr/local/Homebrew already exists.
Please remove it manually or uninstall and reinstall Homebrew into a new
location as the migration cannot be done automatically.