diff --git a/lib/vagrant/machine.rb b/lib/vagrant/machine.rb index 8ebdd4636..6c05d9966 100644 --- a/lib/vagrant/machine.rb +++ b/lib/vagrant/machine.rb @@ -254,13 +254,21 @@ module Vagrant if index_uuid.nil? # Create the index entry and save it entry = MachineIndex::Entry.new - entry.extra_data["box"] = @config.vm.box entry.local_data_path = @env.local_data_path entry.name = @name.to_s entry.provider = @provider_name.to_s entry.state = "preparing" entry.vagrantfile_path = @env.root_path entry.vagrantfile_name = @env.vagrantfile_name + + if @box + entry.extra_data["box"] = { + "name" => @box.name, + "provider" => @box.provider.to_s, + "version" => @box.version.to_s, + } + end + entry = @env.machine_index.set(entry) @env.machine_index.release(entry) diff --git a/test/unit/vagrant/machine_test.rb b/test/unit/vagrant/machine_test.rb index e479b2e25..2ac2bb75e 100644 --- a/test/unit/vagrant/machine_test.rb +++ b/test/unit/vagrant/machine_test.rb @@ -403,7 +403,13 @@ describe Vagrant::Machine do end it "is set one when setting an ID" do - subject.config.vm.box = "FOO" + # Setup the box information + box = double("box") + box.stub(name: "foo") + box.stub(provider: :bar) + box.stub(version: "1.2.3") + subject.box = box + subject.id = "foo" uuid = subject.index_uuid @@ -412,12 +418,16 @@ describe Vagrant::Machine do # Test the entry itself entry = env.machine_index.get(uuid) - expect(entry.extra_data["box"]).to eq(subject.config.vm.box) expect(entry.name).to eq(subject.name) expect(entry.provider).to eq(subject.provider_name.to_s) expect(entry.state).to eq("preparing") expect(entry.vagrantfile_path).to eq(env.root_path) expect(entry.vagrantfile_name).to eq(env.vagrantfile_name) + expect(entry.extra_data["box"]).to eq({ + "name" => box.name, + "provider" => box.provider.to_s, + "version" => box.version, + }) env.machine_index.release(entry) end