diff --git a/builder/virtualbox/step_attach_guest_additions.go b/builder/virtualbox/step_attach_guest_additions.go index 4ed259990..c0710bc16 100644 --- a/builder/virtualbox/step_attach_guest_additions.go +++ b/builder/virtualbox/step_attach_guest_additions.go @@ -25,7 +25,6 @@ type stepAttachGuestAdditions struct { func (s *stepAttachGuestAdditions) Run(state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*config) driver := state.Get("driver").(Driver) - guestAdditionsPath := state.Get("guest_additions_path").(string) ui := state.Get("ui").(packer.Ui) vmName := state.Get("vmName").(string) @@ -35,6 +34,9 @@ func (s *stepAttachGuestAdditions) Run(state multistep.StateBag) multistep.StepA return multistep.ActionContinue } + // Get the guest additions path since we're doing it + guestAdditionsPath := state.Get("guest_additions_path").(string) + // Attach the guest additions to the computer log.Println("Attaching guest additions ISO onto IDE controller...") command := []string{ diff --git a/builder/virtualbox/step_upload_guest_additions.go b/builder/virtualbox/step_upload_guest_additions.go index 3999368a5..2dce09d0e 100644 --- a/builder/virtualbox/step_upload_guest_additions.go +++ b/builder/virtualbox/step_upload_guest_additions.go @@ -19,7 +19,6 @@ func (s *stepUploadGuestAdditions) Run(state multistep.StateBag) multistep.StepA comm := state.Get("communicator").(packer.Communicator) config := state.Get("config").(*config) driver := state.Get("driver").(Driver) - guestAdditionsPath := state.Get("guest_additions_path").(string) ui := state.Get("ui").(packer.Ui) // If we're attaching then don't do this, since we attached. @@ -28,6 +27,9 @@ func (s *stepUploadGuestAdditions) Run(state multistep.StateBag) multistep.StepA return multistep.ActionContinue } + // Get the guest additions path since we're doing it + guestAdditionsPath := state.Get("guest_additions_path").(string) + version, err := driver.Version() if err != nil { state.Put("error", fmt.Errorf("Error reading version for guest additions upload: %s", err))