diff --git a/pkgs/clan-cli/clan_lib/clan/create.py b/pkgs/clan-cli/clan_lib/clan/create.py index 48c192565..4f636b263 100644 --- a/pkgs/clan-cli/clan_lib/clan/create.py +++ b/pkgs/clan-cli/clan_lib/clan/create.py @@ -84,7 +84,7 @@ def create_clan(opts: CreateOptions) -> None: # _postprocess_flake_hook must be private to avoid leaking it to the public API post_process=opts._postprocess_flake_hook, # noqa: SLF001 ) as _clan_dir: - flake = Flake(str(opts.dest)) + flake = Flake(str(Path(opts.dest).absolute())) if opts.setup_git: run(git_command(dest, "init")) diff --git a/pkgs/clan-cli/clan_lib/clan/create_test.py b/pkgs/clan-cli/clan_lib/clan/test_create.py similarity index 86% rename from pkgs/clan-cli/clan_lib/clan/create_test.py rename to pkgs/clan-cli/clan_lib/clan/test_create.py index 9855a9ee0..ec501b224 100644 --- a/pkgs/clan-cli/clan_lib/clan/create_test.py +++ b/pkgs/clan-cli/clan_lib/clan/test_create.py @@ -38,6 +38,29 @@ def test_create_simple(tmp_path: Path, offline_flake_hook: Any) -> None: assert "instances" in inventory +@pytest.mark.with_core +def test_can_handle_path_without_slash( + tmp_path: Path, + offline_flake_hook: Any, + monkeypatch: pytest.MonkeyPatch, +) -> None: + """ + Tests for a regression, where it broke when the path is a single word like `foo`. + The flake identifier was interpreted as an external flake. + """ + monkeypatch.chdir(tmp_path) + dest = Path("test_clan") + + opts = CreateOptions( + dest=dest, template="default", _postprocess_flake_hook=offline_flake_hook + ) + + create_clan(opts) + + assert dest.exists() + assert dest.is_dir() + + @pytest.mark.with_core def test_create_with_name(tmp_path: Path, offline_flake_hook: Any) -> None: """