`fetch-libs` command requires being logged into charmhub
Metadata
Current evaluation
Fixed by merged PR #1702 (commit 1da46c8f), which made fetch-libs use anonymous Charmhub access. PR #1701 also fixed handling of library names containing underscores.
Resolution: closed resolved
Reason: PR #1702 was merged as commit 1da46c8f and explicitly allowed fetch-libs to run without logging in. A related merged fix, PR #1701, corrected library-name validation for underscored charm names.
Evaluated by: mr-cal-bot
No scores available.
Issue body
### Bug Description
The `fetch-libs` command uses a logged in charmhub session, though it doesn't need to.
### To Reproduce
1. Create a fresh VM/container
2. Add one or more libraries to a new charm
3. Run `charmcraft fetch-libs`
Expected:
Libraries are collected
Actual:
Requests login
### Environment
n/a
### charmcraft.yaml
```shell
name: cc-1654
type: charm
bases:
- build-on:
- name: ubuntu
channel: "22.04"
run-on:
- name: ubuntu
channel: "22.04"
# (Required)
summary: A very short one-line summary of the flask application.
# (Required)
description: |
A comprehensive overview of your Flask application.
]
charm-libs:
- lib: mysql.mysql
version: 0
```
### Relevant log output
```shell
2024-05-07 10:17:58.552 Getting library metadata from charmhub
2024-05-07 10:17:58.552 Retrieving credentials for 'charmcraft' on 'api.charmhub.io' from keyring 'SecretService Keyring'.
2024-05-07 10:17:58.553 Credentials not found in the keyring 'SecretService Keyring'
2024-05-07 10:17:58.553 charmcraft internal error: CredentialsUnavailable("No credentials found for 'charmcraft' on 'api.charmhub.io'.")
2024-05-07 10:17:58.554 Traceback (most recent call last):
2024-05-07 10:17:58.554 File "/snap/charmcraft/3643/lib/python3.10/site-packages/craft_application/application.py", line 510, in run
2024-05-07 10:17:58.554 return_code = dispatcher.run() or 0
2024-05-07 10:17:58.554 File "/snap/charmcraft/3643/lib/python3.10/site-packages/craft_cli/dispatcher.py", line 487, in run
2024-05-07 10:17:58.554 return self._loaded_command.run(self._parsed_command_args)
2024-05-07 10:17:58.554 File "/snap/charmcraft/3643/lib/python3.10/site-packages/charmcraft/application/commands/store.py", line 1676, in run
2024-05-07 10:17:58.554 libs_metadata = store.get_libraries_metadata_by_name(charm_libs)
2024-05-07 10:17:58.554 File "/snap/charmcraft/3643/lib/python3.10/site-packages/charmcraft/services/store.py", line 220, in get_libraries_metadata_by_name
2024-05-07 10:17:58.554 for lib in self.get_libraries_metadata(libraries)
2024-05-07 10:17:58.554 File "/snap/charmcraft/3643/lib/python3.10/site-packages/charmcraft/services/store.py", line 212, in get_libraries_metadata
2024-05-07 10:17:58.554 return self.client.fetch_libraries_metadata(store_libs)
2024-05-07 10:17:58.554 File "/snap/charmcraft/3643/lib/python3.10/site-packages/charmcraft/store/client.py", line 202, in fetch_libraries_metadata
2024-05-07 10:17:58.554 response = self.request_urlpath_json("POST", "/v1/charm/libraries/bulk", json=libs)
2024-05-07 10:17:58.554 File "/snap/charmcraft/3643/lib/python3.10/site-packages/charmcraft/store/client.py", line 134, in request_urlpath_json
2024-05-07 10:17:58.554 response = super().request(method, self.api_base_url + urlpath, *args, **kwargs)
2024-05-07 10:17:58.554 File "/snap/charmcraft/3643/lib/python3.10/site-packages/craft_store/base_client.py", line 184, in request
2024-05-07 10:17:58.554 headers["Authorization"] = self._get_authorization_header()
2024-05-07 10:17:58.554 File "/snap/charmcraft/3643/lib/python3.10/site-packages/craft_store/store_client.py", line 108, in _get_authorization_header
2024-05-07 10:17:58.554 auth = creds.unmarshal_candid_credentials(self._auth.get_credentials())
2024-05-07 10:17:58.554 File "/snap/charmcraft/3643/lib/python3.10/site-packages/craft_store/auth.py", line 277, in get_credentials
2024-05-07 10:17:58.554 raise errors.CredentialsUnavailable(self.application_name, self.host)
2024-05-07 10:17:58.554 craft_store.errors.CredentialsUnavailable: No credentials found for 'charmcraft' on 'api.charmhub.io'.
```
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Fixed by merged PR #1702 (commit 1da46c8f), which made fetch-libs use anonymous Charmhub access. PR #1701 also fixed handling of library names containing underscores. | |
| stealth/space-bunny-alpha | — | closed stale | canonical/charmcraft#1671 was closed without a documented fix or linked PR; fetch-libs remained unnecessarily dependent on a Charmhub login in the issue history. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Closed without a documented fix, likely abandoned. Investigation identified a conflicting API validation for charm name hyphens versus underscores, but no resolution or code changes were implemented. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without resolution. An internal ticket was created, but no fix was implemented. The issue appears abandoned after a contributor noted a related API validation mismatch. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed after an internal Jira ticket (CRAFT-2878) was created to track the bug. A related charm name validation conflict with the Charmhub API was noted. No public fix or resolution is documented. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | The fetch-libs command incorrectly required Charmhub authentication. The issue was closed without a documented fix. Investigation noted a conflicting API validation rule for charm names. |
Update history
No update history recorded yet.
Related work
-
Likely Fixed By:
canonical/charmcraft#1702
(confidence 99%)
Merged commit 1da46c8f allows fetch-libs to access Charmhub anonymously.
-
Related To:
canonical/charmcraft#1701
(confidence 95%)
Merged commit 3af2c248 fixed the related fetch-libs validation problem for library names with underscores.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #284 Running `charmcraft fetch-lib` on a charm with dashes should fetch to a path with underscores | charmcraft | closed | Closed as stale with no recorded fix or maintainer rationale. A later unlinked change, #1701 (3af2c248), implemented underscore support for fetch-libs. | |
| #1702 fix: allow fetch-libs to work without logging in | charmcraft | merged | Merged PR #1702 as commit 1da46c8f, allowing fetch-libs to run without logging in and addressing #1681. | |
| #1665 feat: add fetch-libs command | charmcraft | merged | Merged PR #1665 added Charmcraft's fetch-libs command; implementation landed in commit 38ea17d6. | |
| #1788 `fetch-lib` should work from anywhere | charmcraft | open | `fetch-lib` regressed in Charmcraft 3.1.1 by requiring charmcraft.yaml outside projects; a minimal reproducer was provided, and a maintainer explicitly kept the compatibility request open. | |
| #806 Add `--force` option to `charmcraft fetch-lib` | charmcraft | closed | --force was not added; merged PR #1665 introduced fetch-libs, which updates declared libraries despite local modifications. | |
| #2204 [3.4.3] Charmcraft fetch-lib fails with `Library None not found in Charmhub.` | charmcraft | open | Bulk fetch-lib aborts on an unavailable local library and misleadingly prints “Library None not found”; current code still uses the absent CLI argument, while PR #2505 remains open. |