Vagrant: All vagrant-commands throw ruby-stacktrace. Too large environment?

Created on 7 Nov 2017  ·  37Comments  ·  Source: hashicorp/vagrant

Hi,
running vagrant status (or any other vagrant-command) gives me the following stacktrace after 10~15 seconds. The error first appeared after trying to vagrant up a local development-machine, which is essentially a ubuntu/xenial64 packed with a webserver in a few lines of shell-provisioning. The vm runs perfectly fine on other systems, so i don't think its particulary relevant for this case. At least vagrant status doesn't even involve the vm.

~
C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.4.0/json/common.rb:156:in initialize': negative string size (or size too big) (ArgumentError) from C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.4.0/json/common.rb:156:innew'
from C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.4.0/json/common.rb:156:in parse' from C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.4.0/json/common.rb:335:inload'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/machine_index.rb:293:in unlocked_reload' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/machine_index.rb:53:inblock in initialize'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/machine_index.rb:323:in block in with_index_lock' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/machine_index.rb:321:inopen'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/machine_index.rb:321:in with_index_lock' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/machine_index.rb:52:ininitialize'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/environment.rb:741:in new' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/environment.rb:741:inmachine_index'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/environment.rb:215:in block in action_runner' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/runner.rb:33:inrun'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/environment.rb:543:in hook' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/environment.rb:792:inunload'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/bin/vagrant:141:in ensure in <main>' from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/bin/vagrant:141:in

'
~

Vagrant version

~bash
vagrant -v
Vagrant 2.0.1
~

Host operating system

(almost fresh) Windows 10

The long idle time before the stacktrace appears and the error-message itself suggest that there is a monstrous environment that vagrant wants to load before ruby eventually gives up.

bug hoswindows

Most helpful comment

Is there any workaround for this problem?

You can try downgrade virtual box to 5.1 if you use 5.2 and use vagrant 2.0.0

All 37 comments

Could you provide a gist to the full debug output when you try to run a command with vagrant? Thanks!

@RaoulSchaffranek - could you also provide the vagrantfile you're using? Thank you!

And here it is: https://gist.github.com/RaoulSchaffranek/a1d77e77305f74e49cce47546c94048c
I anonymized our customer name inside the file.

Also reproduced on Windows 8.1, OpenSSH 3.8.1p1, OpenSSL 0.9.7d 17 Mar 2004

same on win8.1 fresh install
cmd: vagrant init ubuntu/trusty64

Is there any workaround for this problem?

Is there any workaround for this problem?

You can try downgrade virtual box to 5.1 if you use 5.2 and use vagrant 2.0.0

Thank you! This worked for me

This worked for me too, thank you very much ! :-)

Isn't this a workaround? Do you have a definitive solution for this?

I have this ussue with vagrant 2.0.3 + VirtualBox 5.2.8 on Windows 10 too.

Same problem. Vagrant 2.0.3, Windows 7 SP1, VirtualBox 5.2.8, bento/debian-9.4

Whell, my solution is uninstall Vagrant completely . It works for me.

For those encountering this error, is it originating from the same location as the original poster in the machine_index.rb file?

Same issue on Windows 8.1, Vagrant 2.4 and VirtualBox 5.2.8.

C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.4.0/json/common.rb:156:in `initialize': negative string size (or size too big) (ArgumentError)
        from C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.4.0/json/common.rb:156:in `new'
        from C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.4.0/json/common.rb:156:in `parse'
        from C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.4.0/json/common.rb:335:in `load'
        from C:/HashiCorp/Vagrant/embedded/gems/2.0.4/gems/vagrant-2.0.4/lib/vagrant/machine_index.rb:293:in `unlocked_reload'
        from C:/HashiCorp/Vagrant/embedded/gems/2.0.4/gems/vagrant-2.0.4/lib/vagrant/machine_index.rb:53:in `block in initialize'
        from C:/HashiCorp/Vagrant/embedded/gems/2.0.4/gems/vagrant-2.0.4/lib/vagrant/machine_index.rb:323:in `block in with_index_lock'
        from C:/HashiCorp/Vagrant/embedded/gems/2.0.4/gems/vagrant-2.0.4/lib/vagrant/machine_index.rb:321:in `open'
        from C:/HashiCorp/Vagrant/embedded/gems/2.0.4/gems/vagrant-2.0.4/lib/vagrant/machine_index.rb:321:in `with_index_lock'
        from C:/HashiCorp/Vagrant/embedded/gems/2.0.4/gems/vagrant-2.0.4/lib/vagrant/machine_index.rb:52:in `initialize'

        from C:/HashiCorp/Vagrant/embedded/gems/2.0.4/gems/vagrant-2.0.4/lib/vagrant/environment.rb:708:in `new'
        from C:/HashiCorp/Vagrant/embedded/gems/2.0.4/gems/vagrant-2.0.4/lib/vagrant/environment.rb:708:in `machine_index'
        from C:/HashiCorp/Vagrant/embedded/gems/2.0.4/gems/vagrant-2.0.4/lib/vagrant/environment.rb:192:in `block in action_runner'
        from C:/HashiCorp/Vagrant/embedded/gems/2.0.4/gems/vagrant-2.0.4/lib/vagrant/action/runner.rb:33:in `run'
        from C:/HashiCorp/Vagrant/embedded/gems/2.0.4/gems/vagrant-2.0.4/lib/vagrant/environment.rb:510:in `hook'
        from C:/HashiCorp/Vagrant/embedded/gems/2.0.4/gems/vagrant-2.0.4/lib/vagrant/environment.rb:759:in `unload'
        from C:/HashiCorp/Vagrant/embedded/gems/2.0.4/gems/vagrant-2.0.4/bin/vagrant:154:in `ensure in <main>'
        from C:/HashiCorp/Vagrant/embedded/gems/2.0.4/gems/vagrant-2.0.4/bin/vagrant:154:in `<main>'

@gncgaspar Can you please provide a gist of the full command output with the --debug flag enabled? Thanks!

@gncgaspar Thanks! One more thing, can you provide a gist of the file in:

C:\Users\XYZ\.vagrant.d\data\index

This seems to be what's causing the issue and determining the underlying cause will let me provide a better fix. Thanks again!

@chrisroberts I checked C:\Users\XYZ.vagrant.d\data\index and that file does not exist.

@gncgaspar My apologies! I missed a directory in that path:

C:\Users\XYZ\.vagrant.d\data\machine-index\index

@chrisroberts That file exists but its size is around 1GB.

@gncgaspar Interesting. Do you currently have any Vagrant guests created (halted or running)? The size of the file is definitely the cause of the problem, but the file being that large is certainly unexpected. Do any of the local data paths for the machines defined in that file exist?

@gncgaspar And thanks again for all the information. Without seeing this locally to reproduce it is extremely helpful to understand what is going on with an affected system to formulate a fix. It's really appreciated :smiley:

I have the very same problem, as stated above I managed to run the vm by downgrading virtual box to 5.1.36 and vagrant to 2.0.0, removed the VM, restarted several times and recreated a new vm, then it was ok.
=> windows 10, box = ubuntu/xenial64

@Benibur What is the size of the file:

> C:\Users\YOUR_USERNAME\.vagrant.d\data\machine-index\index

Downgrading to vagrant 2.0.0 + Virtualbox 5.1.34 and re-creating VMs also did work for me. Currently the file which you mentioned is 2144 bytes (for version 2.0.0)

@dmaryenko-skyhook Were you receiving the same error message as the original issue description indicates?

common.rb:156:in `initialize': negative string size (or size too big) (ArgumentError)

Originally I had vagrant 2.0.0. When I updated Virtualbox and Vagrant it to latest versions - I started to receive the same error message. After investigation (with VMs removal and re-installing of virtualbox and vagrant, even with Windows re-installation) I've found that only vagrant 2.0.0 is still working, with Virtualbox 5.1.x. All newer versions raises the originally mentioned issue.

@dmaryenko-skyhook Is there any chance you could email me the file:

> C:\Users\YOUR_USERNAME\.vagrant.d\data\machine-index\index

I can't reproduce a state that causes the error being encountered and having a file known to cause the issue to test with would be very helpful.

@chrisroberts

What is the size of the file:

C:\Users\YOUR_USERNAME.vagrant.d\data\machine-index\index

Sorry, as I downgraded I erased the directory... And reproducing the problem means breking my working environement... not possible... good luck !

Бродяга не любит табуляции в файле Homestead.yaml ... Отступ должен быть с пробелами и точным.
Просто замените вкладки пробелами, и бродяга может начать. У меня сработало

Same problem. Deleting entire directory C:\Users\YOUR_USERNAME.vagrant.d\ helped for me. C:\Users\YOUR_USERNAME.vagrant.d\data\machine-index\index was ~700Mb (may be too big?).

Closing as an issue with the index file needing to be removed. If this issue reproduces itself, please open a new issue and provide the contents of the index file for inspection so that we can determine root cause of the issue. Cheers!

solution:
delete C:\Users\User \ .vagrant.d

I deleted the file and it worked perfectly
C:\Users\User \ .vagrant.d

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings