brew update not working — bad substitution error on update.sh

Created on 9 May 2016  Â·  6Comments  Â·  Source: Homebrew/brew

Please follow the general troubleshooting steps first:

  • [X] Ran brew update and retried your prior step?

I tried to.

  • [X] Ran brew doctor, fixed as many issues as possible and retried your prior step?
  • [X] If you're seeing permission errors tried running sudo chown -R $(whoami) $(brew --prefix)?

Bug reports:

I just installed OSX El Capitan and now brew update doesn't work. I have followed these instructions: https://ohthehugemanatee.org/blog/2015/10/01/how-i-got-el-capitain-working-with-my-developer-tools/

Then I tried things like changing permissions, pulling it from origin again and doing a hard reset, uninstalling Homebrew and installing it again, and so on. The error remains. I can run brew doctor and it doesn't report any errors other than a few unlinked files that I installed myself. I just can't run brew update (the whole problem started because I ran brew doctor and it recommended that I run brew update). Xcode is installed too. Anyway here's what shows up when I run brew update:

mv: rename /usr/local/Library/Taps/homebrew-versions, to /usr/local/Library/Taps/homebrew/homebrew-versions/homebrew-versions,: No such file or directory 
/usr/local/Library/Homebrew/cmd/update.sh: line 58: ${#${tap_dir_basename//[^-]}}: bad substitution

And here's the content of line 58 and the following ones, in update.sh:

if [[ ${#${tap_dir_basename//[^\-]}} -gt 1 ]]
then
echo "Homebrew changed the structure of Taps like <someuser>/<sometap>." >&2
echo "So you may need to rename $HOMEBREW_LIBRARY/Taps/$user/homebrew-$repo manually." >&2
fi
else
echo "Homebrew changed the structure of Taps like <someuser>/<sometap>. " >&2
echo "$tap_dir is an incorrect Tap path." >&2
echo "So you may need to rename it to $HOMEBREW_LIBRARY/Taps/<someuser>/homebrew-<sometap> manually." >&2
fi

Any idea what this is about?

Most helpful comment

What is the output of ls -AlF /usr/local/Library/Taps and ls -AlF /usr/local/Library/Taps/*?

Nevermind! I was able to reproduce this locally and fixed the bug. Thanks for reporting it! Can you please do the following one last time and report back whether it worked this time?

cd /usr/local
git checkout master
git fetch origin
git reset --hard origin/master
brew update

All 6 comments

What is the output of ls -AlF /usr/local/Library/Taps and ls -AlF /usr/local/Library/Taps/*?

What is the output of ls -AlF /usr/local/Library/Taps and ls -AlF /usr/local/Library/Taps/*?

Nevermind! I was able to reproduce this locally and fixed the bug. Thanks for reporting it! Can you please do the following one last time and report back whether it worked this time?

cd /usr/local
git checkout master
git fetch origin
git reset --hard origin/master
brew update

cc @xu-cheng Do 93e0f4f9465978460d411f27214e19ae3fc4d294 and 500f9eada854c1939bf9a0caf94085214c9399b0 need to be backported to Homebrew/legacy-homebrew?

@UniqMartin
It worked! Thank you!

@UniqMartin I think so. Thanks for catching this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fxcoudert picture fxcoudert  Â·  3Comments

MikeMcQuaid picture MikeMcQuaid  Â·  3Comments

cfredhart picture cfredhart  Â·  4Comments

mislav picture mislav  Â·  3Comments

paanvaannd picture paanvaannd  Â·  4Comments