Search code examples
rubydockervagrant

FrozenError while trying to use Vagrant


I'm trying to raise some linux virtual machines with Vagrant, however, I am met with this error everytime. I even re-installed vagrant but nothing helped so far.

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'ubuntu/focal64' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'ubuntu/focal64'
    default: URL: https://vagrantcloud.com/ubuntu/focal64
==> default: Adding box 'ubuntu/focal64' (v20230803.0.0) for provider: virtualbox

C:/Users/Alex/.vagrant.d/gems/3.1.3/gems/rubyhacks-0.1.5/lib/rubyhacks.rb:342:in `-@': can't modify frozen String: "=" (FrozenError)
        from C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/3.1.0/rubygems/requirement.rb:114:in `parse'
        from C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/3.1.0/rubygems/requirement.rb:138:in `block in initialize'
        from C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/3.1.0/rubygems/requirement.rb:138:in `map!'
        from C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/3.1.0/rubygems/requirement.rb:138:in `initialize'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/box_collection.rb:280:in `new'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/box_collection.rb:280:in `block in find'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/box_collection.rb:278:in `map'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/box_collection.rb:278:in `find'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/action/builtin/box_add.rb:325:in `box_add'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/action/builtin/box_add.rb:293:in `add_from_metadata'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/action/builtin/box_add.rb:128:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/action/warden.rb:48:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/action/builder.rb:180:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/action/runner.rb:101:in `block in run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/util/busy.rb:19:in `busy'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/action/runner.rb:101:in `run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/action/builtin/handle_box.rb:83:in `handle_box'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/action/builtin/handle_box.rb:42:in `block in call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/action/builtin/handle_box.rb:36:in `synchronize'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/action/builtin/handle_box.rb:36:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/action/warden.rb:48:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/action/warden.rb:127:in `block in finalize_action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/action/warden.rb:48:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/action/builder.rb:180:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/action/runner.rb:101:in `block in run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/util/busy.rb:19:in `busy'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/action/runner.rb:101:in `run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/action/builtin/call.rb:53:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/action/warden.rb:48:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/plugins/providers/virtualbox/action/check_virtualbox.rb:20:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/action/warden.rb:48:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/action/builder.rb:180:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/action/runner.rb:101:in `block in run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/util/busy.rb:19:in `busy'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/action/runner.rb:101:in `run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/machine.rb:248:in `action_raw'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/machine.rb:217:in `block in action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/environment.rb:631:in `lock'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/machine.rb:203:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/machine.rb:203:in `action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.3.7/lib/vagrant/batch_action.rb:86:in `block (2 levels) in run'

Has anyone ever encountered such problem?

I tried re-installing Vagrant but it did not fix the problem.


Solution

  • These errors point to problems with ruby. Having different errors for different versions of vagrant points to the version of ruby being wrong. Vagrant needs specific versions of ruby to run correctly.

    According to the documentation, there should be a file called vagrant.gemspec which specifies the ruby version that this version of vagrant needs. Using ruby -v should show you which version you are using. If those differ, the fix is to install the required version of ruby.