← 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
2025-05-23 12:42:46+00:00
Updated
2025-06-07 00:12:31+00:00
Closed

Current evaluation

No evaluation has been recorded for this issue yet.

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

No evaluation history available.