diff --git a/CHANGELOG.md b/CHANGELOG.md index bc2bfa56f..201a7ffc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ BUG FIXES: - core: Fix a rare issue where vagrant up would complain it couldn't check version of a box that doesn't exist. [GH-3326] - commands/box: Show versions when listing. [GH-3316] + - commands/box: Outdated check can list local boxes that are newer. [GH-3321] - commands/status: Machine readable output contains the target. [GH-3218] - guests/arch: Reload udev rules after network change. [GH-3322] - guests/debian: Changing host name works properly. [GH-3283] diff --git a/lib/vagrant/action/builtin/box_check_outdated.rb b/lib/vagrant/action/builtin/box_check_outdated.rb index fcd88c384..a134f294b 100644 --- a/lib/vagrant/action/builtin/box_check_outdated.rb +++ b/lib/vagrant/action/builtin/box_check_outdated.rb @@ -54,6 +54,8 @@ module Vagrant name: update[0].name, current: box.version, latest: update[1].version)) + else + check_outdated_local(env) end @app.call(env) @@ -61,9 +63,15 @@ module Vagrant def check_outdated_local(env) machine = env[:machine] + + # Make sure we respect the constraints set within the Vagrantfile + version = machine.config.vm.box_version + version += ", " if version + version ||= "" + version += "> #{machine.box.version}" + box = env[:box_collection].find( - machine.box.name, machine.box.provider, - "> #{machine.box.version}") + machine.box.name, machine.box.provider, version) if box env[:ui].warn(I18n.t( "vagrant.box_outdated_local", diff --git a/test/unit/vagrant/action/builtin/box_check_outdated_test.rb b/test/unit/vagrant/action/builtin/box_check_outdated_test.rb index 9e1a2051e..0112d2656 100644 --- a/test/unit/vagrant/action/builtin/box_check_outdated_test.rb +++ b/test/unit/vagrant/action/builtin/box_check_outdated_test.rb @@ -127,6 +127,32 @@ describe Vagrant::Action::Builtin::BoxCheckOutdated do expect(env[:box_outdated]).to be_true end + it "has an update if it is local" do + iso_env.box3("foo", "1.1", :virtualbox) + + expect(box).to receive(:has_update?).and_return(nil) + + expect(app).to receive(:call).with(env).once + + subject.call(env) + + expect(env[:box_outdated]).to be_true + end + + it "does not have a local update if not within constraints" do + iso_env.box3("foo", "1.1", :virtualbox) + + machine.config.vm.box_version = "> 1.0, < 1.1" + + expect(box).to receive(:has_update?).and_return(nil) + + expect(app).to receive(:call).with(env).once + + subject.call(env) + + expect(env[:box_outdated]).to be_false + end + it "raises error if has_update? errors" do expect(box).to receive(:has_update?).and_raise(Vagrant::Errors::VagrantError)