Virtual Box Vagrant Crashes

Some more ideas to add to @alwaysblank’s list

  • Could your computer be overheating? Are you running multiple VMs at once, or the entire Adobe suite at the same time which could be eating up all your memory?

Also, what does a “crash” mean in this context? Does the computer shut off? Does it reboot? What’s the result of the crash?

2 Likes

Thanks. Unfortunately, everything after ‘vagrant destroy’ is beyond my understanding.

I’ve just had another crash when adding a blade partial. So I’m going to suspend the VB whenever I work on blade partials (where I’m adding HTML for engineers to later integrate). When I get the HTML ready, I’ll start the VB again and work on the styles.

I’m alone this week, engineer out of town, and I can’t afford to keep losing time on this.

Crash = kernel panic. Computer shut down and restart.

Last Friday I talked to Apple support and they suggested I reinstall the OS. That took a LOT of time and had no effect.

Sometimes I’ve got an Adobe app or 2 open, but not in last couple days. Sketch is open. Streaming music is on. 20 or so Google tabs are open. Coda & SourceTree. Plus assorted apps for time, calendar, screen saver, measuring, color, etc. Fan does seem to run loudly every now and then, but it’s not tied to crashes. As I mention above, working in any of the blade.php files DOES seem to trigger the crash. I’m keeping eyes on that now and changing up my workflow.

Weirdly…no panic.log is in system diagnostics.

I find it hard to believe that I’m maxing out a brand new MBP 15" with upgraded processor and 16GB of memory

Can you post your Vagrantfile? I googled around a little and found a number of people with similar issues that appear to be caused by using Mac’s NFS support.

1 Like

Have you tried discarding your existing Trellis directory/install and starting fresh?

Unusual behavior with macOS and Vagrant with NFS makes me think it’s worth also trying this edit in your Vagrantfile, replacing this line as follows:

       trellis_config.wordpress_sites.each_pair do |name, site|
-        config.vm.synced_folder local_site_path(site), nfs_path(name), type: 'nfs'
+        config.vm.synced_folder local_site_path(site), nfs_path(name), type: 'nfs', mount_options: [ 'nolock', 'vers=3', 'tcp', 'fsc', 'rw', 'noatime']
         config.bindfs.bind_folder nfs_path(name), remote_site_path(name, site), u: 'vagrant', g: 'www-data', o: 'nonempty'
       end

Then apply these changes by running this:
vagrant reload

If that helps, then

  • credit goes to @ben
  • and weird, because I vaguely thought the issue was resolved as of macOS 10.13.2
2 Likes

Thanks, @fullyint and @ben

I’ve made the change. I’ll let you know if it keeps my machine from crashing. Fingers crossed!

I’ve made the change from @fullyint below. Don’t want to fiddle with the Trellis install as I’m not comfortable re-doing all that and breaking what I do have.

 # -*- mode: ruby -*-
# vi: set ft=ruby :

ANSIBLE_PATH = __dir__ # absolute path to Ansible directory on host machine
ANSIBLE_PATH_ON_VM = '/home/vagrant/trellis' # absolute path to Ansible directory on virtual machine

require File.join(ANSIBLE_PATH, 'lib', 'trellis', 'vagrant')
require File.join(ANSIBLE_PATH, 'lib', 'trellis', 'config')
require 'yaml'

vconfig = YAML.load_file("#{ANSIBLE_PATH}/vagrant.default.yml")

if File.exist?("#{ANSIBLE_PATH}/vagrant.local.yml")
 local_config = YAML.load_file("#{ANSIBLE_PATH}/vagrant.local.yml")
 vconfig.merge!(local_config) if local_config
end

ensure_plugins(vconfig.fetch('vagrant_plugins')) if vconfig.fetch('vagrant_install_plugins')

trellis_config = Trellis::Config.new(root_path: ANSIBLE_PATH)

Vagrant.require_version '>= 2.0.1'

Vagrant.configure('2') do |config|
 config.vm.box = vconfig.fetch('vagrant_box')
 config.vm.box_version = vconfig.fetch('vagrant_box_version')
 config.ssh.forward_agent = true
 config.vm.post_up_message = post_up_message

 # Fix for: "stdin: is not a tty"
 # https://github.com/mitchellh/vagrant/issues/1673#issuecomment-28288042
 config.ssh.shell = %{bash -c 'BASH_ENV=/etc/profile exec bash'}

 # Required for NFS to work
 if vconfig.fetch('vagrant_ip') == 'dhcp'
   config.vm.network :private_network, type: 'dhcp', hostsupdater: 'skip'

   cached_addresses = {}
   config.hostmanager.ip_resolver = proc do |vm, _resolving_vm|
     if cached_addresses[vm.name].nil?
       if vm.communicate.ready?
         vm.communicate.execute("hostname -I | cut -d ' ' -f 2") do |type, contents|
           cached_addresses[vm.name] = contents.split("\n").first[/(\d+\.\d+\.\d+\.\d+)/, 1]
         end
       end
     end
     cached_addresses[vm.name]
   end
 else
   config.vm.network :private_network, ip: vconfig.fetch('vagrant_ip'), hostsupdater: 'skip'
 end

 main_hostname, *hostnames = trellis_config.site_hosts_canonical
 config.vm.hostname = main_hostname

 if Vagrant.has_plugin?('vagrant-hostmanager') && !trellis_config.multisite_subdomains?
   redirects = trellis_config.site_hosts_redirects

   config.hostmanager.enabled = true
   config.hostmanager.manage_host = true
   config.hostmanager.aliases = hostnames + redirects
 elsif Vagrant.has_plugin?('landrush') && trellis_config.multisite_subdomains?
   config.landrush.enabled = true
   config.landrush.tld = config.vm.hostname
   hostnames.each { |host| config.landrush.host host, vconfig.fetch('vagrant_ip') }
 else
   fail_with_message "vagrant-hostmanager missing, please install the plugin with this command:\nvagrant plugin install vagrant-hostmanager\n\nOr install landrush for multisite subdomains:\nvagrant plugin install landrush"
 end

 bin_path = File.join(ANSIBLE_PATH_ON_VM, 'bin')

 if Vagrant::Util::Platform.wsl? || (Vagrant::Util::Platform.windows? and !Vagrant.has_plugin? 'vagrant-winnfsd')
   trellis_config.wordpress_sites.each_pair do |name, site|
     config.vm.synced_folder local_site_path(site), remote_site_path(name, site), owner: 'vagrant', group: 'www-data', mount_options: ['dmode=776', 'fmode=775']
   end

   config.vm.synced_folder ANSIBLE_PATH, ANSIBLE_PATH_ON_VM, mount_options: ['dmode=755', 'fmode=644']
   config.vm.synced_folder File.join(ANSIBLE_PATH, 'bin'), bin_path, mount_options: ['dmode=755', 'fmode=755']
 else
   if !Vagrant.has_plugin? 'vagrant-bindfs'
     fail_with_message "vagrant-bindfs missing, please install the plugin with this command:\nvagrant plugin install vagrant-bindfs"
   else
     trellis_config.wordpress_sites.each_pair do |name, site|
       config.vm.synced_folder local_site_path(site), nfs_path(name), type: 'nfs', mount_options: [ 'nolock', 'vers=3', 'tcp', 'fsc', 'rw', 'noatime']
       config.bindfs.bind_folder nfs_path(name), remote_site_path(name, site), u: 'vagrant', g: 'www-data', o: 'nonempty'
     end

     config.vm.synced_folder ANSIBLE_PATH, '/ansible-nfs', type: 'nfs'
     config.bindfs.bind_folder '/ansible-nfs', ANSIBLE_PATH_ON_VM, o: 'nonempty', p: '0644,a+D'
     config.bindfs.bind_folder bin_path, bin_path, perms: '0755'
   end
 end

 vconfig.fetch('vagrant_synced_folders', []).each do |folder|
   options = {
     type: folder.fetch('type', 'nfs'),
     create: folder.fetch('create', false),
     mount_options: folder.fetch('mount_options', [])
   }

   destination_folder = folder.fetch('bindfs', true) ? nfs_path(folder['destination']) : folder['destination']

   config.vm.synced_folder folder['local_path'], destination_folder, options

   if folder.fetch('bindfs', true)
     config.bindfs.bind_folder destination_folder, folder['destination'], folder.fetch('bindfs_options', {})
   end
 end

 provisioner = local_provisioning? ? :ansible_local : :ansible
 provisioning_path = local_provisioning? ? ANSIBLE_PATH_ON_VM : ANSIBLE_PATH

 config.vm.provision provisioner do |ansible|
   if local_provisioning?
     ansible.install_mode = 'pip'
     ansible.provisioning_path = provisioning_path
     ansible.version = vconfig.fetch('vagrant_ansible_version')
   end

   ansible.playbook = File.join(provisioning_path, 'dev.yml')
   ansible.galaxy_role_file = File.join(provisioning_path, 'requirements.yml') unless vconfig.fetch('vagrant_skip_galaxy') || ENV['SKIP_GALAXY']
   ansible.galaxy_roles_path = File.join(provisioning_path, 'vendor/roles')

   ansible.groups = {
     'web' => ['default'],
     'development' => ['default']
   }

   ansible.tags = ENV['ANSIBLE_TAGS']
   ansible.extra_vars = { 'vagrant_version' => Vagrant::VERSION }

   if vars = ENV['ANSIBLE_VARS']
     extra_vars = Hash[vars.split(',').map { |pair| pair.split('=') }]
     ansible.extra_vars.merge!(extra_vars)
   end
 end

 # Virtualbox settings
 config.vm.provider 'virtualbox' do |vb|
   vb.name = config.vm.hostname
   vb.customize ['modifyvm', :id, '--cpus', vconfig.fetch('vagrant_cpus')]
   vb.customize ['modifyvm', :id, '--memory', vconfig.fetch('vagrant_memory')]
   vb.customize ['modifyvm', :id, '--ioapic', vconfig.fetch('vagrant_ioapic', 'on')]

   # Fix for slow external network connections
   vb.customize ['modifyvm', :id, '--natdnshostresolver1', vconfig.fetch('vagrant_natdnshostresolver', 'on')]
   vb.customize ['modifyvm', :id, '--natdnsproxy1', vconfig.fetch('vagrant_natdnsproxy', 'on')]
 end

 # VMware Workstation/Fusion settings
 ['vmware_fusion', 'vmware_workstation'].each do |provider|
   config.vm.provider provider do |vmw, override|
     vmw.name = config.vm.hostname
     vmw.vmx['numvcpus'] = vconfig.fetch('vagrant_cpus')
     vmw.vmx['memsize'] = vconfig.fetch('vagrant_memory')
   end
 end

 # Parallels settings
 config.vm.provider 'parallels' do |prl, override|
   prl.name = config.vm.hostname
   prl.cpus = vconfig.fetch('vagrant_cpus')
   prl.memory = vconfig.fetch('vagrant_memory')
   prl.update_guest_tools = true
 end
end

@ben @fullyint

Update for Wed: crashed again after making edits in header.blade.php file. Note: I was working OK in this file for a couple hours before it crashed. Thought everything was OK. Apparently, not. :frowning:

…aaand another crash. Back to square 1.

VB and Vagrant have been removed & replaced. Fingers crossed for better workflow today.

@ben @fullyint
Thursday update after rebuilding VB and Vagrant…still crashing.

How would I go about rebuilding my Trellis install? I don’t understand how to mess with that and not lose my work.

Backup your WordPress database. Destroy your Vagrant box.

Remove your trellis directory and start over from the instructions on GitHub.

Thanks @ben
I’ve replaced Trellis and will keep you posted.

I also increased the Base & Video Memory amounts in VB, as the VB GUI had an error message, saying the amount was insufficient. Base memory = 2048 MB, Video memory = 16 MB.

I’m very confused about the Ubuntu vs. Mac OSX thing. Seems if I create a VB in the GUI, I have the option of Mac High Sierra. But Vagrant(?) creates a VB for Ubuntu. I have no idea what, if any difference it makes. But, since I’ve rebuilt the VB, Vagrant & Trellis, I’m going with the Ubuntu option built from instructions…albeit with more memory as noted above.

I’m really confused about what you’re doing with the VB GUI. You’ll need to be making edits to your Vagrantfile if you want to change those settings.

Do not do this. You need to run vagrant up from the Trellis directory.

Please follow the Trellis docs and installation notes!

@ben @fullyint

OK. I give up. Just made some edits to a custom page template blade file. First save was OK. Second made the system crash (kernel panic). And I’ve successfully crashed it an additional 3 times on same file…just to be sure. :wink:

So, none of the following has resolved the problem:

  • Destroying & rebuilding Virtual Box
  • Adding memory to VB
  • Updating VB
  • Updating Vagrant
  • Removing & replacing Vagrant
  • Removing & replacing Trellis
  • Changing the line in Vagrantfile as recommended above

I’m now resorting to building HTML templates in CodePen and pasting them into blade files when VB is not running.

How the heck are the engineers going to work in blade files when I hand this over?

Would it be better if we gave up VB and used MAMP?

Thanks for your help.

I did run it from Trellis. I also experimented with the VB GUI. Been going around in circles.

@azzcatdesign I can only imagine how frustrating this must be. Thanks for having managed to keep a cooperative tone here. You avoided the entitled and blaming exasperation that sometimes creeps in for people in a desperate tools/project situation.

Will probably have to hire help rather than find it in forum. I think you’ll need some one-on-one assistance, more than this thread can offer. As @alwaysblank suggested, this looks similar to reports of kernel panic issues that will probably have a very disheartening prognosis. Examples: one, two, three

I don’t think this is a Roots issue. I think it’s more of a mix of vagrant + VB + mac kernel, which probably means everybody’s going to say “wrong forum.” And although this is a friendly forum, it’s probably not really a forum that must try to address the issue. In any case, if you end up seeking hired assistance, I endorse everyone who has posted above.

To use Roots stuff or not.

I don’t think this is a issue others do face or will face. I don’t recall any recent related reports here on Roots discourse. I suspect if you personally temporarily switch to a different machine, you and your colleagues won’t have to face the issue anymore.

So, you could do the non-VM workaround that you mentioned, but…
:star: I’d encourage you to try to find a different machine to work on till you’ve passed your most urgent deadlines. :star2:

If you decide to troubleshoot further, maybe the following questions and techniques will help.

Try avoiding NFS. Your Vagrantfile looks fine as posted, but could you try @alwaysblank’s suggestion of avoiding NFS? Comment out all of this sync config except this portion and vagrant reload (or save db, vagrant destroy and vagrant up).

The above edit of disabling NFS may cause you to run into issues of performance speed or the permissions issues discussed at roots/trellis#82 and roots/trellis#83 (when Trellis started using NFS).

Achieve consistent method to reproduce, then manipulate variables. Ideally your first step in troubleshooting would be to find a technique for consistently reproducing the issue. Then start cutting out as many variables as possible, testing after each, noting when the problem stops.

For example, if you use some text editor other than Coda, does the issue still happen? Related ideas for avoiding Coda and reducing reliance on the Vagrant sync folder:

What if you don’t use SourceTree?

The notes above show you how to eliminate NFS as a variable.

You could also see if it is reproducible while removing VirtualBox as a variable, using instead virtualization alternatives such as Parallels or VMware, if you have them.

Conflicting virtualization? Simplify the troubleshooting (remove more variables) by powering off or destroying any other VirtualBox VMs. Check the VB GUI for orphaned VMs. Also check vagrant global-status for any weird extra VMs and destroy them if possible. If this last command lists VMs that no longer exist in VB, you can vagrant global-status --prune to remove them from the list. And if you do have such virtualization alternatives like Parallels and VMware, be sure they aren’t running while you test on Vagrant + VB.

Think back to better days. Was there ever a period during which this didn’t happen? If so, what has changed with your system since? Maybe recent kernel Mac kernel updates? Updated VB, try a rollback to the previously known working version. Same with Vagrant; maybe rollback to previously working Vagrant version.

Other logs. Maybe check for any helpful info reports in the various

  • ~/Library/Logs/DiagnosticReports/
  • /Library/Logs/DiagnosticReports/
2 Likes