How to add a downloaded .box file to Vagrant?

115,140

Solution 1

Solution:

vagrant box add my-box file:///d:/path/to/file.box

Has to be in a URL format.

Solution 2

You can point to the folder where vagrant and copy the box file to same location. Then after you may run as follows

vagrant box add my-box name-of-the-box.box
vagrant init my-box
vagrant up

Just to check status

vagrant status

Solution 3

Try to change directory to where the .box is saved

Run vagrant box add my-box downloaded.box, this may work as it avoids absolute path (on Windows?).

Solution 4

Alternatively to add downloaded box, a json file with metadata can be created. This way some additional details can be applied. For example to import box and specifying its version create file:

{
  "name": "laravel/homestead",
  "versions": [
    {
      "version": "7.0.0",
      "providers": [
        {
          "name": "virtualbox",
          "url": "file:///path/to/box/virtualbox.box"
        }
      ]
    }
  ]
}

Then run vagrant box add command with parameter:

vagrant box add laravel/homestead /path/to/metadata.json

Solution 5

Solution for Windows:

  • Open the cmd or powershell as admin
  • CD into the folder containing the .box file
  • vagrant box add --name name_of_my_box 'name_of_my_box.box'
  • vagrant box list should show the new box in the list

Solution for MAC:

  • Open terminal
  • CD into the folder containing the .box file
  • vagrant box add --name name_of_my_box "./name_of_my_box.box"
  • vagrant box list should show the new box in the list
Share:
115,140
Petrus Theron
Author by

Petrus Theron

I solve business problems with software. Over the past 15 years I have risked significant personal wealth to work on multiple startups. My unique experience allows me to understand a human desire, design a product that satisfies that need - then build and deploy it single-handedly from concept to scale. Sometimes I write about it. I primarily work in Clojure/ClojureScript, but I have built small to medium-sized products (sub-million LOC) using Python, C#, C/C++, Java, Pascal and JavaScript. Products I built: 2007-2011 Rhythm Music Store: online music store / record label that that sold 80k MP3s online. MyNames: an API to register .CO.ZA domains and provision nameservers. Stack: Python, AngularJS. Krit.com: a mobile customer feedback tool that used geolocation and SMS to bridge the gap between customers and retail managers 2007-2016: iFix (now weFix) Repair Management System tracks 500k repairs and millions in revenues at 36+ branches. Acquired by weFix. ...several others. There are more. Happy to delve into technical details. Good with people and recruiting.

Updated on December 04, 2020

Comments

  • Petrus Theron
    Petrus Theron over 3 years

    How do I add a downloaded .box file to Vagrant's list of available boxes? The .box file is located on an external drive.

    I tried running vagrant box add my-box d:/path/to/box, but Vagrant interprets the path as a URL.

  • Rakib
    Rakib over 8 years
    what if i use vagrant box add my-box ./path/to/mybox.box ?
  • Rakib
    Rakib over 8 years
    i did vagrant init and vagrant up and my vagrant box is running. But i can't ssh. When i do vagrant ssh it says "The machine you're attempting to SSH into is configured to use password-based authentication. Vagrant can't script entering the password for you. If you're prompted for a password, please enter the same password you have configured in the Vagrantfile." whereas i didn't configure anything in the Vagrantfile. I am just using the Vagrantfile that got automatically created upon vagrant init. When i cat Vagrantfile, I don't see anything called a password or pem or anything
  • Rakib
    Rakib over 8 years
    i did vagrant init and vagrant up and my vagrant box is running. But i can't ssh. When i do vagrant ssh it says "The machine you're attempting to SSH into is configured to use password-based authentication. Vagrant can't script entering the password for you. If you're prompted for a password, please enter the same password you have configured in the Vagrantfile." whereas i didn't configure anything in the Vagrantfile. I am just using the Vagrantfile that got automatically created upon vagrant init. When i cat Vagrantfile, I don't see anything called a password or pem or anything
  • Brad Parks
    Brad Parks over 7 years
    you can also pass -f to force it to download the box again, and replace it if it already exists. e.g. vagrant box add -f my-box http://some-url
  • codewario
    codewario over 7 years
    If vagrant ssh is asking for a password, and the base box you're using is public, chances are the password is vagrant.
  • Karim Samir
    Karim Samir about 7 years
    I have the same error and password vagrant didn't solve it
  • Redsandro
    Redsandro over 5 years
    The password for the modern.ie Microsoft boxes is Passw0rd!
  • Eugen Mayer
    Eugen Mayer over 5 years
    vagrant under macos and linux (2.2.2) works with a nun URI path to, so the scheme file:// can be omitted here at least. Maybe that a version specific change or its windows specific, i rather expect the latter one
  • Faizan Anwer Ali Rupani
    Faizan Anwer Ali Rupani over 3 years
    Finally a solution. Thanks
  • MakisH
    MakisH about 3 years
    To everybody who cannot ssh afterwards, the problem originates from the box export. You need to add the Vagrant insecure public key to the authorized keys again. See stackoverflow.com/questions/30075461/…