Part `pebble` cannot be primed if there is ill-formed `mkdir` in the stage directory
Metadata
Current evaluation
Fixed by merged PR canonical/rockcraft#1026 (9905e6f5): Pebble priming now uses coreutils from the base/build-base, so staged executables cannot shadow mkdir.
Resolution: closed resolved
Reason: PR canonical/rockcraft#1026 was merged as commit 9905e6f5. It updates the Pebble part to use coreutils from the base or build-base, preventing staged files from overriding commands such as mkdir during priming.
Evaluated by: mr-cal-bot
No scores available.
Issue body
### Bug Description
The `override-prime` of the part `pebble` cannot be correctly executed due to the `PATH` being overridden. If there are any files named `mkdir` staged by other parts, the staged `mkdir` will be used to execute the override prime script instead of using the one in the build base.
The `PATH` during priming the `my-part` part:
```
PATH=/root/parts/my-part/install/usr/sbin:/root/parts/my-part/install/usr/bin:/root/parts/my-part/install/sbin:/root/parts/my-part/install/bin:/root/stage/usr/sbin:/root/stage/usr/bin:/root/stage/sbin:/root/stage/bin:/snap/rockcraft/3790/libexec/rockcraft:/snap/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
```
Effectively, any `mkdir` or `chmod` that the `override-prime` of part `pebble` calls will be using the ones from the stage path instead of the system default path.
### To Reproduce
Use the following `rockcraft.yaml` file. Run `rockcraft pack --verbosity trace`, and the process will fail with the following log.
### Environment
```
# /etc/os-release
PRETTY_NAME="Ubuntu 24.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.3 LTS (Noble Numbat)"
VERSION_CODENAME=noble
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=noble
LOGO=ubuntu-logo
```
```
$ snap list | grep 'rockcraft\|lxd'
lxd 6.5-ccdfb39 36020 latest/stable canonical** -
rockcraft 1.15.0 3790 latest/stable canonical** classic
```
### rockcraft.yaml
```yaml
name: debug-rock
base: bare
build-base: ubuntu@24.04
version: '0.1'
summary: Summary
description: |
Description.
platforms:
amd64:
parts:
my-part:
plugin: nil
override-build: |
mkdir -p ${CRAFT_PART_INSTALL}/usr/bin
echo -e "#!/usr/bin/env bash\n echo 'Fake mkdir!'\nexit 1" > ${CRAFT_PART_INSTALL}/usr/bin/mkdir
chmod +x ${CRAFT_PART_INSTALL}/usr/bin/mkdir
```
### Relevant log output
```shell
...
2025-11-17 17:26:22.868 Staging my-part
2025-11-17 17:26:22.869 execute action my-part:Action(part_name='my-part', step=Step.STAGE, action_type=ActionType.RUN, reason=None, project_vars=ProjectVarInfo(root={}), properties=ActionProperties(changed_files=None, changed_dirs=None))
2025-11-17 17:26:22.888 Staging pebble
2025-11-17 17:26:22.888 execute action pebble:Action(part_name='pebble', step=Step.STAGE, action_type=ActionType.RUN, reason=None, project_vars=ProjectVarInfo(root={}), properties=ActionProperties(changed_files=None, changed_dirs=None))
2025-11-17 17:26:22.909 Priming my-part
2025-11-17 17:26:22.910 execute action my-part:Action(part_name='my-part', step=Step.PRIME, action_type=ActionType.RUN, reason=None, project_vars=ProjectVarInfo(root={}), properties=ActionProperties(changed_files=None, changed_dirs=None))
2025-11-17 17:26:22.928 Pruning primed files that already exist on base layer...
2025-11-17 17:26:22.929 Priming pebble
2025-11-17 17:26:22.929 execute action pebble:Action(part_name='pebble', step=Step.PRIME, action_type=ActionType.RUN, reason=None, project_vars=ProjectVarInfo(root={}), properties=ActionProperties(changed_files=None, changed_dirs=None))
2025-11-17 17:26:22.931 Executing PosixPath('/tmp/tmpojpt7lxf/scriptlet.sh')
2025-11-17 17:26:22.933 :: + craftctl default
2025-11-17 17:26:23.664 ctl server received: b'{"function": "default", "args": []}'
2025-11-17 17:26:23.665 ctl server received: b''
2025-11-17 17:26:23.725 :: + mkdir -p var/lib/pebble/default/layers
2025-11-17 17:26:23.728 :: Fake mkdir!
2025-11-17 17:26:23.729 'override-prime' in part 'pebble' failed with code 1.
2025-11-17 17:26:23.729 Detailed information:
:: + craftctl default
:: + mkdir -p var/lib/pebble/default/layers
2025-11-17 17:26:23.734 Traceback (most recent call last):
2025-11-17 17:26:23.734 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_parts/executor/step_handler.py", line 395, in run_scriptlet
2025-11-17 17:26:23.734 _create_and_run_script(
2025-11-17 17:26:23.734 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_parts/executor/step_handler.py", line 572, in _create_and_run_script
2025-11-17 17:26:23.734 process.run(
2025-11-17 17:26:23.734 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_parts/utils/process.py", line 186, in run
2025-11-17 17:26:23.734 result.check_returncode()
2025-11-17 17:26:23.734 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_parts/utils/process.py", line 52, in check_returncode
2025-11-17 17:26:23.734 raise ProcessError(self)
2025-11-17 17:26:23.734 craft_parts.utils.process.ProcessError: ProcessResult(returncode=1, stdout=b'Fake mkdir!\n', stderr=b'+ craftctl default\n+ mkdir -p var/lib/pebble/default/layers\n', combined=b'+ craftctl default\n+ mkdir -p var/lib/pebble/default/layers\nFake mkdir!\n', command=[PosixPath('/tmp/tmpojpt7lxf/scriptlet.sh')])
2025-11-17 17:26:23.734
2025-11-17 17:26:23.734 The above exception was the direct cause of the following exception:
2025-11-17 17:26:23.734 Traceback (most recent call last):
2025-11-17 17:26:23.734 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_application/services/lifecycle.py", line 306, in run
2025-11-17 17:26:23.734 self._exec(actions)
2025-11-17 17:26:23.734 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_application/services/lifecycle.py", line 330, in _exec
2025-11-17 17:26:23.735 aex.execute(action, stdout=stream, stderr=stream)
2025-11-17 17:26:23.735 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_parts/executor/executor.py", line 353, in execute
2025-11-17 17:26:23.735 self._executor.execute(actions, stdout=stdout, stderr=stderr)
2025-11-17 17:26:23.735 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_parts/executor/executor.py", line 153, in execute
2025-11-17 17:26:23.735 self._run_action(act, stdout=stdout, stderr=stderr)
2025-11-17 17:26:23.735 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_parts/executor/executor.py", line 246, in _run_action
2025-11-17 17:26:23.735 handler.run_action(action, stdout=stdout, stderr=stderr)
2025-11-17 17:26:23.735 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_parts/executor/part_handler.py", line 313, in run_action
2025-11-17 17:26:23.735 state = handler(step_info, stdout=stdout, stderr=stderr)
2025-11-17 17:26:23.735 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-11-17 17:26:23.735 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_parts/executor/part_handler.py", line 583, in _run_prime
2025-11-17 17:26:23.735 contents = self._run_step(
2025-11-17 17:26:23.735 ^^^^^^^^^^^^^^^
2025-11-17 17:26:23.735 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_parts/executor/part_handler.py", line 671, in _run_step
2025-11-17 17:26:23.735 step_handler.run_scriptlet(
2025-11-17 17:26:23.735 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_parts/executor/step_handler.py", line 405, in run_scriptlet
2025-11-17 17:26:23.735 raise errors.ScriptletRunError(
2025-11-17 17:26:23.735 craft_parts.errors.ScriptletRunError: 'override-prime' in part 'pebble' failed with code 1.
2025-11-17 17:26:23.735
2025-11-17 17:26:23.735 :: + craftctl default
2025-11-17 17:26:23.735 :: + mkdir -p var/lib/pebble/default/layers
2025-11-17 17:26:23.735 Review the scriptlet and make sure it's correct.
2025-11-17 17:26:23.735 Recommended resolution: Review the scriptlet and make sure it's correct.
2025-11-17 17:26:23.735 For more information, check out: https://documentation.ubuntu.com/rockcraft/en/1.15.0/reference/plugins/
2025-11-17 17:26:23.735 Full execution log: '/tmp/rockcraft.log'
...
```
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Fixed by merged PR canonical/rockcraft#1026 (9905e6f5): Pebble priming now uses coreutils from the base/build-base, so staged executables cannot shadow mkdir. | |
| stealth/space-bunny-alpha | — | closed resolved | Fixed by canonical/rockcraft#1026, merged as 9905e6f5: Pebble priming now uses coreutils from the build base, preventing staged executables from shadowing mkdir. | |
| qwen/qwen3.6-35b-a3b | — | — | Abandoned. The bug describes a PATH collision where a staged mkdir overrides the system binary during the pebble part's override-prime step, causing build failures. No fix or merge was documented. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without resolution. The bug report detailing how staged files pollute the PATH and break the pebble part's override-prime step remains unfixed. | |
| qwen/qwen3.6-35b-a3b | — | — | Abandoned without a fix or resolution details. The report identifies that staged binaries override the PATH during the prime step, causing the pebble part's override-prime scriptlet to fail. No pull request or resolution was linked. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Closed without comments or a stated resolution. The report details how staged binaries override the PATH during the pebble part's prime step, causing scriptlet failures. No fix or merge was documented. |
Update history
No update history recorded yet.
Related work
-
Likely Fixed By:
canonical/rockcraft#1026
(confidence 100%)
Merged fix explicitly targets the PATH-shadowing failure reported in issue #1023.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1026 fix: use (build-)base's coreutils in pebble part | rockcraft | merged | Merged PR #1026 as commit 9905e6f5, fixing #1023 by using coreutils from the build base while priming the Pebble part. |