← Back to issue list

Pack command output option is inconsistent

View original Github issue

Metadata

Project
craft-application
Number
#770
Type
issue
State
open
Author
cmatsuoka
Labels
Status: Triaged Type: Bug
Created
Updated
Closed

Current evaluation

Pack command --output behaves inconsistently: paths outside the project root silently drop artifacts inside the build instance. Triaged bug (Jira CRAFT-4580); no fix found in current code, which still has the same --output handling.

Suggested action: keep open

Reason: The issue is labelled 'Status: Triaged' and 'Type: Bug' by maintainer cmatsuoka, and the reported behavior still exists in the code: PackCommand in craft_application/commands/lifecycle.py still defines --output with help 'Output directory for created packages.' and passes it to package.set_output_dir() with no validation or error for out-of-root paths. No commit in the history addresses this, so it remains a valid, open design/bug decision (error out vs. deprecate) rather than something to close.

Impact: 45 Quick Win: 18.0 Staleness: 75 Complexity: 60 Confidence: 80 Support Request: 5

Issue body

### Bug Description The `pack` command offers the `--output` option as the "output directory for created packages." However it actually work in different ways: - If output is specified as a subdirectory of the project root, it creates artifacts inside the directory (as described in the help message) - If output is specified as a filename under the project root, it creates the artifact with the specified name. - If output is specified as a directory or filename outside the project root, the artifact is created inside the build instance and it never appears in the host system. The application should probably stop with an error instead of failing silently in cases where the artifact disappears, and clarify the `--output` behavior when multiple output artifacts are generated (if a directory is created then it should do the same when a single output artifact is generated). We can also consider deprecating this option in future releases. ### To Reproduce ```shell $ mkdir /tmp/foo $ cd /tmp/foo $ snapcraft init Go to https://docs.snapcraft.io/the-snapcraft-format/8337 for more information about the snapcraft.yaml format. Successfully initialised project. $ snapcraft pack --output=foo Packed foo $ mkdir bar $ snapcraft pack --output=bar Packed foo_0.1_amd64.snap $ snapcraft pack --output=/tmp Packed foo_0.1_amd64.snap $ ls -l /tmp/foo_0.1_amd64.snap ls: cannot access '/tmp/foo_0.1_amd64.snap': No such file or directory $ snapcraft pack --output=/dirname/ Packed dirname $ ls -l /dirname ls: cannot access '/dirname': No such file or directory ``` ### part yaml ```shell ``` ### Relevant log output ```shell :: 2025-05-23 09:41:29.948 Packing... :: 2025-05-23 09:41:29.948 Reading snap metadata... :: 2025-05-23 09:41:29.949 Running linters... :: 2025-05-23 09:41:29.949 Running linter: classic :: 2025-05-23 09:41:29.949 Running linter: library :: 2025-05-23 09:41:29.951 pack_snap: output='/tmp', compression='xz' :: 2025-05-23 09:41:29.951 pack_snap: check skeleton :: 2025-05-23 09:41:29.966 Creating snap package... :: 2025-05-23 09:41:29.966 Pack command: ['snap', 'pack', '--filename', 'foo_0.1_amd64.snap', '--compression', 'xz', PosixPath('/root/prime'), PosixPath('/tmp')] :: 2025-05-23 09:41:30.026 Packed foo_0.1_amd64.snap ```

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.8-27b
Impact: 45
Quick Win: 18.0
Staleness: 75
Complexity: 60
Confidence: 80
Support Request: 5
keep open Pack command --output behaves inconsistently: paths outside the project root silently drop artifacts inside the build instance. Triaged bug (Jira CRAFT-4580); no fix found in current code, which still has the same --output handling.
qwen/qwen3.6-35b-a3b
Staleness: 90
Complexity: 40
Confidence: 85
Support Request: 10
keep open Inconsistent snapcraft pack --output behavior causes silent failures when paths fall outside the project root. Triaged bug with over a year of inactivity and no follow-up.
qwen3.6-35b-a3b-mtp-q6
Staleness: 90
Complexity: 40
Confidence: 75
Support Request: 5
keep open Inconsistent behavior of snapcraft pack --output when paths are outside the project root, causing silent failures. Triaged bug with an internal ticket, but inactive for over a year.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 35
Confidence: 80
Support Request: 10
keep open Inconsistent snapcraft pack --output behavior fails silently when paths fall outside the project root. Triaged as a bug with an internal Jira ticket created, awaiting implementation.

Update history

No update history recorded yet.

Related issues

No related issues found above the similarity threshold.