Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
brew reinstall commands
brews = []
out = IO.popen("brew list", "r") do |io|
brews = io.read.split "\n"
end
def parse(brew, brew_info)
in_options = false
print "brew reinstall -v #{brew} "
brew_info.split("\n").each do |m|
#puts m.inspect
if in_options
m.scan(/(--[a-zA-Z-]+)/).each do |x|
print x[0] + " "
end
#puts matchdata.inspect
in_options = false
end
if /\*$/.match m
in_options = true
end
end
puts
end
brews.each do |brew|
#puts "brew info #{brew}"
IO.popen("brew info #{brew}", "r") do |info|
parse(brew, info.read)
end
end
@onewheelskyward

This comment has been minimized.

Copy link
Owner Author

@onewheelskyward onewheelskyward commented Nov 4, 2013

Extra thanks to @stepheneb for the improvements!

@fulldecent

This comment has been minimized.

Copy link

@fulldecent fulldecent commented Nov 5, 2013

I am getting warnings like Warning: bash-completion-1.3 already installed and no work is actually getting done.

FYI, referred here from https://github.com/mxcl/homebrew/wiki/C++-Standard-Libraries

@skeet70

This comment has been minimized.

Copy link

@skeet70 skeet70 commented Nov 8, 2013

i think replacing the install -v commands with reinstall commands does what is needed coming from https://github.com/mxcl/homebrew/wiki/C++-Standard-Libraries

@sinisterstuf

This comment has been minimized.

Copy link

@sinisterstuf sinisterstuf commented Nov 8, 2013

Indeed! I replaced install with reinstall on line 8 and can confirm it at least does something now. So far one or two things failed to re-compile, but I'm not sure that's related.

@OleMchls

This comment has been minimized.

Copy link

@OleMchls OleMchls commented Nov 12, 2013

After changing install -v to reinstall

I fired this up λ ~ ruby generate-hombrew-install-commands.rb > brew.sh && bash ./brew.sh

@onewheelskyward

This comment has been minimized.

Copy link
Owner Author

@onewheelskyward onewheelskyward commented Nov 22, 2013

Good idea, I've updated it to use the reinstall command.

@glsee

This comment has been minimized.

Copy link

@glsee glsee commented Jan 4, 2014

I'm getting this error from running ruby genereate-hombrew-install-commands.rb:

generate-hombrew-install-commands.rb:9:in `split': invalid byte sequence in US-ASCII (ArgumentError)
    from generate-hombrew-install-commands.rb:9:in `parse'
    from generate-hombrew-install-commands.rb:28:in `block (2 levels) in <main>'
    from generate-hombrew-install-commands.rb:27:in `popen'
    from generate-hombrew-install-commands.rb:27:in `block in <main>'
    from generate-hombrew-install-commands.rb:25:in `each'
    from generate-hombrew-install-commands.rb:25:in `<main>'
@11bit

This comment has been minimized.

Copy link

@11bit 11bit commented Jan 5, 2014

This is an error with parsing utf8 symbols. You can force to use other encoding (for instance cp1252) in line 27:

IO.popen("brew info #{brew}", "r:cp1252") do |info|

I don't speak ruby so maybe this is not the best solution but it works.

@Blaisorblade

This comment has been minimized.

Copy link

@Blaisorblade Blaisorblade commented Jan 13, 2014

Doesn't this script simply reinstall all installed packages (preserving options)?

I found a link to this script on the wiki (https://github.com/Homebrew/homebrew/wiki/C++-Standard-Libraries) which claims that it only reinstalls root packages, whatever that means:

@onewheelskyward created a Ruby script for displaying on stdout the brew install commands (along with any options used when they were original installed) to re-install all the packages which are root packages generate-hombrew-install-commands.rb.

However, brew list does list all installed formulas (according to man brew), and AFAIK each listed formula is also listed in the output.

@naterhat

This comment has been minimized.

Copy link

@naterhat naterhat commented Jan 26, 2014

I had a problem with incompatible with the standard library, libstd c++. To fix this, found the incompatible formulary, uninstall it, and reinstall it. Then go back to the formulary that has the install error and resintall it. Keep doing this until there is no error.

Error

Error: gdal dependency proj was built with the following
C++ standard library: libstdc++ (from clang)

Fix

$ brew reinstall proj
$ brew install gdal

Not familiar with much of brew and ruby, so there could be a more simpler and easy way. Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment