Fixing Virtualbox and Vagrant in macOS Mojave 10.14 Public Beta 3
- Download a build later than 5.2.12 of Virtualbox 5
- Disable System Integrity Protection (SIP)
- (Try to) Install Virtualbox
- Modify Kexts, rebuild Kernel Extension Cache
- Starting Virtualbox
- Fix plugin installations if you are using Vagrant and they fail to install
- Vagrant and Virtualbox 5.2 working on Mojave!
The new beta of Mac OS X Mojave is mostly stable and so far it has been a good experience… Apart from the recent issues that i have faced with homebrew legacy libraries and this recent problem with Virtualbox, which loads a Kernel Extension that has not yet been approved by Apple.
Here is a temporary solution to get you up and running with the latest Mac OS beta.
Download a build later than 5.2.12 of Virtualbox 5
Go here and download the current Virtualbox Testing version. I got Virtualbox 5.2.15 at this time.
Disable System Integrity Protection (SIP)
Yes, yes, I also hate this, but has to be done until Apple refreshes the list of allowed Kernel Extensions to allow VBoxDrv.kext
to load properly in Mojave.
- Reboot your Mac and hold Command + R (⌘ + R) before it boots.
- Keep holding it until you see the progress bar
- Wait for it to finish
- At the top menu, select Utilities -> Terminal
- Enter
csrutil disable
- Press Enter
- Type
reboot
After this is solved, do the same steps to re-enable SIP, but type csrutil enable
at Step 5.
(Try to) Install Virtualbox
Run the installer.
You will get an error message like this:
No worries, close it and continue.
Modify Kexts, rebuild Kernel Extension Cache
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#Fix Kernel Version
sudo sed -i '' 's/5\.2/5\.3/g' '/Library/Application Support/VirtualBox/VBoxDrv.kext/Contents/Info.plist'
sudo sed -i '' 's/5\.2/5\.3/g' '/Library/Application Support/VirtualBox/VBoxUSB.kext/Contents/Info.plist'
sudo sed -i '' 's/5\.2/5\.3/g' '/Library/Application Support/VirtualBox/VBoxNetAdp.kext/Contents/Info.plist'
sudo sed -i '' 's/5\.2/5\.3/g' '/Library/Application Support/VirtualBox/VBoxNetFlt.kext/Contents/Info.plist'
#Load Kernel Extensions
sudo kextload '/Library/Application Support/VirtualBox/VBoxDrv.kext'
sudo kextload -d '/Library/Application Support/VirtualBox/VBoxDrv.kext' '/Library/Application Support/VirtualBox/VBoxUSB.kext'
sudo kextload -d '/Library/Application Support/VirtualBox/VBoxDrv.kext' '/Library/Application Support/VirtualBox/VBoxNetFlt.kext'
sudo kextload -d '/Library/Application Support/VirtualBox/VBoxDrv.kext' '/Library/Application Support/VirtualBox/VBoxNetAdp.kext'
#Rebuild Kernel Extensions Cache
sudo kextcache -i /
# Start up Virtualbox GUI
Virtualbox &
Starting Virtualbox
Using the GUI will give you an error:
However, you should be able to start VirtualBox using the Terminal:
1
Virtualbox &
Fix plugin installations if you are using Vagrant and they fail to install
Before I had this, which worked before Mojave and in Linux too:
1
2
3
4
5
6
7
8
9
10
required_plugins = %w(vagrant-share vagrant-vbguest vagrant-disksize vagrant-proxyconf)
plugins_to_install = required_plugins.select { |plugin| not Vagrant.has_plugin? plugin }
if not plugins_to_install.empty?
puts "Installing plugins: #{plugins_to_install.join(' ')}"
if system "vagrant plugin install #{plugins_to_install.join(' ')}"
exec "vagrant #{ARGV.join(' ')}"
else
abort "Installation of one or more plugins has failed. Aborting."
end
This caused issues:
1
2
3
Exec error: fork/exec /opt/vagrant/embedded/bin/ruby: argument list too long
Exec error: fork/exec /opt/vagrant/embedded/bin/ruby: argument list too long
Exec error: fork/exec /opt/vagrant/embedded/bin/ruby: argument list too long
The solution was to reformulate the plugin installation code in the Vagrantfile
like this:
1
2
3
4
5
6
7
8
9
required_plugins = %w(vagrant-share vagrant-vbguest vagrant-disksize vagrant-proxyconf)
return if !Vagrant.plugins_enabled?
plugins_to_install = required_plugins.select { |plugin| !Vagrant.has_plugin? plugin }
if plugins_to_install.any?
system "vagrant plugin install #{plugins_to_install.join(' ')}"
exit system 'vagrant up'