hashicorp/vagrant · error · Vagrant::Errors::UploadInvalidCompressionType

The compression type requested for upload (`%{type}`) is not

Error message

The compression type requested for upload (`%{type}`) is not a
supported value. Try uploading again using a valid compression
type.

  Supported types: %{valid_types}

What it means

`vagrant upload --compression-type=TYPE` (or -C) only accepts values in VALID_COMPRESS_TYPES, hard-coded to `[:tgz, :zip]` in the upload command. compression_setup! raises UploadInvalidCompressionType when the requested value is not in that list. When no type is given one is auto-selected (zip when the guest chain is Windows, tgz otherwise), so the error only fires on an explicit invalid value.

Source

Thrown at plugins/commands/upload/command.rb:144

        # Success, exit status 0
        0
      end

      # Setup compression options and validate host and guest have capability
      # to handle compression
      #
      # @param [Vagrant::Machine] machine Vagrant guest machine
      # @param [Hash] options Command options
      def compression_setup!(machine, options)
        if !options[:compression_type]
          if machine.guest.capability_host_chain.first[0] == :windows
            options[:compression_type] = :zip
          else
            options[:compression_type] = :tgz
          end
        end
        if !VALID_COMPRESS_TYPES.include?(options[:compression_type])
          raise Vagrant::Errors::UploadInvalidCompressionType,
            type: options[:compression_type],
            valid_types: VALID_COMPRESS_TYPES.join(", ")
        end
        options[:decompression_method] = "decompress_#{options[:compression_type]}".to_sym
        if !machine.guest.capability?(options[:decompression_method])
          raise Vagrant::Errors::UploadMissingExtractCapability,
            type: options[:compression_type]
        end
      end

      # Compress path using zip into temporary file
      #
      # @param [String] path Path to compress
      # @return [String] path to compressed file
      def compress_source_zip(path)
        require "zip"
        zipfile = Tempfile.create(["vagrant", ".zip"])
        zipfile.close

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. Use exactly `tgz` or `zip`: `vagrant upload -C tgz <src> <dst>`
  2. Drop `-C/--compression-type` entirely and let the command auto-select (zip for Windows guests, tgz otherwise)
  3. Check `vagrant upload -h`; the valid values are listed in the option help

Example fix

# before
vagrant upload -C gzip app_dir /tmp/app_dir

# after
vagrant upload -C tgz app_dir /tmp/app_dir   # or omit -C
Defensive patterns

Strategy: validation

Validate before calling

VALID = %w[tgz zip]
abort "invalid compression type #{t}; use #{VALID.join(' or ')}" unless VALID.include?(t.to_s.downcase)
system('vagrant', 'upload', '-C', t, src, dst)

Type guard

valid_compression_type = ->(t) { %i[tgz zip].include?(t.to_s.downcase.to_sym) }

Try / catch

begin
  command.execute
rescue Vagrant::Errors::UploadInvalidCompressionType => e
  warn "#{e.extra_data[:type]} invalid; valid: #{e.extra_data[:valid_types]}"
  exit 1
end

Prevention

When it happens

Trigger: Passing `-C gzip`, `--compression-type=tar.gz`, or any string other than exactly `tgz` or `zip`; programmatically setting options[:compression_type] to an unsupported symbol; case differences such as `TGZ` because the comparison is exact.

Common situations: Users assuming gzip/tar/bz2 are supported because the `-c/--compress` help mentions gzip; scripts ported from another upload tool's flags; uppercase type names.

Related errors


AI-assisted analysis of hashicorp/vagrant@35f3160f4a (2026-08-21). Data as JSON: /api/errors/a37c589fe9381ec3. Report an issue: GitHub.