--force and the issue is still present.brew update-reset && brew update and retried my command.brew doctor, fixed as many issues as possible and retried my command.When trying to reinstall java (to upgrade to java 10), the installation fails.
brew cask reinstall java
--force --verbose --debug==> Hbc::Installer#reinstall
==> Hbc::Installer#install
==> Printing caveats
==> Caveats
This Cask makes minor modifications to the JRE to prevent issues with
packaged applications, as discussed here:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=411361
If your Java application still asks for JRE installation, you might need
to reboot or logout/login.
Installing java means you have AGREED to the license at
https://www.oracle.com/technetwork/java/javase/terms/license/index.html
==> Hbc::Installer#fetch
==> Satisfying dependencies
==> Downloading
==> Downloading http://download.oracle.com/otn-pub/java/jdk/10.0.2+13/19aef61b38124481863b1413dce1855f/jdk-10.0.2_osx-x64_bin.dmg
/usr/bin/curl -q --show-error --user-agent Homebrew/1.7.1-224-ga985f0a\ \(Macintosh\;\ Intel\ Mac\ OS\ X\ 10.12.6\)\ curl/7.54.0 -b oraclelicense=accept-securebackup-cookie --silent --head --write-out \%\{redirect_url\} --output /dev/null http://download.oracle.com/otn-pub/java/jdk/10.0.2\+13/19aef61b38124481863b1413dce1855f/jdk-10.0.2_osx-x64_bin.dmg
==> Downloading from https://edelivery.oracle.com/otn-pub/java/jdk/10.0.2+13/19aef61b38124481863b1413dce1855f/jdk-10.0.2_osx-x64_bin.dmg
/usr/bin/curl -q --show-error --user-agent Homebrew/1.7.1-224-ga985f0a\ \(Macintosh\;\ Intel\ Mac\ OS\ X\ 10.12.6\)\ curl/7.54.0 --fail -b oraclelicense=accept-securebackup-cookie --location --remote-time --continue-at - --output /Users/jbellini/Library/Caches/Homebrew/Cask/java--10.0.2,13:19aef61b38124481863b1413dce1855f.dmg.incomplete https://edelivery.oracle.com/otn-pub/java/jdk/10.0.2\+13/19aef61b38124481863b1413dce1855f/jdk-10.0.2_osx-x64_bin.dmg
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 539 100 539 0 0 781 0 --:--:-- --:--:-- --:--:-- 782
100 395M 100 395M 0 0 5204k 0 0:01:17 0:01:17 --:--:-- 4000k
==> Downloaded to -> /Users/jbellini/Library/Caches/Homebrew/Cask/java--10.0.2,13:19aef61b38124481863b1413dce1855f.dmg
==> Verifying download
==> Determining which verifications to run for Cask java
==> Checking for verification class Hbc::Verify::Checksum
==> 1 verifications defined
Hbc::Verify::Checksum
==> Running verification of class Hbc::Verify::Checksum
==> Verifying checksum for Cask java
==> SHA256 checksums match
Error: Cask 'java' is unreadable: undefined method `undent' for #<String:0x0000000103ac2278>
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cask_loader.rb:65:in `rescue in load'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cask_loader.rb:58:in `load'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cask_loader.rb:179:in `load'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/installer.rb:122:in `uninstall_existing_cask'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/installer.rb:86:in `install'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/installer.rb:114:in `reinstall'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cli/reinstall.rb:10:in `block in run'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cli/reinstall.rb:5:in `each'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cli/reinstall.rb:5:in `run'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cli/abstract_command.rb:33:in `run'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cli.rb:91:in `run_command'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cli.rb:157:in `run'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cli.rb:122:in `run'
/usr/local/Homebrew/Library/Homebrew/cmd/cask.rb:7:in `cask'
/usr/local/Homebrew/Library/Homebrew/brew.rb:87:in `<main>'
Error: Kernel.exit
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cli.rb:162:in `exit'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cli.rb:162:in `rescue in run'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cli.rb:145:in `run'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cli.rb:122:in `run'
/usr/local/Homebrew/Library/Homebrew/cmd/cask.rb:7:in `cask'
/usr/local/Homebrew/Library/Homebrew/brew.rb:87:in `<main>'
brew cask doctor==> Homebrew-Cask Version
Homebrew-Cask 1.7.1-224-ga985f0a
Homebrew/homebrew-cask (git revision b7cc4; last commit 2018-08-12)
==> macOS
10.12.6
==> SIP
Enabled
==> Java
1.8.0_181, 1.8.0_141
==> Homebrew-Cask Install Location
<NONE>
==> Homebrew-Cask Staging Location
/usr/local/Caskroom
==> Homebrew-Cask Cached Downloads
~/Library/Caches/Homebrew/Cask (14 files, 4GB)
==> Homebrew-Cask Taps:
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask (4023 casks)
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask-versions (192 casks)
==> Contents of $LOAD_PATH
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.7/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.7/lib/ruby/site_ruby/2.3.0
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.7/lib/ruby/site_ruby/2.3.0/x86_64-darwin9.0
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.7/lib/ruby/site_ruby/2.3.0/universal-darwin9.0
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.7/lib/ruby/site_ruby
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.7/lib/ruby/vendor_ruby/2.3.0
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.7/lib/ruby/vendor_ruby/2.3.0/x86_64-darwin9.0
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.7/lib/ruby/vendor_ruby/2.3.0/universal-darwin9.0
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.7/lib/ruby/vendor_ruby
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.7/lib/ruby/2.3.0
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.7/lib/ruby/2.3.0/x86_64-darwin9.0
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.7/lib/ruby/2.3.0/universal-darwin9.0
/usr/local/Homebrew/Library/Homebrew/cask/lib
/usr/local/Homebrew/Library/Homebrew
==> Environment Variables
LC_ALL="en_US.UTF-8"
PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/Homebrew/Library/Homebrew/shims/scm"
SHELL="/bin/bash"
brew tapbrewsci/bio
homebrew/cask
homebrew/cask-versions
homebrew/core
homebrew/science
osgeo/osgeo4mac
Note that when running the command with --force --verbose --debug to show the output, I deleted the cached file
Reading the Java Cask, I could realize that there is no call to the EOS.undent method.
But, searching a bit in the brew repositories, I found this issue comment, that made me realize that there is a call to the EOS.undent method in the older java Cask that was installed some time ago (/usr/local/Caskroom/java/.metadata/1.8.0_141-b15,336fa29ff2bb4ef291e347e091f7f4a7/20170719070345.780/Casks/java.rb).
I think the issue is happening due to this.
Ok, I could fix it by removing the call to the undent method in the java.rb file in the .metadata directory. Once removed, I executed brew cask uninstall java && brew cask install java. After this I got last java version installed.
However, it would be great that brew could handle these cases in which the installed versions of the packages are outdated.
Yes, that is the correct solution for now. Closing as duplicate.
Most helpful comment
Ok, I could fix it by removing the call to the
undentmethod in thejava.rbfile in the.metadatadirectory. Once removed, I executedbrew cask uninstall java && brew cask install java. After this I got last java version installed.However, it would be great that brew could handle these cases in which the installed versions of the packages are outdated.