Skip to content

# Bug Report: fastapi-forge fails on WSL/Linux with multiple issues #110

@matteolavaggi

Description

@matteolavaggi

Bug Report: fastapi-forge fails on WSL/Linux with multiple issues

Environment

  • OS: WSL Ubuntu (Windows Subsystem for Linux)
  • Python Version: 3.10
  • fastapi-forge Version: 0.13.0
  • Installation Method: pip install fastapi-forge

Description

When running fastapi-forge start on WSL/Linux, the application encounters multiple critical issues:

  1. Missing configuration file error - looks for default_project_models.json in current working directory instead of package installation directory
  2. Runtime crash - same sys.argv[0] issue as Windows when trying to access the web interface

Steps to Reproduce

  1. Install WSL Ubuntu on Windows
  2. Create a virtual environment: python3 -m venv .venv
  3. Activate environment: source .venv/bin/activate
  4. Install fastapi-forge: pip install fastapi-forge
  5. Run the command: fastapi-forge start

Issue #1: Missing Configuration File

Error Message

FileNotFoundError: [Errno 2] No such file or directory: '/path/to/project/fastapi_forge/default_project_models.json'

Full Stack Trace

Traceback (most recent call last):
  File "/path/to/project/.venv/bin/fastapi-forge", line 5, in <module>
    from fastapi_forge import main
  File "/path/to/project/.venv/lib/python3.10/site-packages/fastapi_forge/__init__.py", line 4, in <module>
    main()
  File "/path/to/project/.venv/lib/python3.10/site-packages/click/core.py", line 1462, in __call__
    return self.main(*args, **kwargs)
  File "/path/to/project/.venv/lib/python3.10/site-packages/click/core.py", line 1383, in main
    rv = self.invoke(ctx)
  File "/path/to/project/.venv/lib/python3.10/site-packages/click/core.py", line 1850, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/path/to/project/.venv/lib/python3.10/site-packages/click/core.py", line 1246, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/path/to/project/.venv/lib/python3.10/site-packages/click/core.py", line 814, in invoke
    return callback(*args, **kwargs)
  File "/path/to/project/.venv/lib/python3.10/site-packages/fastapi_forge/cli.py", line 15, in start
    init()
  File "/path/to/project/.venv/lib/python3.10/site-packages/fastapi_forge/frontend.py", line 17, in init
    with open(path) as file:
FileNotFoundError: [Errno 2] No such file or directory: '/path/to/project/fastapi_forge/default_project_models.json'

Root Cause

The code in fastapi_forge/frontend.py line 17 is trying to open a configuration file using a relative path that assumes the file is in the current working directory rather than in the installed package directory.

The file actually exists at:

.venv/lib/python3.10/site-packages/fastapi_forge/default_project_models.json

But the code is looking for it at:

./fastapi_forge/default_project_models.json  # Current working directory

Issue #2: Runtime Crash (Same as Windows)

After manually creating the missing directory and copying the file, the application starts but crashes when accessing the web interface with the same sys.argv[0] issue as on Windows.

Error Message

SystemExit: 0

Occurs in nicegui/ui_run.py when trying to execute runpy.run_path(sys.argv[0])

Stack Trace Excerpt

File ".venv/lib/python3.10/site-packages/nicegui/ui_run.py", line 131, in run_script
  runpy.run_path(sys.argv[0], run_name='__main__')
File "/usr/lib/python3.10/runpy.py", line 289, in run_path
  return _run_module_code(code, init_globals, run_name,
[...]
File ".venv/bin/fastapi-forge", line 9, in <module>
  sys.exit(main())
[...]
SystemExit: 0

Expected Behavior

  1. The tool should find its configuration files from the package installation directory
  2. The web interface should load successfully at http://localhost:8777
  3. Users should be able to define database schema and generate projects

Actual Behavior

  1. Immediate crash due to missing configuration file in wrong location
  2. After workaround, runtime crash when accessing the web interface

Suggested Fixes

For Issue #1 (Missing Configuration File)

In fastapi_forge/frontend.py, use proper path resolution:

import os
from pathlib import Path

# Get the package installation directory
package_dir = Path(__file__).parent
config_path = package_dir / "default_project_models.json"

with open(config_path) as file:
    # ... rest of the code

Instead of using a relative path that depends on the current working directory.

For Issue #2 (Runtime Crash)

Same fix as suggested for Windows - handle sys.argv[0] properly in the NiceGUI integration or use an alternative approach that doesn't rely on script introspection.

Workaround Attempted

Created the missing directory structure manually:

mkdir -p fastapi_forge
cp .venv/lib/python3.10/site-packages/fastapi_forge/default_project_models.json fastapi_forge/

This fixes Issue #1 but Issue #2 still occurs.

Additional Context

This suggests the tool was not properly tested on:

  • WSL/Linux environments
  • Installations via pip in virtual environments
  • Running from different working directories

The assumption that configuration files will be in the current working directory is a fundamental design flaw that makes the tool unusable in most real-world scenarios.

Related Issues

This is related to the Windows issue (#[number]) but with an additional critical bug specific to how the tool handles package resources.

Platform Impact

  • Windows: Broken (sys.argv[0] issue)
  • WSL/Linux: Broken (missing config + sys.argv[0] issue)
  • macOS: Likely broken (same issues would apply)

The tool appears to be fundamentally broken across all platforms in the current release (0.13.0).

Would appreciate urgent attention to these critical issues. Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions