hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.24k stars 4.43k forks source link

Boxes are listed alphabetically, breaking box usage and update #7582

Closed e7d closed 7 years ago

e7d commented 8 years ago

Vagrant seems to be inconsistent with version handling, sometimes parsing it correctly as a version number, sometimes processing it as a simple string. In the later case, this causes some erroneous alphabetical comparisons leading to inconsistent reactions. Local file processing seems to use string version, like vagrant box list command. Calls to the Atlas platform seem to process version numbers correctly.

The best example is with the vagrant box update command. First, it will eroneously find the latest version alphabetically, then ask Atlas for the latest one, then utlimately that the one answered correctly by Atlas is actually already installed.

Vagrant version

Vagrant 1.8.4

Host operating system

Windows 10 Pro

Guest operating system

Not relevant

Vagrantfile

Vagrant.configure(2) do |config|
    config.vm.define "Neap" do |node|
        # For a complete reference, please see the online documentation at
        # https://docs.vagrantup.com.

        # General configuration
        node.vm.hostname = "neap.dev"
        node.vm.box = "e7d/neap-box"
        node.vm.box_version = ">= 1.2.6"
        node.hostsupdater.aliases = ["api.neap.dev", "db.neap.dev", "doc.neap.dev", "irc.neap.dev", "mail.neap.dev", "rtmp.neap.dev", "socket.neap.dev", "static.neap.dev", "www.neap.dev"]

        # Network configuration
        node.vm.network "private_network", ip: "192.168.32.10"
        node.vm.network "public_network"
        node.vm.network "forwarded_port", guest: 80, host: 8080
        node.vm.network "forwarded_port", guest: 443, host: 8443
        node.vm.network "forwarded_port", guest: 5432, host: 5432

        # Synced folder configuration
        node.vm.synced_folder ".", "/vagrant", type: "nfs"

        # VirtualBox provider
        node.vm.provider "virtualbox" do |vb|
            # System configuration
            vb.name = "Neap"
            vb.cpus = "4"
            vb.memory = "1024"

            # Additional storage configuration
            data_disk = "./.vagrant/machines/neap/virtualbox/data.vdi"
            unless File.exist?(data_disk)
                vb.customize ["createhd", "--filename", data_disk, "--size", 512 * 1024]
                vb.customize ["storageattach", :id, "--storagectl", "SATA Controller", "--port", 1, "--device", 0, "--type", "hdd", "--medium", data_disk]
            end
        end

        #  VirtualBox Guest update
        node.vbguest.auto_update = true
        node.vbguest.no_remote = true

        # Provisioning script
        node.vm.provision "shell" do |s|
            s.inline = "/vagrant/bootstrap.sh | tee /vagrant/bootstrap.log"
            s.keep_color = true
        end
    end
end

Debug output

http://pastebin.com/8JWmyf71

Expected behavior

λ vagrant box list
e7d/neap-box            (virtualbox, 1.2.5)
e7d/neap-box            (virtualbox, 1.2.7)
e7d/neap-box            (virtualbox, 1.2.8)
e7d/neap-box            (virtualbox, 1.2.11)
λ vagrant box update
==> Neap: Checking for updates to 'e7d/neap-box'
    Neap: Latest installed version: 1.2.11
    Neap: Version constraints: = 1.2.6
    Neap: Provider: virtualbox
==> Neap: Box 'e7d/neap-box' (v1.2.11) is running the latest version.
λ vagrant up
Bringing machine 'Neap' up with 'virtualbox' provider...
==> Neap: Importing base box 'e7d/neap-box'...
==> Neap: Matching MAC address for NAT networking...
==> Neap: Checking if box 'e7d/neap-box' is up to date...
==> Neap: Setting the name of the VM: Neap
...

Actual behavior

λ vagrant box list
e7d/neap-box            (virtualbox, 1.2.11)
e7d/neap-box            (virtualbox, 1.2.5)
e7d/neap-box            (virtualbox, 1.2.7)
e7d/neap-box            (virtualbox, 1.2.8)
λ vagrant box update
==> Neap: Checking for updates to 'e7d/neap-box'
    Neap: Latest installed version: 1.2.8
    Neap: Version constraints: >= 1.2.6
    Neap: Provider: virtualbox
==> Neap: Updating 'e7d/neap-box' with provider 'virtualbox' from version
==> Neap: '1.2.8' to '1.2.11'...
==> Neap: Loading metadata for box 'https://atlas.hashicorp.com/e7d/neap-box'
==> Neap: Adding box 'e7d/neap-box' (v1.2.11) for provider: virtualbox
The box you're attempting to add already exists. Remove it before
adding it again or add it with the `--force` flag.

Name: e7d/neap-box
Provider: virtualbox
Version: 1.2.11
λ vagrant up
Bringing machine 'Neap' up with 'virtualbox' provider...
==> Neap: Importing base box 'e7d/neap-box'...
==> Neap: Matching MAC address for NAT networking...
==> Neap: Checking if box 'e7d/neap-box' is up to date...
==> Neap: A newer version of the box 'e7d/neap-box' is available! You currently
==> Neap: have version '1.2.8'. The latest is version '1.2.11'. Run
==> Neap: `vagrant box update` to update.
==> Neap: Setting the name of the VM: Neap
...

Steps to reproduce

  1. Have a box with available a latest version build installed >10 (ie: 1.11), having previous ones also installed (ie: 1.0, 1.7 and 1.9)
  2. Run vagrant box list and see versions order (alphabetical)
  3. Run vagrant box update, see vagrant trying to update to latest available version, then fail because files already exists.
  4. Run vagrant up and see Vagrant advertising about an available update for the latest version, even being already installed.

    References

None found

bruno commented 8 years ago

I am seeing the same behaviour with Vagrant 1.8.5 on OSX with only atlas version numbering:

$ vagrant box list
waysact/trusty64    (vmware_desktop, 14)
waysact/trusty64    (vmware_desktop, 17)
waysact/trusty64    (vmware_desktop, 5)
waysact/trusty64    (vmware_desktop, 8)
phyber commented 7 years ago

This issue should be fixed by #7956.

chrisroberts commented 7 years ago

Fixed via #7956 and #8334. Thanks for opening this issue.

ghost commented 4 years ago

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.