Support --project-dir pointing to a missing directory (CRAFT-474).
Metadata
Current evaluation
Merged #508 (dbad275a, implementation 15d530ae) to tolerate a missing --project-dir; a later init regression was fixed by merged #543 (d21282d9).
Resolution: closed resolved
Reason: PR #508 was merged to accept a missing project directory and load the default configuration. Follow-up PR #543 was later merged to restore the intended init behavior for missing directories.
Evaluated by: mr-cal-bot
No scores available.
Issue body
I just fixed this when loading the config, so at least `charmcraft` does not crash.
I considered doing this verification in `main.py`, when loading the argument. The verification there would make more sense, as it's a "command line argument" verification, and we could raise a proper ArgumentParsingError indicating that the directory does not exist.
However, we *may want* for `--project-dir` to point to a directory that is not there, for the `init` command. See issue #198, where it claims that if the directory indicated to `init` is not there, we should create it.
So, in the end, I decided that the best behaviour is to just "accept" the parameter pointing to nowhere, and load a default config with that info. Note that the flag `config_provided` is `False` in this case, so if the executed command does need a real config, it will finish in error anyway.
One way to test this behaviour change is by issuing:
charmcraft version --project-dir /whatever
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Merged #508 (dbad275a, implementation 15d530ae) to tolerate a missing --project-dir; a later init regression was fixed by merged #543 (d21282d9). | |
| stealth/space-bunny-alpha | — | closed resolved | Merged #508 in commit 15d530ae, allowing a missing --project-dir without crashing and supporting init; a later regression was fixed by #543. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged in #508 via dbad275a (fix commit 15d530ae), allowing --project-dir to reference a missing directory. A later init regression was fixed by #543 in d21282d9. | |
| qwen/qwen3.6-35b-a3b | — | — | Merged fix preventing charmcraft from crashing when --project-dir points to a missing directory. Allows init to accept non-existent paths. A later regression was fixed in PR #543. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged to prevent crashes when --project-dir references a missing directory. The fix accepts non-existent paths during config loading, deferring validation to commands requiring a real config. A later regression was resolved in PR #543. |
Update history
No update history recorded yet.
Related work
-
Likely Fixed By:
canonical/charmcraft#543
(confidence 99%)
Merged as d21282d9 to fix the reported regression where init failed when the target directory did not exist.
-
Related To:
canonical/charmcraft#198
(confidence 95%)
Discussed the requirement for init to create and use a project directory that does not yet exist.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #543 Support a missing directory in the init command (CRAFT-541). | charmcraft | merged | Merged support for running charmcraft init when the target directory is missing, and removed ineffective series arguments from tests. | |
| #229 fix: make project directory loading less strict. | craft-application | merged | Merged PR #229 in commit 341e378d: project-directory loading now permits missing directories and rejects only incompatible existing paths, supporting commands such as init. |