Error when running brew cask install

3.6k views Asked by At

Here's the error:

$ brew cask install sublime-text
Error: No such file or directory -brew-cask

1

There are 1 answers

0
l3x On

brew cask install was working earlier in the day, so I hoping that it was just a change in the load path affected the shell's ability to find and run the brew cask install command.

So, I did an exhaustive search:

$ find / \( -name "brew\-cask*" -type f \) -or \( -ilname "*brew-cask*" \) 2>/dev/null | grep brew-cask | xargs ls -l

-rw-r--r--  1 lex  admin    0 Sep  1 16:42 /Library/Caches/Homebrew/Formula/brew-cask.brewing
-rwxr-xr-x  1 lex  admin  193 Aug 31 20:35 /Library/Caches/Homebrew/brew-cask--git/bin/brew-cask.rb
-rw-r--r--  1 lex  admin  470 Aug 31 20:35 /Library/Caches/Homebrew/brew-cask--git/brew-cask.rb
-rwxr-xr-x  1 lex  wheel  197 Sep  1 16:39 /usr/local/Cellar/brew-cask/0.15.0/bin/brew-cask.rb
lrwxr-xr-x  1 lex  admin   32 Aug 31 20:35 /usr/local/Library/Formula/brew-cask.rb -> ../Taps/phinze-cask/brew-cask.rb
lrwxr-xr-x  1 lex  admin   29 Sep  1 16:39 /usr/local/Library/LinkedKegs/brew-cask -> ../../Cellar/brew-cask/0.15.0
-rwxr-xr-x  1 lex  admin  193 Aug 31 20:35 /usr/local/Library/Taps/phinze-cask/bin/brew-cask.rb
-rw-r--r--  1 lex  admin  470 Aug 31 20:35 /usr/local/Library/Taps/phinze-cask/brew-cask.rb
lrwxr-xr-x  1 lex  admin   43 Sep  1 16:39 /usr/local/bin/brew-cask.rb -> ../Cellar/brew-cask/0.15.0/bin/brew-cask.rb
lrwxr-xr-x  1 lex  admin   26 Sep  1 16:39 /usr/local/opt/brew-cask -> ../Cellar/brew-cask/0.15.0

The last two lines looked interesting...

$ ls -l /usr/local/Cellar/brew-cask/0.15.0/bin/brew-cask.rb
-rwxr-xr-x  1 lex  wheel  197 Sep  1 16:39 /usr/local/Cellar/brew-cask/0.15.0/bin/brew-cask.rb

$ ls -l /usr/local/Cellar/brew-cask/0.15.0
total 16
drwxr-xr-x  421 lex  wheel  14314 Sep  1 16:39 Casks
-rw-r--r--    1 lex  admin    226 Sep  1 16:39 INSTALL_RECEIPT.json
-rw-r--r--    1 lex  wheel   1909 Sep  1 16:39 README.md
drwxr-xr-x    3 lex  wheel    102 Sep  1 16:39 bin
drwxr-xr-x    5 lex  wheel    170 Sep  1 16:39 rubylib

Hmmm... /usr/local/opt/brew-cask points to a directory that contains a bin directory that then contains brew-cask...

Then, I looked in at my load path...

$ echo $PATH
/Users/lex/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/opt/coreutils/libexec/gnubin:/Users/lex/.rbenv/bin:/Users/lex/.rbenv/shims:/Users/lex/bin:/usr/local/opt:/usr/local/bin:/usr/bin

And sure enough, my PATH had been changed to load files in /usr/local/opt before it loads files in /usr/local/bin.

The rest of the "executables" were similar in the /usr/local/opt directory. So, I removed it from my path.

I tried again...

$ brew cask install sublime-text
==> Downloading http://c758482.r82.cf2.rackcdn.com/Sublime%20Text%202.0.2.dmg
######################################################################## 100.0%
==> Success! sublime-text installed to /opt/homebrew-cask/Caskroom/sublime-text/2.0.2
==> Linking Sublime Text 2.app to /Users/lex/Applications/Sublime Text 2.app

Success :-)