Skip to content

--quiet flag doesn't suppress 'App Host:' prefix in app exec output #1673

@sevos

Description

@sevos

Problem

When using kamal app exec with the --quiet flag to redirect binary output (like tar archives), the command still outputs an "App Host:" prefix line that corrupts the binary stream.

Example Use Case

Attempting to backup application storage by creating a tar archive and streaming it locally:

bundle exec kamal app exec --quiet --reuse -- "tar czf - /rails/storage/" > backup.tar.gz

Expected Result: A valid gzip-compressed tar archive
Actual Result: Corrupted file that starts with ASCII text "App Host: hostname\n" followed by the gzip data

Root Cause

In lib/kamal/sshkit_with_ext.rb:21-23:

def puts_by_host(host, output, type: "App")
  puts "#{type} Host: #{host}\n#{output}\n\n"
end

This method always outputs the prefix regardless of the verbosity setting. While --quiet sets commander.verbosity = :error, puts_by_host doesn't check this setting before outputting.

The method is called from lib/kamal/cli/app.rb:151 and lib/kamal/cli/app.rb:167:

puts_by_host host, capture_with_info(*KAMAL.app(role: role, host: host).execute_in_existing_container(cmd, env: env))

Environment

  • Kamal version: 2.x
  • Ruby version: 3.4.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions