3

On OSX El Captain 10.11.6, I have

$ VirtualBox --help
Oracle VM VirtualBox Manager 5.0.16

I'm trying to uninstall virtual box but getting following ...

brew cask uninstall --force virtualbox
Error: undefined method `<=' for nil:NilClass
Did you mean?  <=>
Follow the instructions here:
  https://github.com/caskroom/homebrew-cask#reporting-bugs
/usr/local/Caskroom/virtualbox/.metadata/5.0.16-105871/20160414170649.906/Casks/virtualbox.rb:2:in `block in load'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cask.rb:23:in `instance_eval'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cask.rb:23:in `initialize'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cask_loader.rb:29:in `new'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cask_loader.rb:29:in `cask'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cask_loader.rb:65:in `cask'
/usr/local/Homebrew/Library/Homebrew/compat/hbc/cask_loader.rb:10:in `cask'
/usr/local/Caskroom/virtualbox/.metadata/5.0.16-105871/20160414170649.906/Casks/virtualbox.rb:1:in `load'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cask_loader.rb:55:in `instance_eval'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cask_loader.rb:55:in `load'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cask_loader.rb:168:in `load'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cli/uninstall.rb:19:in `block in run'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cli/uninstall.rb:12:in `each'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cli/uninstall.rb:12:in `run'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cli/abstract_command.rb:35:in `run'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cli.rb:98:in `run_command'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cli.rb:168:in `run'
/usr/local/Homebrew/Library/Homebrew/cask/lib/hbc/cli.rb:132:in `run'
/usr/local/Homebrew/Library/Homebrew/cmd/cask.rb:8:in `cask'
/usr/local/Homebrew/Library/Homebrew/brew.rb:100:in `<main>'

Here is first line of the file it is complaining about :

cat /usr/local/Caskroom/virtualbox/.metadata/5.0.16-105871/20160414170649.906/Casks/virtualbox.rb

cask 'virtualbox' do
  if MacOS.release <= :lion

Any ideas ?

k1eran
  • 4,492
  • 8
  • 50
  • 73

3 Answers3

7

open a terminal and run the following command

brew update
brew cleanup

remove all the packages with brew

brew cask rm virtualbox --force
brew cask rm vagrant --force
brew cask rm vagrant-manager --force

remove any existing packages that might have been missed

rm -rf /Applications/Vagrant* /Applications/VirtualBox
sudo rm -f /usr/bin/vagrant /usr/local/bin/vagrant
sudo rm -rf /opt/vagrant /opt/homebrew-cask/Caskroom/va* /opt/homebrew-cask/Caskroom/virtualbox
rm -rf ~/.vagrant* ~/.docker ~/Virtual*
rm -rf /usr/local/Caskroom/virtualbox && rm -rf /Applications/VirtualBox.app/
sudo pkgutil --forget com.vagrant.vagrant

UPDATE: if you wish to reinstall it run the following commands

brew cleanup
brew update --rebase
brew upgrade --cleanup
brew install vagrant-completion --force
brew cask install virtualbox --force
brew cask install vagrant --force
brew cask install vagrant-manager --force
brew upgrade --cleanup
brew cleanup
brew doctor
sudo shutdown -r now
CatChMeIfUCan
  • 569
  • 1
  • 7
  • 26
  • This still leave it installed ? e.g ls /usr/local/Caskroom/virtualbox/5.0.16-105871/ Applications@ UserManual.pdf* VirtualBox.pkg VirtualBox_Uninstall.tool* – k1eran Mar 01 '18 at 00:29
  • it will completely uninstall it since you will delete any existing packages – CatChMeIfUCan Mar 01 '18 at 00:36
  • I ran your commands and additional had to manually remove /usr/local/Caskroom/virtualbox and /Applications/VirtualBox.app/. After that I was able to `brew cask reinstall virtualbox --verbose --debug` which previously had been failing – k1eran Mar 01 '18 at 00:53
  • Can you add those steps to your answer, then I will accept it. Cheers. – k1eran Mar 01 '18 at 01:00
  • which commands you like to be added? i have updated the answer regarding your desire to reinstall – CatChMeIfUCan Mar 01 '18 at 09:29
  • 1
    Hi there I had to also manually do ... rm -rf /usr/local/Caskroom/virtualbox && rm -rf /Applications/VirtualBox.app/ – k1eran Mar 01 '18 at 10:01
  • 2
    Hi, thanks for the suggestion it has been added to answer. – CatChMeIfUCan Mar 01 '18 at 10:47
  • why would you remove `~/.docker`? – Martin Feb 09 '19 at 08:48
1
brew uninstall --cask --force virtualbox
Kiryl Plyashkevich
  • 2,157
  • 19
  • 18
0

Uninstalling virtualbox worked for me after removing the offending call to MacOS.release from the old virtualbox.rb script. The file should be hereabouts:

/usr/local/Caskroom/virtualbox/.metadata/5.0.14-105127/20160220202816.699/Casks/virtualbox.rb

With a text editor, remove the if statement and only keep the branch that selects the installed 5.0.14 version. After that, brew should be able to parse and then uninstall the old virtualbox cask using a simple

brew cask uninstall virtualbox

axel
  • 1