Latest installed version -- where is it stored?

28 views
Skip to first unread message

cmucluser

unread,
Apr 23, 2019, 7:32:49 PM4/23/19
to Vagrant
How does 'vagrant' determine the "Latest installed version" of a box?   Where is that info stored?
I can't find anything appropriate under '~/vagrant.d' (and am facing a problem related to that.)

Jim McGinness

unread,
Apr 24, 2019, 1:22:43 PM4/24/19
to Vagrant
Given the name of a box (with the VAGRANTSLASH substitution in place) under ~/.vagrant.d/boxes you will find a file named and containing the metadata_url and one or more version-number directories. These version-number directories contain the unpacked boxes. The highest-numbered version is considered the "latest installed version". To discover if a more recent version exists, vagrant fetches the info via the metadata_url.

If you are asking a slightly different question, "how does vagrant determine the version of a box used to create an existing vm?", the answer is found in ~.vagrant.d/data/machine-index/index which contains the box and version info as part of each entry in the "machines" data structure. This centralized data structure is what lets, for instance, "vagrant global-status" work and is also the reason you get a warning if you move (change the name of) a folder containing a deployed Vagrantfile.


cmucluser

unread,
Apr 24, 2019, 3:17:10 PM4/24/19
to Vagrant
> Given the name of a box ... under ~/.vagrant.d/boxes you will find a

> file named and containing the metadata_url and one or more
> version-number directories.

Yes, I had seen this.


> These version-number directories contain the unpacked boxes. The
> highest-numbered version is considered the "latest installed
> version". To discover if a more recent version exists, vagrant
> fetches the info via the metadata_url.

And this doesn't work well, with the latest Vagrant version, 2.2.4.

Let me be specific now:

----
    vagrant box list | grep generic/oracle7
    =>
    generic/oracle7 (virtualbox, 1.9.8)
    generic/oracle7 (virtualbox, 1.9.10)

----
    ls -l ~/.vagrant.d/boxes/generic-VAGRANTSLASH-oracle7/
    =>
    ... 102 Apr 19 17:37 1.9.10/
    ... 102 Apr 16 13:59 1.9.8/
    ...  40 Apr 19 17:37 metadata_url

Notice the lexicographic ordering of the box versions; this may be
important for the following, which is "the problem stuff":


----

    vagrant box update --box generic/oracle7
    Checking for updates to 'generic/oracle7
    Latest installed version: 1.9.8

See how 1.9.8 was found to be the latest one, rather than the truly
latest, 1.9.10?  Since there is apparently no place where the "latest
installed version" is recorded, I conclude that the determination is
based on the lexicographic ordering of the installed versions.

And then, of course, 1.9.8 is a "higher" version than 1.9.10; and we
see this (continuing the output of the above 'update' command):

    Version constraints: > 1.9.8
    Provider: virtualbox
    Updating 'generic/oracle7' with provider 'virtualbox' from version
    '1.9.8' to '1.9.10'...
    Loading metadata for box 'https://vagrantcloud.com/generic/oracle7
    Adding box 'generic/oracle7' (v1.9.10) 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: generic/oracle7
    Provider: virtualbox
    Version: 1.9.10

I have been working around this in my setup framework all right but
this is an annoyance and wrong behavior.

Is there anybody around to fix it?

Thank you for responding!

-- Alex

cmucluser

unread,
Apr 24, 2019, 3:36:59 PM4/24/19
to Vagrant
I've just discovered, from the IRC #vagrant channel, that the Vagrant
code is available on Github.com (I assumed it was "closed source").

Then, of course, I can see the confirmation of my to my statement on
the lexicographical version ordering bug:

# vagrant/plugins/commands/box/command/update.rb:

          to_update = [
            [name, provider, boxes[name][provider].sort.last],
          ]

Sorting by the 'name' is not taking into account the numeric nature of
the version elements.  A bug.

-- Alex
Message has been deleted

Jim McGinness

unread,
Apr 24, 2019, 4:34:01 PM4/24/19
to Vagrant
Agreed, it looks like an incorrect sort method is being used.

Jim McGinness

unread,
Apr 24, 2019, 4:50:03 PM4/24/19
to Vagrant
Elsewhere in the code, they're careful to use Gem::Version to avoid this problem.

Brian Cain

unread,
Apr 24, 2019, 5:26:12 PM4/24/19
to vagra...@googlegroups.com
Hey there!

Just to confirm, this bug seems to only exist when you specify a box to update with the --box flag. If you run with the update command on a guest using that box, it works just fine:

Screenshot from 2019-04-24 14-23-14.png

I recommend opening a GitHub issue with the proper issue template information filled out and I'll be happy to fix it! Or feel free to open a pull request. Thanks!

On Wed, Apr 24, 2019 at 1:50 PM Jim McGinness <jmc...@gmail.com> wrote:
Elsewhere in the code, they're careful to use Gem::Version to avoid this problem.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/5b48aa1e-5d2b-4a4b-9290-894d6a545de2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Brian Cain

cmucluser

unread,
Apr 24, 2019, 5:40:53 PM4/24/19
to Vagrant
A question, not quite related to this bug: where is the translation
between the module "descriptors" happening?

I.e. I can use 'box update --box generic/oracle7' and you just used
'box update oracle', and somehow 'vagrant' was able to translate the
short 'oracle' used in your command to the long 'generic/oracle7' used
in mine.  What dictionary was used for that translation?

Thanks!

-- Alex

On Tuesday, April 23, 2019 at 7:32:49 PM UTC-4, cmucluser wrote:

Brian Cain

unread,
Apr 24, 2019, 5:46:57 PM4/24/19
to vagra...@googlegroups.com
Hey there,

There's no magic or anything special here. I just defined a guest named "oracle" in my Vagrantfile with the box "generic/oracle7":

 config.vm.define "oracle" do |b|
    b.vm.box = "generic/oracle7"
    b.vm.provider :virtualbox
  end

The difference being: Without the --box flag, the update command updates boxes associated with guests in your Vagrantfile.

So in this case I defined a guest named "oracle" which used the "generic/oracle7" box. That flag is useful for when you
want to update a box but maybe don't have a guest associated with it.

Hope that clears things up!

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
Brian Cain

cmucluser

unread,
Apr 24, 2019, 5:50:01 PM4/24/19
to Vagrant
Thanks; I want a mechanism not using an existing Vagrant environment (an existing Vagrantfile).

On Tuesday, April 23, 2019 at 7:32:49 PM UTC-4, cmucluser wrote:

cmucluser

unread,
Apr 24, 2019, 7:11:33 PM4/24/19
to Vagrant
I just submitted a pull request with a fix: https://github.com/hashicorp/vagrant/pull/10810.

Since I am doing such a thing with Github.com for the first time ever, I am not absolutely sure I did everything correctly for the fix to be considered and merged in.

-- Alex

On Tuesday, April 23, 2019 at 7:32:49 PM UTC-4, cmucluser wrote:

Brian Cain

unread,
Apr 24, 2019, 7:24:11 PM4/24/19
to vagra...@googlegroups.com
Thanks Alex! I'll respond on there. We greatly appreciate the pull request for the fix!

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
Brian Cain
Reply all
Reply to author
Forward
0 new messages