Homebrew / legacy-homebrew

💀 The former home of Homebrew/homebrew (deprecated)
https://brew.sh
26.97k stars 11.35k forks source link

search command is eval-ing contents of Alias files. #47899

Closed uxp closed 8 years ago

uxp commented 8 years ago

I'm not exactly sure what is going on here.

[uxp@localhost]% brew search arm
Error: /usr/local/Library/Aliases/gearmand:1: syntax error, unexpected ..
../Formula/gearman.rb
  ^
/usr/local/Library/Aliases/gearmand:1: unknown regexp options - gara
Please report this bug:
    https://git.io/brew-troubleshooting
/usr/local/Library/Homebrew/formulary.rb:23:in `module_eval'
/usr/local/Library/Homebrew/formulary.rb:23:in `load_formula'
/usr/local/Library/Homebrew/formulary.rb:36:in `load_formula_from_path'
/usr/local/Library/Homebrew/formulary.rb:85:in `load_file'
/usr/local/Library/Homebrew/formulary.rb:76:in `klass'
/usr/local/Library/Homebrew/formulary.rb:72:in `get_formula'
/usr/local/Library/Homebrew/formulary.rb:207:in `factory'
/usr/local/Library/Homebrew/cmd/search.rb:149:in `block in search_formulae'
/usr/local/Library/Homebrew/cmd/search.rb:147:in `map'
/usr/local/Library/Homebrew/cmd/search.rb:147:in `search_formulae'
/usr/local/Library/Homebrew/cmd/search.rb:44:in `search'
/usr/local/Library/brew.rb:143:in `<main>'

Library/Aliases/gearmand appears to be the correct format (a text file who's contents are the relative path to the canonical formula file). gearmand appears to be the only file that matches the string of arm:

[uxp@localhost]% find /usr/local/Library/Aliases -name "*arm*"
/usr/local/Library/Aliases/gearmand

My instinct is pointing to module_eval inside Library/Homebrew/formulary.rb slurping the contents of the alias file and trying to evaluate the relative path as a regexp replace or something, (eg s/../Library/gearmand) where e and m are invalid regexp flags. This all makes perfect sense, except for the reason that we're trying to module_eval the contents of files inside the Aliases directory from the load_formula method, when it seems like it should be restricted to files within the Formula directory.

DomT4 commented 8 years ago

See https://github.com/Homebrew/homebrew/issues/36706#issuecomment-73775085. I suspect that could well be your issue.

UniqMartin commented 8 years ago

Library/Aliases/gearmand appears to be the correct format (a text file who's contents are the relative path to the canonical formula file).

That's not the correct format. It should be a symbolic link pointing to the formula (like all files in Library/Aliases/). Can you check if that's the case? I suspect something else went wrong, maybe during a brew update. Is there something special about your git or its configuration on your system? Have you altered the core.symlinks configuration value of git?

uxp commented 8 years ago

Interesting. I think I do have an issue where all the files in Library/Aliases are standard text files, and not symlinks. There should be nothing special about my git, but it is the Apple distributed version and not an overridden version. core.symlinks was not set to any value.

I've been having issues after upgrading to OS X to El Capitan and not re-installing all my installed formulas, so I blew out my Homebrew install by hand and re-installed manually to try and preserve some other installed programs within /usr/local, which could definitely have caused the discrepancy.

eg:

% cd `brew --prefix`
% rm -rf Cellar
% brew prune
% rm `git ls-files`
% rm -r Library/Homebrew Library/Aliases Library/Formula Library/Contributions
% rm -rf .git
% curl -L https://github.com/Homebrew/homebrew/tarball/master | tar xz --strip 1
% brew update

After explicitly setting core.symlinks to true, then re-installing Homebrew using the same exact procedure above, I was able to resolve my issues. Sorry for the noise.