`charmcraft pack` doesn't include all error output
Metadata
Current evaluation
Fixed in Charmcraft 1.5 via improved instance-internal log retrieval, ensuring full build error output is captured. Closed by maintainer pending user verification on the updated version.
Suggested action: —
No scores available.
Issue body
I'm trying to make some small changes to the postgresql-k8s charm, but it hasn't been touched since before charmcraft.yaml was a requirement (last updated in May 2021).
This is what my requirements.txt and charmcraft.yaml look like:
```
mthaddon@tenaya:~/repos/k8s-charms/charm-k8s-postgresql/charm-k8s-postgresql$ cat requirements.txt
# [REDACTED comments for brevity]
git+git://github.com/canonical/operator@f521841#egg=ops
charmhelpers
kubernetes
oci-image
pgconnstr
psycopg2
pyyaml
tenacity
mthaddon@tenaya:~/repos/k8s-charms/charm-k8s-postgresql/charm-k8s-postgresql$ cat charmcraft.yaml
type: charm
bases:
- build-on:
- name: "ubuntu"
channel: "20.04"
run-on:
- name: "ubuntu"
channel: "20.04"
parts:
charm:
build-packages:
- git
- libpq-dev
```
When I run `charmcraft pack` I see the following in the logs:
```
2022-03-06 13:54:36.658 :: 2022-03-06 12:54:35.671 :: Collecting Jinja2
2022-03-06 13:54:36.658 :: 2022-03-06 12:54:35.674 :: Using cached Jinja2-3.0.3.tar.gz (269 kB)
2022-03-06 13:54:36.658 :: 2022-03-06 12:54:35.910 :: ERROR: Command errored out with exit status 1:
2022-03-06 13:54:36.658 :: 2022-03-06 12:54:35.910 :: command: /root/parts/charm/build/staging-venv/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-zqtn4m0n/Jinja2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-zqtn4m0n/Jinja2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-zqtn4m0n/Jinja2/pip-egg-info
2022-03-06 13:54:36.658 :: 2022-03-06 12:54:35.911 :: cwd: /tmp/pip-install-zqtn4m0n/Jinja2/
2022-03-06 13:54:36.658 :: 2022-03-06 12:54:35.911 :: Complete output (35 lines):
2022-03-06 13:54:36.658 :: 2022-03-06 12:54:35.911 :: Traceback (most recent call last):
2022-03-06 13:54:36.658 :: 2022-03-06 12:54:35.911 :: File "<string>", line 1, in <module>
2022-03-06 13:54:36.658 :: 2022-03-06 12:54:35.911 :: File "/tmp/pip-install-zqtn4m0n/Jinja2/setup.py", line 4, in <module>
2022-03-06 13:54:36.658 :: 2022-03-06 12:54:35.911 :: setup(
2022-03-06 13:54:36.659 Executing on host: lxc --project charmcraft config device show local:charmcraft-postgresql-k8s-9553140-0-0-amd64
2022-03-06 13:54:36.766 Executing on host: lxc --project charmcraft config device remove local:charmcraft-postgresql-k8s-9553140-0-0-amd64 disk-/root/project
2022-03-06 13:54:36.943 Executing on host: lxc --project charmcraft stop local:charmcraft-postgresql-k8s-9553140-0-0-amd64
2022-03-06 13:54:38.431 Failed to build charm for bases index '0'.
2022-03-06 13:54:38.433 Traceback (most recent call last):
2022-03-06 13:54:38.433 File "/snap/charmcraft/761/lib/charmcraft/commands/build.py", line 467, in pack_charm_in_instance
2022-03-06 13:54:38.433 instance.execute_run(
2022-03-06 13:54:38.433 File "/snap/charmcraft/761/lib/craft_providers/lxd/lxd_instance.py", line 221, in execute_run
2022-03-06 13:54:38.433 return self.lxc.exec(
2022-03-06 13:54:38.433 File "/snap/charmcraft/761/lib/craft_providers/lxd/lxc.py", line 307, in exec
2022-03-06 13:54:38.433 return runner(final_cmd, **kwargs) # pylint: disable=subprocess-run-check
2022-03-06 13:54:38.433 File "/snap/charmcraft/761/usr/lib/python3.8/subprocess.py", line 516, in run
2022-03-06 13:54:38.433 raise CalledProcessError(retcode, process.args,
2022-03-06 13:54:38.433 subprocess.CalledProcessError: Command '['lxc', '--project', 'charmcraft', 'exec', 'local:charmcraft-postgresql-k8s-9553140-0-0-amd64', '--cwd', '/root/project', '--', 'env', 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin', 'CHARMCRAFT_MANAGED_MODE=1', 'charmcraft', 'pack', '--bases-index', '0']' returned non-zero exit status 1.
```
However, if I start the LXC, exec in and run the same commands charmcraft is doing (e.g. `python3 -m venv /root/parts/charm/build/staging-venv && /root/parts/charm/build/staging-venv/bin/pip3 install --upgrade --no-binary :all: --requirement=requirements.txt`) I see the following output:
```
Collecting Jinja2
Using cached Jinja2-3.0.3.tar.gz (269 kB)
ERROR: Command errored out with exit status 1:
command: /root/parts/charm/build/staging-venv/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-lvssyfhi/Jinja2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-lvssyfhi/Jinja2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-lvssyfhi/Jinja2/pip-egg-info
cwd: /tmp/pip-install-lvssyfhi/Jinja2/
Complete output (35 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-lvssyfhi/Jinja2/setup.py", line 4, in <module>
setup(
File "/root/parts/charm/build/staging-venv/lib/python3.8/site-packages/setuptools/__init__.py", line 145, in setup
return distutils.core.setup(**attrs)
File "/usr/lib/python3.8/distutils/core.py", line 121, in setup
dist.parse_config_files()
File "/root/parts/charm/build/staging-venv/lib/python3.8/site-packages/setuptools/dist.py", line 701, in parse_config_files
parse_configuration(self, self.command_options,
File "/root/parts/charm/build/staging-venv/lib/python3.8/site-packages/setuptools/config.py", line 121, in parse_configuration
meta.parse()
File "/root/parts/charm/build/staging-venv/lib/python3.8/site-packages/setuptools/config.py", line 426, in parse
section_parser_method(section_options)
File "/root/parts/charm/build/staging-venv/lib/python3.8/site-packages/setuptools/config.py", line 399, in parse_section
self[name] = value
File "/root/parts/charm/build/staging-venv/lib/python3.8/site-packages/setuptools/config.py", line 184, in __setitem__
value = parser(value)
File "/root/parts/charm/build/staging-venv/lib/python3.8/site-packages/setuptools/config.py", line 515, in _parse_version
version = self._parse_attr(value, self.package_dir)
File "/root/parts/charm/build/staging-venv/lib/python3.8/site-packages/setuptools/config.py", line 349, in _parse_attr
module = import_module(module_name)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/tmp/pip-install-lvssyfhi/Jinja2/src/jinja2/__init__.py", line 8, in <module>
from .environment import Environment as Environment
File "/tmp/pip-install-lvssyfhi/Jinja2/src/jinja2/environment.py", line 15, in <module>
from markupsafe import Markup
ModuleNotFoundError: No module named 'markupsafe'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
```
It would be helpful if the charmcraft log included this information so I didn't have to dig for it manually.
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen3.6-35b-a3b-mtp-q6 | — | — | Fixed in Charmcraft 1.5 via improved instance-internal log retrieval, ensuring full build error output is captured. Closed by maintainer pending user verification on the updated version. | |
| qwen/qwen3.6-35b-a3b | — | — | Resolved in Charmcraft 1.5 by enhancing instance-internal log retrieval to capture complete pip and build error traces. The issue was closed as fixed, with the maintainer recommending an upgrade to v1.5 and reopening if the truncation persists. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Resolved in Charmcraft 1.5 by improving instance-internal log retrieval to capture full build error output. Issue closed as fixed. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Resolved in Charmcraft 1.5 by improving instance-internal log retrieval, ensuring charmcraft pack outputs complete build errors. Issue closed as fixed. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1747 Failed to run the build script for part 'charm' | charmcraft | closed | Build script failure during charmcraft pack was resolved. The issue was closed after the maintainer acknowledged the report and merged the fix in PR #1751. | |
| #501 charmcraft pack fails trying to include a non-existing charm/src/.tox/ | charmcraft | closed | charmcraft pack failed when copying non-existent build directories or files. Users worked around it with charmcraft clean. The issue was closed as fixed upstream in the underlying parts lifecycle code. | |
| #552 `charmcraft pack` runs indefinitely when using parts | charmcraft | closed | The charmcraft pack hang was caused by a duplicate ignore patterns bug. This was fixed in Charmcraft 1.3.0. The author confirmed they would upgrade and close the issue pending recurrence. | |
| #140 Always log the charmcraft version when indicated. | charmcraft | merged | Merged. Relocated charmcraft version logging from Dispatcher initialization to MessageHandler, guaranteeing consistent file output and terminal display in verbose mode. Approved by two reviewers, passed CI, and addresses part of issue #48. |