Homebrew: Cask 'java' definition is invalid

You can clean up old-style cask formulas thus:

grep "cask :v1 =>" --files-with-match /usr/local/Caskroom/*/.metadata/*/*/Casks/*.rb \
  | xargs gdirname | xargs gdirname | xargs rm -r

Assuming you've installed coreutils with a g prefix, so gdirname runs the GNU flavor of dirname


Solved by doing the following:

  1. Edited the java cask:
vim /usr/local/Caskroom/java/.metadata/1.8.0_51-b16/20150725210402.758/Casks/java.rb
  1. Changed the first line from:

cask :v1 => 'java' do

to

cask 'java' do

  1. Removed the undent comments at the end of the cask, which were giving me problems.

  2. Ran brew uninstall --cask java

Problem solved 💥