homebrew / homebrew-command-not-found Goto Github PK
View Code? Open in Web Editor NEWš Ubuntuās command-not-found equivalent for Homebrew on macOS
License: MIT License
š Ubuntuās command-not-found equivalent for Homebrew on macOS
License: MIT License
$ brew install binutils
$ gaddr2line
zsh: command not found: gaddr2line
Would be nice if it said "this should already be installed by package X, perhaps it's not in your PATH"? Just to avoid confusion for those of us using it :)
When I run brew which-update
, I now get the following error:
==> Using executables list from '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/executables.txt'
Error: undefined method `split' for nil:NilClass
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/cmd/brew-which-update.rb:34:in `block in initialize'
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/cmd/brew-which-update.rb:32:in `each'
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/cmd/brew-which-update.rb:32:in `initialize'
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/cmd/brew-which-update.rb:198:in `new'
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/cmd/brew-which-update.rb:198:in `<top (required)>'
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/usr/local/Homebrew/Library/Homebrew/utils.rb:20:in `require?'
/usr/local/Homebrew/Library/Homebrew/brew.rb:106:in `<main>'
The command brew which-update
does not work anymore, it just generates that error message. brew command-not-found-init
and brew which-formula
still work, thankfully. This is a new problem and did not happen before, brew which-update
worked until recently. I got this problem after running brew update
as usual today. I am on macOS 10.12 Sierra and the rest of homebrew works fine right now, no problems at all with brew doctor
.
For example, the instructions for fish have:
set HB_CNF_HANDLER (brew --prefix)"/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.fish"
But /opt/homebrew/Homebrew
does not exist in a standard installation. The Library has moved to /opt/homebrew/Library
which means that the /Homebrew
portion of the path should be removed.
I followed the installation instructions but it doesn't work
$ brew install bash;
$ brew tap homebrew/command-not-found;
$ # edit .bash_profile
$ tail -n3 .bash_profile;
if brew command command-not-found-init > /dev/null; then
eval "$(brew command-not-found-init)";
fi
$ source .bash_profile;
$ when
-bash: when: command not found
$
I'm just added command-not-found tap and cannot run which-update:
% brew which-update
==> Using executables list from '/opt/homebrew/Library/Taps/homebrew/homebrew-command-not-found/executables.txt'
Error: missing keywords: flags, ignore_errors
Warning: Removed Sorbet lines from backtrace!
/opt/homebrew/Library/Homebrew/formulary.rb:132:in `load_formula_from_path'
/opt/homebrew/Library/Taps/homebrew/homebrew-command-not-found/lib/executables_db.rb:64:in `block (2 levels) in update!'
/opt/homebrew/Library/Taps/homebrew/homebrew-command-not-found/lib/executables_db.rb:63:in `each'
/opt/homebrew/Library/Taps/homebrew/homebrew-command-not-found/lib/executables_db.rb:63:in `block in update!'
/opt/homebrew/Library/Taps/homebrew/homebrew-command-not-found/lib/executables_db.rb:62:in `each'
/opt/homebrew/Library/Taps/homebrew/homebrew-command-not-found/lib/executables_db.rb:62:in `update!'
/opt/homebrew/Library/Taps/homebrew/homebrew-command-not-found/lib/which_update.rb:51:in `update_and_save!'
/opt/homebrew/Library/Taps/homebrew/homebrew-command-not-found/cmd/which-update.rb:41:in `which_update'
/opt/homebrew/Library/Homebrew/brew.rb:86:in `<main>'
Homebrew version:
% brew --version
Homebrew 4.1.17-33-g13ca5c3
Homebrew/homebrew-core (git revision ca924ee3875; last commit 2023-10-28)
Homebrew/homebrew-cask (git revision c9f9182d01; last commit 2023-10-27)
Command which-formula is working:
% brew which-formula identify
imagemagick
imagemagick@6
For some reason brew which-formula
doesn't work for me.
brew which-formula when
returns:
Error: private method `flag?' called for ["when"]:Array
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/cmd/brew-which-formula.rb:74:in `<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/usr/local/Homebrew/Library/Homebrew/utils.rb:82:in `require?'
/usr/local/Homebrew/Library/Homebrew/brew.rb:108:in `<main>'
I'm using:
macOS Catalina 10.15.2 19C57
Homebrew 2.2.3-11-gdfe028a
With Linuxbrew:
$ brew which-update --stats executables.txt
Error: undefined method `install_tap' for Homebrew:Module
/home/baptiste/.linuxbrew/Library/Taps/homebrew/homebrew-command-not-found/cmd/brew-which-update.rb:160:in `block in <top (required)>'
/home/baptiste/.linuxbrew/Library/Taps/homebrew/homebrew-command-not-found/cmd/brew-which-update.rb:158:in `each'
/home/baptiste/.linuxbrew/Library/Taps/homebrew/homebrew-command-not-found/cmd/brew-which-update.rb:158:in `flat_map'
/home/baptiste/.linuxbrew/Library/Taps/homebrew/homebrew-command-not-found/cmd/brew-which-update.rb:158:in `<top (required)>'
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/home/baptiste/.linuxbrew/Library/brew.rb:21:in `require?'
/home/baptiste/.linuxbrew/Library/brew.rb:89:in `<main>'
$ brew doctor
Your system is ready to brew.
$ brew config
HOMEBREW_VERSION: 0.9.5
ORIGIN: https://github.com/Homebrew/linuxbrew
HEAD: 44cbc9f7147442c2aa029795780833fa72ce69c9
Last commit: il y a 2 jours
HOMEBREW_PREFIX: /home/baptiste/.linuxbrew
HOMEBREW_REPOSITORY: /home/baptiste/.linuxbrew
HOMEBREW_CELLAR: /home/baptiste/.linuxbrew/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://linuxbrew.bintray.com
CPU: quad-core 64-bit broadwell
Kernel: Linux 4.2.0-35-generic x86_64 GNU/Linux
OS: Ubuntu 14.04.4 LTS
Codename: trusty
OS glibc: 2.19
OS gcc: 4.8.4
Linuxbrew glibc: N/A
Linuxbrew gcc: N/A
Clang: N/A
X11: 2.7.8 => /usr
System Ruby: 1.9.3-p484 => /usr/bin/ruby1.9.1
Perl: /usr/bin/perl
Python: /usr/bin/python => /usr/bin/python2.7
Ruby: /usr/bin/ruby => /usr/bin/ruby1.9.1
Java: 1.7.0_95
brew install llvm --with-lldb => installs lldb
brew which-formula lldb
# empty
would be nice to have:
brew which-formula --search_with_options lldb
llvm --with-lldb
Context here: Homebrew/brew#2003
I am having some issues after installing.
I am running zsh on OS X Yosemite 10.10.5. I tapped the repository and added the line if brew command command-not-found-init > /dev/null; then eval "$(brew command-not-found-init)"; fi
to the .zshrc.
Now when I start a shell, I get:
Last login: Thu Aug 20 07:34:21 on ttys001
(eval):1: no matches found: ā#
ā ~
If I type when
, I get:
ā ~ when
zsh: command not found: when
I see that the new brew commands have been installed, so I am not sure what might be causing the issue. I wanted to check with you before posting an issue to ensure I am not making a foolish mistake.
I don't think there are issues with my .zshrc; when I enter zsh -n ~/.zshrc
to the command prompt, no errors appear.
I think it'd be great to perhaps import this tool into Homebrew core at some point.
Some executables can be provided by two different formulae.
Warning: Calling Formula#all without --all
or HOMEBREW_EVAL_ALL
is deprecated! There is no replacement.
Please report this issue to the homebrew/command-not-found tap (not Homebrew/brew or Homebrew/homebrew-core):
/opt/homebrew/Library/Taps/homebrew/homebrew-command-not-found/lib/executables_db.rb:57
brew install
will automatically tap the tap when necessary. Also to be neater , brew install homebrew/tap/formula
is preferred over brew install homebrew/homebrew-tap/formula
.
We need to search in $(brew --prefix)/Library/Taps/*/*/
to find which formulae come from taps and prefix them in the database.
On Mac OSX .bashrc
is not sourced by default, but .bash_profile
is.
In your readme you refer to .bashrc
. Is this correct or do you mean .bash_profile
?
We might want to use āpackageā instead of āformulaā.
Started up a terminal on macOS this morning and got the following error.
Error:' uninitialized constant Utils::Shell
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/cmd/brew-command-not-found-init.rb:4:in 'shell'
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/cmd/brew-command-not-found-init.rb:45:in 'init'
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/cmd/brew-command-not-found-init.rb:58:in '<top (required)>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in 'require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in 'require'
/usr/local/Homebrew/Library/Homebrew/utils.rb:85:in 'require?'
/usr/local/Homebrew/Library/Homebrew/brew.rb:121:in '<main>'
removing the homebrew-command-not-found tap resolves it
> brew untap homebrew/command-not-found
MacOS: 10.15.6 (19G2021)
Xcode : Version 11.6 (11E708)
Homebrew
> brew --version
Homebrew 2.4.13-41-g236cbbc
Homebrew/homebrew-core (git revision 90eb3; last commit 2020-08-22)
Homebrew/homebrew-cask (git revision 4602d; last commit 2020-08-22)
> ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
> pwd
/usr/local/Cellar/ruby/2.7.1_2/bin
> ./ruby -v
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin19]
Possibly caused by Brew update on the 22/08/2020 ?
Homebrew/homebrew-core (git revision 90eb3; last commit 2020-08-22)
Homebrew/homebrew-cask (git revision 4602d; last commit 2020-08-22)
The readme says I should add this to my .bashrc
:
if brew command command-not-found-init > /dev/null 2>&1; then eval "$(brew command-not-found-init)"; fi
In pseudocode:
command-not-found
has been tapped, then read the output of brew command-not-found-init
into the current shell.Well, what is the output of brew command-not-found-init
?
$ brew command-not-found-init
# To enable homebrew-command-not-found
# Add the following lines to ~/.bashrc
if brew command command-not-found-init > /dev/null; then
eval "$(brew command-not-found-init)";
fi
So the test verifying the tap is tapped is getting executed twice. Why not just add eval "$(brew command-not-found-init)"
to .bashrc
and call it a day?
The fish command-not-found handler is __fish_command_not_found_handler.
Is there going to be FISH support? I tried following the instructions but, it doesn't work for FISH.
$ -h
Usage: brew which-formula [--explain] command [...]
Prints the formula(e) which provides the given command.
--explain Output explanation of how to get 'cmd' by
installing one of the providing formulae.
-d, --debug Display any debugging information.
-q, --quiet Make some output more quiet.
-v, --verbose Make some output more verbose.
-h, --help Show this message.
Clearly we are running "brew which-formula $BADCMD" and -h gets passed to brew.
I tried this test:
$ brew which-formula -- -h
but that command appears to just hang so there are so other changes needed and it fell below the threshold where I have time to try putting together a patch.
But I figured I should at least make a bug report.
e.g. shell.fm
have been removed from the main repo but the update script didnāt remove it from executables.txt
.
Since we donāt support it it might be a good idea not to suggest boneyarded formulae.
The current suggestion feature might show formulae that donāt work on the current OS versionĀ / architecture, e.g. on 10.10:
$ valgrind
The program 'valgrind' is currently not installed. You can install it by typing:
brew install valgrind
$ brew install valgrind
valgrind: OS X Mavericks or older is required.
Error: An unsatisfied requirement failed this build.
Right now brew which-update
only adds the new name but doesnāt delete the old name.
still just shows up
$ when
-bash: when: command not found
$ brew tap homebrew/command-not-found
Warning: Tap homebrew/command-not-found already tapped.
.bash_profile
if brew command command-not-found-init > /dev/null; then eval "$(brew command-not-found-init)"; fi
Every time I run an invalid command, it takes about 1-2 seconds before it shows the candidates of packages or shows the "Unknown command" message. The experience is far worse than the counterpart in, say, Ubuntu, where the results show up in like <0.1 seconds. I'm so impatient that I immediately type Ctrl-C once I recognized I typed a wrong command before the results are output. Now I'm going to disable this feature... Is there a room of improvement? If it is easy enough, maybe I can contribute.
This is my zshrc
start=`gdate +%s.%N`
export ZSH="$HOME/.oh-my-zsh"
fpath=(/usr/local/share/zsh-completions /usr/local/share/zsh-completions/conda-zsh-completion $fpath)
source $ZSH/oh-my-zsh.sh
end=`gdate +%s.%N`
runtime=$( echo "$end - $start"|bc -l )
echo "$runtime seconds"
when I open zsh
the output is always around .118130000 seconds
Now when I try adding command-not found
:
start=`gdate +%s.%N`
export ZSH="$HOME/.oh-my-zsh"
fpath=(/usr/local/share/zsh-completions /usr/local/share/zsh-completions/conda-zsh-completion $fpath)
if brew command command-not-found-init > /dev/null; then
eval "$(brew command-not-found-init)";
fi
source $ZSH/oh-my-zsh.sh
end=`gdate +%s.%N`
runtime=$( echo "$end - $start"|bc -l )
echo "$runtime seconds"
Now when I open zsh
, the output is around 2.358168000 seconds
!
Clearly, this is unacceptable. What can be done to speed this up?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ššš
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ā¤ļø Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.