diff --git a/CHANGELOG.md b/CHANGELOG.md index 094fda9a2..0c1bc07b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ BUG FIXES: fail [GH-3391] - core: `vagrant` on Windows cmd.exe doesn't always exit with exit code zero. [GH-3420] + - commands/package: Nice error if includes contain symlinks. [GH-3200] - commands/rsync-auto: Don't crash if the machine can't be communicated to. [GH-3419] - guests/fedora: Fix hostname setting. [GH-3382] diff --git a/lib/vagrant/action/general/package.rb b/lib/vagrant/action/general/package.rb index 10c456dd9..1986dc598 100644 --- a/lib/vagrant/action/general/package.rb +++ b/lib/vagrant/action/general/package.rb @@ -72,6 +72,11 @@ module Vagrant FileUtils.cp(from, to, :preserve => true) end end + rescue Errno::EEXIST => e + raise if !e.to_s.include?("symlink") + + # The directory contains symlinks. Show a nicer error. + raise Errors::PackageIncludeSymlink end # Compress the exported file into a package diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index a0ce3bb13..be378dd57 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -456,6 +456,10 @@ module Vagrant error_key(:include_file_missing, "vagrant.actions.general.package") end + class PackageIncludeSymlink < VagrantError + error_key(:package_include_symlink) + end + class PackageOutputDirectory < VagrantError error_key(:output_is_directory, "vagrant.actions.general.package") end diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 3c247c573..ba69c6b20 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -789,6 +789,10 @@ en: You can however, install a plugin with the same name to replace these plugins. User-installed plugins take priority over system-installed plugins. + package_include_symlink: |- + A file or directory you're attempting to include with your packaged + box has symlinks in it. Vagrant cannot include symlinks in the + resulting package. Please remove the symlinks and try again. provider_not_found: |- The provider '%{provider}' could not be found, but was requested to back the machine '%{machine}'. Please use a provider that exists.