hashicorp/vagrant · warning

Vagrant is automatically disabling direct upload to backend

Error message

Vagrant is automatically disabling direct upload to backend storage.
Uploads directly to backend storage are currently only supported for
files 5G in size or smaller. Box file to upload is: %{size}

What it means

Warning from `vagrant cloud provider upload` (plugins/commands/cloud/provider/upload.rb) when --direct is requested but File.stat(file).size exceeds 5 GiB (5 * Vagrant::Util::Numeric::GIGABYTE). Vagrant prints the human-readable size (bytes_to_string) and automatically downgrades options[:direct] = false, so the upload is routed through the standard (server-mediated) upload path instead of direct-to-backend storage.

Source

Thrown at plugins/commands/cloud/provider/upload.rb:71

          # @param [String] provider Provider name
          # @param [String] architecture Architecture name
          # @param [String] file Path to asset
          # @param [String] access_token User Vagrant Cloud access token
          # @param [Hash] options
          # @option options [Boolean] :direct Upload directly to backend storage
          # @return [Integer]
          def upload_provider(org, box, version, provider, architecture, file, access_token, options)
            account = VagrantCloud::Account.new(
              custom_server: api_server_url,
              access_token: access_token
            )

            # Include size check on file and disable direct if over 5G
            if options[:direct]
              fsize = File.stat(file).size
              if fsize > (5 * Vagrant::Util::Numeric::GIGABYTE)
                box_size = Vagrant::Util::Numeric.bytes_to_string(fsize)
                @env.ui.warn(I18n.t("cloud_command.provider.direct_disable", size: box_size))
                options[:direct] = false
              end
            end

            with_provider(account: account, org: org, box: box, version: version, provider: provider, architecture: architecture) do |p|
              p.upload(direct: options[:direct]) do |upload_url|
                m = options[:direct] ? :put : :put
                uploader = Vagrant::Util::Uploader.new(upload_url, file, ui: @env.ui, method: m)
                ui = Vagrant::UI::Prefixed.new(@env.ui, "cloud")
                ui.output(I18n.t("cloud_command.provider.upload",
                  org: org, box_name: box, version: version, provider: provider))
                ui.info("Upload File: #{file}")
                uploader.upload!
                ui.success(I18n.t("cloud_command.provider.upload_success",
                  org: org, box_name: box, version: version, provider: provider))
              end
              0
            end

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. Accept the automatic fallback — the upload still completes, just via the relay path (slower).
  2. To genuinely use direct upload, shrink the artifact below 5G: repackage the box, compress, or split the disk.
  3. Remove --direct from scripts if your boxes are routinely >5G so logs stay clean and behavior is deterministic.
  4. Check the file size first (`stat -c %s file.box`) when you need predictable upload timing.

Example fix

# before
vagrant cloud provider upload myorg/app 1.0.0 virtualbox --architecture amd64 \
  --file ./app.box --direct   # >5G -> warning, falls back to relayed upload

# after (verify size, only use direct when supported)
SIZE=$(stat -c %s ./app.box)
DIRECT=$([ "$SIZE" -le 5368709120 ] && echo --direct || echo "")
vagrant cloud provider upload myorg/app 1.0.0 virtualbox --architecture amd64 \
  --file ./app.box $DIRECT
Defensive patterns

Strategy: validation

Validate before calling

MAX=5368709120  # 5 GiB
size=$(stat -c %s "$BOX_FILE" 2>/dev/null || stat -f %z "$BOX_FILE")
DIRECT_FLAG=""
[ "$size" -le "$MAX" ] && DIRECT_FLAG=--direct
vagrant cloud provider upload ... --file "$BOX_FILE" $DIRECT_FLAG

Prevention

When it happens

Trigger: Running `vagrant cloud provider upload ... --direct --file big.box` where big.box is larger than 5 GiB; the size probe runs before with_provider opens the upload session, and the chosen upload_url/mthod reflects the non-direct path.

Common situations: Large virtualbox/VMware boxes with bundled disk images exceeding 5G; CI publishing pipelines that always pass --direct for speed and silently lose that optimization on big artifacts; disk-full or sparse-file surprises where the apparent size crosses the threshold.

Related errors


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