pkg: error: --add-architecture takes exactly one argument
Metadata
Current evaluation
Closed as a duplicate of #4289. The failure stemmed from incorrect dpkg argument ordering, requiring --add-architecture before --root. Resolved by correcting the command sequence in the installer.
Suggested action: —
No scores available.
Issue body
### Bug Description
Snapcraft fails to add a dpkg architecture to the system when a custom package repository is added and prints the following error:
```
pkg: error: --add-architecture takes exactly one argument
Type dpkg --help for help about installing and deinstalling packages [*];
Use 'apt' or 'aptitude' for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;
```
### To Reproduce
Build the attached snapcraft.yaml using Snapcraft 7.5.0:
```
$ sudo snapcraft -v --destructive-mode
Starting Snapcraft 7.5.0
Logging execution to '/root/.local/state/snapcraft/log/snapcraft-20230731-095242.281432.log'
Running on amd64 for amd64
Initializing parts lifecycle
Installing package repositories... d
pkg: error: --add-architecture takes exactly one argument
Type dpkg --help for help about installing and deinstalling packages [*];
Use 'apt' or 'aptitude' for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;
Options marked [*] produce a lot of output - pipe it through 'less' or 'more' !
Command '['dpkg', '--add-architecture', 'arm64', '--root', '/']' returned non-zero exit status 2.
Full execution log: '/root/.local/state/snapcraft/log/snapcraft-20230731-095242.281432.log'
```
### Environment
Running in a newly created LXD container.
```
$ snapcraft --version
snapcraft 7.5.0
$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.2 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
```
### snapcraft.yaml
```shell
name: my-snap-name # you probably want to 'snapcraft register <name>'
base: core22 # the base snap is the execution environment for this snap
version: '0.1' # just for humans, typically '1.2+git' or '1.3.2'
summary: Single-line elevator pitch for your amazing snap # 79 char long summary
description: |
This is my-snap's description. You have a paragraph or two to tell the
most important story about your snap. Keep it under 100 words though,
we live in tweetspace and your description wants to look good in the snap
store.
grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots
package-repositories:
- type: apt
architectures: [ arm64 ]
components: [ main ]
suites: [ jammy, jammy-security, jammy-updates ]
key-id: F6ECB3762474EDA9D21B7022871920D1991BC93C
url: http://ports.ubuntu.com/ubuntu-ports
parts:
my-part:
# See 'snapcraft plugins'
plugin: nil
```
### Relevant log output
```shell
2023-07-31 09:52:42.282 Starting Snapcraft 7.5.0
2023-07-31 09:52:42.283 lifecycle command: 'pack', arguments: Namespace(bind_ssh=False, build_for=None, debug=False, destructive_mode=True, directory=None, enable_developer_debug=False, enable_experimental_extensions=False, enable_experimental_plugins=False, enable_experimental_target_arch=False, enable_experimental_ua_services=False, enable_manifest=False, http_proxy=None, https_proxy=None, manifest_image_information=None, output=None, provider=None, target_arch=None, ua_token=None, use_lxd=False)
2023-07-31 09:52:42.283 command: pack, arguments: Namespace(bind_ssh=False, build_for=None, debug=False, destructive_mode=True, directory=None, enable_developer_debug=False, enable_experimental_extensions=False, enable_experimental_plugins=False, enable_experimental_target_arch=False, enable_experimental_ua_services=False, enable_manifest=False, http_proxy=None, https_proxy=None, manifest_image_information=None, output=None, provider=None, target_arch=None, ua_token=None, use_lxd=False)
2023-07-31 09:52:42.293 CPU count (from process affinity): 8
2023-07-31 09:52:42.293 Invalid SNAPCRAFT_MAX_PARALLEL_BUILD_COUNT ''
2023-07-31 09:52:42.293 Running on amd64 for amd64
2023-07-31 09:52:42.297 Initializing parts lifecycle
2023-07-31 09:52:42.298 is_snap: True, SNAP_NAME set to snapcraft
2023-07-31 09:52:42.298 load state file: /home/ubuntu/test/parts/my-part/state/pull
2023-07-31 09:52:42.303 load state file: /home/ubuntu/test/parts/my-part/state/build
2023-07-31 09:52:42.332 load state file: /home/ubuntu/test/parts/my-part/state/stage
2023-07-31 09:52:42.335 load state file: /home/ubuntu/test/parts/my-part/state/prime
2023-07-31 09:52:42.338 process my-part:Step.PULL
2023-07-31 09:52:42.338 check if Part('my-part'):Step.PULL is dirty
2023-07-31 09:52:42.338 check if Part('my-part'):Step.PULL is outdated
2023-07-31 09:52:42.338 add action my-part:Step.PULL(ActionType.SKIP)
2023-07-31 09:52:42.338 process my-part:Step.BUILD
2023-07-31 09:52:42.338 check if Part('my-part'):Step.BUILD is dirty
2023-07-31 09:52:42.339 check if Part('my-part'):Step.BUILD is outdated
2023-07-31 09:52:42.339 add action my-part:Step.BUILD(ActionType.SKIP)
2023-07-31 09:52:42.339 process my-part:Step.STAGE
2023-07-31 09:52:42.339 check if Part('my-part'):Step.STAGE is dirty
2023-07-31 09:52:42.339 check if Part('my-part'):Step.STAGE is outdated
2023-07-31 09:52:42.339 add action my-part:Step.STAGE(ActionType.SKIP)
2023-07-31 09:52:42.339 process my-part:Step.PRIME
2023-07-31 09:52:42.339 check if Part('my-part'):Step.PRIME is dirty
2023-07-31 09:52:42.339 check if Part('my-part'):Step.PRIME is outdated
2023-07-31 09:52:42.339 add action my-part:Step.PRIME(ActionType.SKIP)
2023-07-31 09:52:43.503 Installing package repositories...
2023-07-31 09:52:43.516 Command '['dpkg', '--add-architecture', 'arm64', '--root', '/']' returned non-zero exit status 2.
2023-07-31 09:52:43.518 Traceback (most recent call last):
2023-07-31 09:52:43.518 File "/snap/snapcraft/9510/lib/python3.8/site-packages/snapcraft/parts/parts.py", line 168, in run
2023-07-31 09:52:43.518 self._install_package_repositories()
2023-07-31 09:52:43.518 File "/snap/snapcraft/9510/lib/python3.8/site-packages/snapcraft/parts/parts.py", line 204, in _install_package_repositories
2023-07-31 09:52:43.518 refresh_required = repo.install(
2023-07-31 09:52:43.518 File "/snap/snapcraft/9510/lib/python3.8/site-packages/craft_archives/repo/installer.py", line 44, in install
2023-07-31 09:52:43.518 return _install_repos(
2023-07-31 09:52:43.518 File "/snap/snapcraft/9510/lib/python3.8/site-packages/craft_archives/repo/installer.py", line 94, in _install_repos
2023-07-31 09:52:43.518 refresh_required |= sources_manager.install_package_repository_sources(
2023-07-31 09:52:43.518 File "/snap/snapcraft/9510/lib/python3.8/site-packages/craft_archives/repo/apt_sources_manager.py", line 294, in install_package_repository_sources
2023-07-31 09:52:43.518 _add_architecture(architectures, root=self._signed_by_root)
2023-07-31 09:52:43.518 File "/snap/snapcraft/9510/lib/python3.8/site-packages/craft_archives/repo/apt_sources_manager.py", line 304, in _add_architecture
2023-07-31 09:52:43.518 subprocess.run(
2023-07-31 09:52:43.518 File "/snap/snapcraft/9510/usr/lib/python3.8/subprocess.py", line 516, in run
2023-07-31 09:52:43.518 raise CalledProcessError(retcode, process.args,
2023-07-31 09:52:43.518 subprocess.CalledProcessError: Command '['dpkg', '--add-architecture', 'arm64', '--root', '/']' returned non-zero exit status 2.
2023-07-31 09:52:43.518
2023-07-31 09:52:43.518 The above exception was the direct cause of the following exception:
2023-07-31 09:52:43.518 Traceback (most recent call last):
2023-07-31 09:52:43.518 File "/snap/snapcraft/9510/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 302, in _run_command
2023-07-31 09:52:43.518 _run_lifecycle_and_pack(
2023-07-31 09:52:43.518 File "/snap/snapcraft/9510/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 345, in _run_lifecycle_and_pack
2023-07-31 09:52:43.518 lifecycle.run(
2023-07-31 09:52:43.518 File "/snap/snapcraft/9510/lib/python3.8/site-packages/snapcraft/parts/parts.py", line 192, in run
2023-07-31 09:52:43.518 raise errors.PartsLifecycleError(str(err)) from err
2023-07-31 09:52:43.518 snapcraft.errors.PartsLifecycleError: Command '['dpkg', '--add-architecture', 'arm64', '--root', '/']' returned non-zero exit status 2.
2023-07-31 09:52:43.518 Full execution log: '/root/.local/state/snapcraft/log/snapcraft-20230731-095242.281432.log
```
### Additional context
_No response_
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | Closed as a duplicate of #4289. The failure stemmed from incorrect dpkg argument ordering, requiring --add-architecture before --root. Resolved by correcting the command sequence in the installer. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed as duplicate of #4289. The bug stems from dpkg receiving --root after --add-architecture. The fix reorders the flags so --root comes first. Resolved in the referenced issue. | |
| qwen/qwen3.6-35b-a3b | — | — | Marked as a duplicate of #4289. The error occurs because dpkg requires the architecture argument before the --root flag. Fixed in the referenced PR by correcting the command argument order. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Closed as a duplicate of #4289. The error occurs because dpkg requires --add-architecture to precede other flags like --root. The fix is tracked in the referenced issue. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Snapcraft failed to add dpkg architectures due to incorrect command argument ordering. Closed as a duplicate of #4289, which resolves the same dpkg argument order issue. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #4289 dpkg --add-architecture fails when using package-repositories | snapcraft | closed | Fixed in Snapcraft candidate channel. --root was incorrectly placed before --add-architecture. Maintainers confirmed the argument order bug and directed users to the candidate channel for the fix, pending release after other architecture issues resolve. |