18

The problem is about the capability 'change_host_name' isn't supported by the guest when I try to execute the following command line:

vagrant up

It gives me an error as the following:

Vagrant attempted to execute the capability 'change_host_name'
on the detect guest OS 'linux', but the guest doesn't
support that capability. This capability is required for your
configuration of Vagrant. Please either reconfigure Vagrant to
avoid this capability or fix the issue by creating the capability.

Note that my OS is: OS X Yosemite 10.10.5

Guest Additions Version: 4.2.0 and VirtualBox Version: 5.0

I've tried many solutions of others who face this issue, but I couldn't fix it.

dsds
  • 183
  • 1
  • 7

1 Answers1

26

This is https://github.com/mitchellh/vagrant/issues/7625. It will be fixed in the next release, until then if its blocking you, you can patch vagrant yourself

If you want to patch yourself

Method1 :

  • search for the plugins/guests/ubuntu/guest.rb file in your vagrant installation
    • e.g. /opt/vagrant/embedded/gems/gems/vagrant-1.8.5/plugins/guests/ubuntu/guest.rb on mac/linux default install
    • or /opt/vagrant/embedded/gems/vagrant-1.8.5/plugins/guests/ubuntu/guest.rb
    • windows : C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.8.5\plugin‌​s\guests\ubuntu\gues‌​t.rb
  • replace with https://raw.githubusercontent.com/carlosefr/vagrant/1c631c18d1a654405f6954459a42ac19a1a2f096/plugins/guests/ubuntu/guest.rb (make sure to be with correct rights if you install as admin, you must be admin user to save the file)
  • alternatively edit the file and replace all contents by

    module VagrantPlugins
      module GuestUbuntu
        class Guest < Vagrant.plugin("2", :guest)
          def detect?(machine)
            # This command detects if we are running on Ubuntu. /etc/os-release is
            # available on modern Ubuntu versions, but does not exist on 14.04 and
            # previous versions, so we fall back to lsb_release.
            #
            #   GH-7524
            #   GH-7625
            #
            machine.communicate.test <<-EOH.gsub(/^ {10}/, "")
              if test -r /etc/os-release; then
                source /etc/os-release && test xubuntu = x$ID
              elif test -x /usr/bin/lsb_release; then
                /usr/bin/lsb_release -i 2>/dev/null | grep -q Ubuntu
              else
                exit 1
              fi
            EOH
          end
        end
      end
    end
    

Method2 : An Alternative method to patch the file using patch command :

save the following file under vagrant-guest.patch

commit 00fa49191dba2bb7c6322fa8df9327ca505c0b41
Author: Seth Vargo <sethvargo@gmail.com>
Date:   Sat Jul 23 11:40:36 2016 -0400

    guests/ubuntu: Revert detection

    - Semi-reverts GH-7524
    - Fixes GH-7625

diff --git a/plugins/guests/ubuntu/guest.rb b/plugins/guests/ubuntu/guest.rb
index 9aeb7aa..f60108e 100644
--- a/plugins/guests/ubuntu/guest.rb
+++ b/plugins/guests/ubuntu/guest.rb
@@ -2,7 +2,22 @@ module VagrantPlugins
   module GuestUbuntu
     class Guest < Vagrant.plugin("2", :guest)
       def detect?(machine)
-        machine.communicate.test("test -r /etc/os-release && . /etc/os-release && test xubuntu = x$ID")
+        # This command detects if we are running on Ubuntu. /etc/os-release is
+        # available on modern Ubuntu versions, but does not exist on 14.04 and
+        # previous versions, so we fall back to lsb_release.
+        #
+        #   GH-7524
+        #   GH-7625
+        #
+        machine.communicate.test <<-EOH.gsub(/^ {10}/, "")
+          if test -r /etc/os-release; then
+            source /etc/os-release && test xubuntu = x$ID
+          elif test -x /usr/bin/lsb_release; then
+            /usr/bin/lsb_release -i 2>/dev/null | grep -q Ubuntu
+          else
+            exit 1
+          fi
+        EOH
       end
     end
   end

and run the following command to apply the patch

sudo patch -p1 --directory /opt/vagrant/embedded/gems/gems/vagrant-1.8.5/ < vagrant-guest.patch

Just replace /opt/vagrant/embedded/gems/gems/vagrant-1.8.5 (or /opt/vagrant/embedded/gems/vagrant-1.8.5/plugins/guests/ubuntu/guest.rb) with your vagrant folder installation

Frederic Henri
  • 51,761
  • 10
  • 113
  • 139
  • Nice one - fixed it for me to, big kudos due – Anthony Main Aug 25 '16 at 10:48
  • On a default windows install, C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.8.5\plugins\guests\ubuntu\guest.rb Took me a while to find that file... – Jonathan Scher Sep 10 '16 at 22:47
  • Is there a way to make this work for Windows host and linux guest? –  Sep 20 '16 at 21:31
  • @user1177476 I think so, some users reported it was working from windows - the file path should be C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.8.5\plugin‌​s\guests\ubuntu\gues‌​t.rb; if you don't find it there, make a global search on your disk - edit the file and replace the content with what I added in the message, it should work – Frederic Henri Sep 21 '16 at 06:13
  • Ubuntu 16.10 keeps the file at /usr/share/vagrant/plugins/guests/ubuntu/guest.rb – Sarah Messer Dec 19 '16 at 14:50
  • As of the latest vagrant (1.9.1), the same sort of error occurs. The patch here no longer applies though. – mc0e Feb 03 '17 at 21:10
  • @mc0e strange, not able to replicate on 1.9.1, weird though as it seems the fix has been applied in code – Frederic Henri Feb 05 '17 at 13:11
  • I was trying to run a 3rd party vagrant box recipe that references the box bento/centos-6.7. The box hasn't been updated in a while, and the vagrant provisioning doesn't include a `yum update` . Doing that update allowed me to move forward to the next bit-rot issue with the box. – mc0e Feb 05 '17 at 15:26
  • You are a lifesaver :) – Nash Nov 07 '17 at 08:22