← 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 --output` has path-dependent semantics and can report success while artifacts remain outside the host project; outside-tree artifacts are now rejected, but filename and multi-artifact behavior remains undocumented.

Suggested action: keep open

Reason: The report provides four reproducible commands and logs showing artifacts from `/tmp` remaining inside the build instance. Commit `5a0fca83` (PR #767) now raises `ArtifactCreationError` for artifacts outside the project tree, addressing silent loss; however, `--output` still only says "output directory" and does not clarify filename or single-versus-multiple-artifact semantics.

Evaluated by: mr-cal-bot

Impact: 52 Quick Win: 25 Complexity: 48 Confidence: 92 Actionability: 91

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
stealth/space-bunny-alpha
Impact: 52
Quick Win: 25
Complexity: 48
Confidence: 92
Actionability: 91
keep open `pack --output` has path-dependent semantics and can report success while artifacts remain outside the host project; outside-tree artifacts are now rejected, but filename and multi-artifact behavior remains undocumented.
qwen/qwen3.6-35b-a3b
Impact: 40
Quick Win: 22
Complexity: 30
Confidence: 75
Actionability: 80
keep open Pack command --output option has inconsistent behavior: works for project-relative paths but silently fails for paths outside the project root, with artifacts created inside the build instance.
qwen/qwen3.8-27b
Impact: 45
Quick Win: 18
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.

Update history

No update history recorded yet.

Related work

  • Likely Fixed By: canonical/craft-application#767 (confidence 96%)

    Commit `5a0fca83` adds package-path normalization and rejects paths outside the project tree, addressing the silent-disappearance case.

Related issues

No related issues found above the similarity threshold.