トラブルシューティング
各セクションでは、まず表示されるメッセージを示し、続いて原因と解決方法を説明します。
fastkit: command not found
シェルが fastkit コマンドを見つけられません。fastkit をインストールした仮想環境が有効化されていないか、uv tool install がコマンドを置くフォルダーが PATH に含まれていないかのどちらかです(uv tool update-shell で追加できます)。仮想環境を有効化すると(source .venv/bin/activate、Windows では .venv\Scripts\activate)、fastkit --version が fastapi-fastkit, version 2.0.0 を表示するようになります。python -m fastapi_fastkit を使うと、有効な仮想環境の Python で同じコマンドを実行できます。インストールも参照してください。
プロジェクトがすでに存在する
$ fastkit init --name hello --no-venv -y
╭──────────────── Error ────────────────╮
│ ❌ Project 'hello' already exists. │
╰───────────────────────────────────────╯
init は、指示がない限り既存のフォルダーには書き込みません。たいていは、別の名前にすれば解決します。ほかの 2 つの方法を試す前に、作業内容をコミットするかバックアップしてください。
fastkit deleteproject helloは、確認のあとhelloフォルダー全体を削除します。--in-placeは、現在のフォルダーにプロジェクトを書き込みます。テンプレートに含まれないファイルはそのまま残し、テンプレートに含まれるファイル(README.mdなど)は上書きします。ターミナルでは、上書きするファイルを一覧表示して先に確認を求めます。-yを付けると、確認せずに上書きします。
テンプレートが存在しない
$ fastkit init --template fastapi-sqlmode --project-name notes
╭───────────────────────────────── Error ──────────────────────────────────╮
│ ❌ Template 'fastapi-sqlmode' does not exist. Did you mean │
│ 'fastapi-sqlmodel', 'fastapi-single-module'? Run 'fastkit │
│ list-templates' to see the available templates. │
╰──────────────────────────────────────────────────────────────────────────╯
fastkit 2.0 で削除されたテンプレートも、同じように報告されます。その代わりになるテンプレートはfastkit 1.x からアップグレードするに書かれています。
runserver が仮想環境を見つけられない
--no-venv で作成したプロジェクトや、クローンしたばかりのプロジェクトには .venv がありません。fastkit runserver は、プロジェクトのパッケージマネージャーで仮想環境を作成するコマンドを表示します。そのコマンドを実行してから、もう一度 fastkit runserver を実行してください。
$ fastkit runserver
╭───────────────────────────────── Error ──────────────────────────────────╮
│ ❌ This FastAPI-fastkit project has no virtual environment (.venv), for │
│ example because it was created with --no-venv. Create it and install the │
│ dependencies from the project directory with: │
│ uv sync │
│ then run 'fastkit runserver' again. │
╰──────────────────────────────────────────────────────────────────────────╯
Do you want to continue with the current Python instead? [y/N]: n
uv がインストールされていない
fastkit は、uv がインストールされていれば uv を、そうでなければ pip を使います。pip を使う場合、まとめの表の Package manager 行は pip (uv is not installed) となり、Next steps パネルと README.md には pip のコマンドが表示されます。プロジェクトは pip でも動きます。uv を使うには、uv をインストールしてからプロジェクトを作成し直すか、--package-manager を指定してください。
Poetry が 2.0 より古い
$ fastkit init --name shop --level layered --database None --package-manager poetry -y
...
╭───────────────────────────────── Error ──────────────────────────────────╮
│ ❌ Project creation failed: Poetry 1.7.1 is installed, but projects │
│ generated by FastAPI-fastkit need Poetry 2.0 or later (they keep their │
│ dependencies in the standard [project] table, which older Poetry cannot │
│ read). Upgrade Poetry with 'poetry self update' (or 'pipx upgrade │
│ poetry' if pipx installed it), or choose another package manager with │
│ --package-manager uv, pdm or pip. Nothing was created. │
╰──────────────────────────────────────────────────────────────────────────╯
ポートがすでに使われている
ほかのプロセス(多くの場合、以前に起動したサーバー)がすでにそのポートで待ち受けています。runserver は、サーバーの終了ステータスで終了します。
$ fastkit runserver
...
╭───────────────────── Success ──────────────────────╮
│ ✨ Starting FastAPI server at 127.0.0.1:8000... │
╰────────────────────────────────────────────────────╯
...
ERROR: [Errno 48] Address already in use
╭───────────────────────────────── Error ──────────────────────────────────╮
│ ❌ The FastAPI server stopped with exit status 3; its messages above say │
│ why. │
╰──────────────────────────────────────────────────────────────────────────╯
ほかのサーバーを停止するか、--port で空いているポートを指定してください。エラー番号はシステムによって異なります。
プロジェクト名が依存パッケージの名前と同じ
$ fastkit init --template fastapi-sqlmodel --project-name sqlmodel --no-venv
╭───────────────────────────────── Error ──────────────────────────────────╮
│ ❌ The project name 'sqlmodel' is also the name of one of its │
│ dependencies (sqlmodel>=0.0.42): the package manager would take the │
│ project for that package and not install it, so the app could not import │
│ it. Choose another project name. │
╰──────────────────────────────────────────────────────────────────────────╯
Windows
- 仮想環境は、
source .venv/bin/activateの代わりに.venv\Scripts\activateで有効化します。 fastkit runserverは、どのシステムでも開発サーバーを起動します。生成されたプロジェクトのscripts/*.shヘルパーを使うには、Git Bash か WSL が必要です。