Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vagrant / Virtualbox crashes when installing npm modules #2786

Closed
aeneasr opened this issue Jan 8, 2014 · 26 comments
Closed

Vagrant / Virtualbox crashes when installing npm modules #2786

aeneasr opened this issue Jan 8, 2014 · 26 comments

Comments

@aeneasr
Copy link

aeneasr commented Jan 8, 2014

Hi,
I've been trying to get Vagrant up and running with precise32 and it works fine on Mac OS X. However, on Windows host it crashes during installing files from NPM.

My Vagrantfile is:

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

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|  
  config.vm.box = "http://files.vagrantup.com/precise32.box"
  config.vm.box = "precise32"
  config.vm.provision :shell, :path => "bootstrap.sh"
  config.vm.network :forwarded_port, host: 4567, guest: 80
  config.vm.network :forwarded_port, host: 3456, guest: 3306
  config.vm.synced_folder "../", "/var/www", :owner => "www-data", :group => "www-data", type: "nfs"
end

My bootstrap looks like:



# Install basic stuff
apt-get -y update
apt-get install -y python-software-properties python g++ make python-software-properties
apt-get install -y apache2 mysql-server-5.5 git sphinxsearch

# Add repositories with current versions
sudo add-apt-repository -y ppa:chris-lea/node.js
sudo add-apt-repository -y ppa:ondrej/php5
sudo add-apt-repository -y ppa:muffinresearch/sass-3.2
sudo add-apt-repository -y ppa:muffinresearch/compass
apt-get -y update

# Install php

apt-get install -y libapache2-mod-php5 php5 php5-intl php5-mysql php5-curl php-pear phpmyadmin php5-xdebug php5-cli

# Install nodejs related stuff

apt-get install -y nodejs
apt-get install -y npm
apt-get install -y ruby-sass 
apt-get install -y ruby-compass
usermod -a -G vagrant www-data

# Install npm dependencies

npm -g install bower --no-bin-links
npm -g install grunt --no-bin-links
npm -g install grunt-cli --no-bin-links
npm -g install pm2 --no-bin-links
npm -g install dnode --no-bin-links

Somewhere when installing npm stuff, the vbox crashes. Npm has a very high IO load as there are many files that are being written. I think that this is related to the issue (since I'm reading buffered_io). However, those files are being installed with -g which means that they're installed globally and should not be installed in the /vagrant directory but rather in something like /root/.npm. Additionally I don't think that the install fails as npm outputs npm http GET, so maybe it's the temp dir - but to be honest, I have no clue why this happens.

I've attached the crash log, so I hope this helps you a little bit.

Please also note, that the crash happens randomly when executing npm. Sometimes execution stops at installing "configstore", sometimes at "archy", sometimes at "which". So I don't think this is related to npm

hashi1

hashi2

hashi3

@aeneasr
Copy link
Author

aeneasr commented Jan 8, 2014

Also, this might be better placed in the VirtualBox forums, but I wanted to start an issue here first just to make sure.

@tmatilai
Copy link
Contributor

tmatilai commented Jan 8, 2014

@arekkas please get the full debug output:

vagrant up --debug > vagrant.log 2>&1

Then gist the vagrant.log file and add link to it here. Also take a look at the npm-debug.log file on the VM.

@aeneasr
Copy link
Author

aeneasr commented Jan 8, 2014

https://gist.github.com/arekkas/8318589

Unfortunately I don't know how to open the npm-debug.log file, since the VM crashes :D

@aeneasr
Copy link
Author

aeneasr commented Jan 8, 2014

I've also found some problems which could be related to this one:

However, the physical network is on both hosts (Windows and Mac) the same. Although the one is connected through WLAN (Mac) and the other through LAN (Windows)

@aeneasr
Copy link
Author

aeneasr commented Jan 8, 2014

Is there a way to not let vagrant destroy the box when it crashes so I can recover the virtualbox.log file?

@tmatilai
Copy link
Contributor

tmatilai commented Jan 8, 2014

Unfortunately I don't know how to open the npm-debug.log file, since the VM crashes :D

Haha, gotcha. =)

Unfortunately I have no idea what is happening based on the Vagrant log. But I'm not sure the VM actually crashes or if the connection is just lost. Vagrant will destroy the box in both cases. You could run vagrant up --no-provision and then vagrant provision to see that.

@aeneasr
Copy link
Author

aeneasr commented Jan 8, 2014

Nope, the VM crashes, since vagrant ssh returns "no vm running". I've tried running npm -g install bower from vagrant ssh but that crahses the VM as well. Unfortunately VBox.log doesn't give any hints about the crash (at least I couldn't find anything). This is really really weird. However, here's the npm-log:

https://gist.github.com/arekkas/8319277

@tmatilai
Copy link
Contributor

tmatilai commented Jan 8, 2014

vagrant ssh after vagrant up --no-provision; vagrant provision? Then it really seems like VirtualBox bug.

@aeneasr
Copy link
Author

aeneasr commented Jan 8, 2014

Yes I think it is an VirtualBox bug. I've already created a ticket here: https://www.virtualbox.org/ticket/12588

@tmatilai
Copy link
Contributor

tmatilai commented Jan 8, 2014

I'm closing this for now. Please reopen if you get information what Vagrant could do to avoid the issue.

@tmatilai tmatilai closed this as completed Jan 8, 2014
@aeneasr
Copy link
Author

aeneasr commented Jan 8, 2014

Will do, thank you for your support!

@aeneasr
Copy link
Author

aeneasr commented Jan 8, 2014

By the way, the guest additions of the precise32 box are way outdated, maybe you could consider updating them to a recent version!

@tmatilai
Copy link
Contributor

tmatilai commented Jan 8, 2014

Agreed, but some people still use 4.2.x while others 4.3.y.

But you can use vagrant-vbguest plugin to automatically keep them in sync with the VirtualBox version on your host. I though I checked from your log that the versions matched but apparently didn't. Must have been other case. Too much debug log again today for me. ;)

@aeneasr
Copy link
Author

aeneasr commented Jan 8, 2014

Ah cool, thanks for the tip :)

@aeneasr
Copy link
Author

aeneasr commented Jan 8, 2014

I'm sorry for posting here again, but this has to do something with the combination of vagrant and virtualbox. I've created a custom debian box with most of the stuff I need pre-configured and pre-installed (modules like grunt, bower, grunt-cli, etc). While setting up everything worked fine but as soon as I make a box out of it and run "vagrant up", npm crashes the box.

Maybe someone could test this on their own windows system? Maybe it's something with Windows itself?

@aeneasr
Copy link
Author

aeneasr commented Jan 8, 2014

Okay this issue seems to be related to 'NAT Networking'. Is there a possibility to use another networking provider like 'Network bridge'? I couldn't find anything in the docs, but maybe I'm way to tired to find it :D

Still, when setting up a machine in the vbox gui, NAT isn't a problem, only when using vagrant the problem appears.

@drpebcak
Copy link

drpebcak commented Jan 9, 2014

@arekkas Vagrant has a public_network feature that creates a bridged network.

@aeneasr
Copy link
Author

aeneasr commented Jan 9, 2014

Unfortunately, this only enables a secondary network adapter, it doesn't disable the NAT tho -> still crashing :(

@tmatilai
Copy link
Contributor

tmatilai commented Jan 9, 2014

Yeah, Vagrant currently always creates the first interface as a NAT one. No way around it as far as I know.

@drpebcak
Copy link

drpebcak commented Jan 9, 2014

You could use vbox manage to remove that interface, but then I doubt your networking would continue to function. It's worth a try.

@aeneasr
Copy link
Author

aeneasr commented Jan 9, 2014

Thank you for investigation, right DNS calls are done extremely intensive in short period. Could you please attach pcap files for Athene2-vm and vagran_default? there is other thing that I've noticed in file.pcap, the order of responses, that could potentially be a reason. And one thing actually Athene2-vm isn't exactly clone of vagrant_default : the first one uses list of DNS servers exported by VirtualBox to guest, while valgrant_default uses dnsproxy. I believe that once you change it Athene2-vm will also crash.

Is there a possibility to not use dnsproxy?

@tmatilai
Copy link
Contributor

tmatilai commented Jan 9, 2014

The only DNS setting I know is:

config.vm.provider :virtualbox do |vb|
  vb.customize ['modifyvm', :id, '--natdnshostresolver1', 'on']
end

You can try if that makes a difference.

@aeneasr
Copy link
Author

aeneasr commented Jan 9, 2014

Thanks, I'll try that once I'm home! :)

@aeneasr
Copy link
Author

aeneasr commented Jan 9, 2014

That solves the problem!

@aeneasr
Copy link
Author

aeneasr commented Jan 9, 2014

Maybe you could include this in a cookbook or a known issues section, so other people find this quickly :)

@BenjaminPaap
Copy link

If I only found this one weeks ago. Thank you guys so much. Was struggling with this issue for days now.

mmarschall added a commit to mmarschall/chef-repo that referenced this issue Dec 27, 2014
@ghost ghost locked and limited conversation to collaborators Apr 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants