fix: quickstart fails on Windows — missing DATABASE_STRING (#5719)
Some checks are pending
Run tests and pre-commit / Run tests and pre-commit hooks (push) Waiting to run
Run tests and pre-commit / Frontend Lint and Build (push) Waiting to run
Publish Fern Docs / run (push) Waiting to run

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Suchintan 2026-04-29 19:59:52 -07:00 committed by GitHub
parent ada83abe7c
commit 8b203899e8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 33 additions and 12 deletions

View file

@ -81,25 +81,20 @@ async def run_migrations_online():
await connectable.dispose()
print("Alembic mode: ", "offline" if context.is_offline_mode() else "online")
if context.is_offline_mode():
run_migrations_offline()
else:
async def async_main():
await run_migrations_online()
try:
loop = asyncio.get_running_loop()
except RuntimeError:
# No running loop -> safe to start one
print("Alembic: no running loop")
asyncio.run(async_main())
else:
# Already running loop -> schedule task and await it
print("Alembic: schedule task")
import concurrent.futures
# Use a ThreadPoolExecutor to run the async function in a new thread
with concurrent.futures.ThreadPoolExecutor() as executor:
future = executor.submit(asyncio.run, async_main())
future.result() # This blocks until completion
future.result()

View file

@ -20,6 +20,8 @@ services:
skyvern:
image: public.ecr.aws/skyvern/skyvern:latest
restart: on-failure
extra_hosts:
- "host.docker.internal:host-gateway"
env_file:
- .env
# comment out if you want to externally call skyvern API

View file

@ -10,6 +10,7 @@ from rich.prompt import Confirm
from skyvern.analytics import capture_setup_event
from .console import console
from .llm_setup import DEFAULT_POSTGRES_DATABASE_STRING, update_or_add_env_var
def command_exists(command: str) -> bool:
@ -122,6 +123,7 @@ def setup_postgresql(no_postgres: bool = False) -> None:
console.print("✅ [green]Database and user exist.[/green]")
else:
create_database_and_user()
update_or_add_env_var("DATABASE_STRING", DEFAULT_POSTGRES_DATABASE_STRING)
capture_setup_event("database-complete", success=True, extra_data={"source": "local"})
return
@ -134,14 +136,26 @@ def setup_postgresql(no_postgres: bool = False) -> None:
return
if not is_docker_running():
docker_installed = command_exists("docker")
if docker_installed:
error_msg = "Docker is installed but not running"
console.print("[red]Docker is installed but the daemon is not running.[/red]")
console.print(
"[yellow]Please start Docker Desktop (or the Docker daemon) and re-run this command.[/yellow]"
)
else:
error_msg = "Docker is not installed"
console.print("[red]Docker is not installed.[/red]")
console.print(
"[yellow]Skyvern needs Docker to run PostgreSQL. Please either:[/yellow]\n"
" 1. Install Docker: [link]https://docs.docker.com/get-docker/[/link]\n"
" 2. Or provide your own Postgres via: [bold]skyvern init --database-string 'postgresql+psycopg://user:pass@host:5432/dbname'[/bold]"
)
capture_setup_event(
"database-fail",
success=False,
error_type="docker_not_running",
error_message="Docker is not running or not installed",
)
console.print(
"[red]Docker is not running or not installed. Please install or start Docker and try again.[/red]"
error_message=error_msg,
)
raise SystemExit(1)
@ -234,4 +248,5 @@ def setup_postgresql(no_postgres: bool = False) -> None:
else:
console.print("✅ [green]Database and user created successfully.[/green]")
update_or_add_env_var("DATABASE_STRING", DEFAULT_POSTGRES_DATABASE_STRING)
capture_setup_event("database-complete", success=True, extra_data={"source": "docker"})

View file

@ -9,6 +9,8 @@ from skyvern.utils.env_paths import resolve_backend_env_path
from .console import console
DEFAULT_POSTGRES_DATABASE_STRING = "postgresql+psycopg://skyvern@localhost:5432/skyvern"
def update_or_add_env_var(key: str, value: str) -> None:
"""Update or add environment variable in .env file."""
@ -42,7 +44,7 @@ def update_or_add_env_var(key: str, value: str) -> None:
"MAX_STEPS_PER_RUN": "50",
"LOG_LEVEL": "INFO",
"LITELLM_LOG": "CRITICAL",
"DATABASE_STRING": "postgresql+psycopg://skyvern@localhost/skyvern",
"DATABASE_STRING": DEFAULT_POSTGRES_DATABASE_STRING,
"PORT": "8000",
"ANALYTICS_ID": "anonymous",
"ENABLE_LOG_ARTIFACTS": "false",

View file

@ -34,6 +34,13 @@ def setup_windows_event_loop_policy() -> None:
def migrate_db() -> None:
# Import here to avoid circular import (config -> utils -> analytics -> config)
from skyvern.analytics import capture_setup_error, capture_setup_event
from skyvern.config import Settings, _ensure_sqlite_dir
from skyvern.forge.sdk.settings_manager import SettingsManager
# Reload settings so env vars set by setup_postgresql() are picked up.
refreshed = Settings()
SettingsManager.set_settings(refreshed)
_ensure_sqlite_dir(refreshed.DATABASE_STRING)
capture_setup_event("migration-start")
try: