Skip to content

Automate browser based workflows with AI

fix: quickstart fails on Windows — missing DATABASE_STRING (#5719)

Suchintan8b203899e87d
diff --git a/alembic/env.py b/alembic/env.py
index 4a20e591a..1a5909f7e 100644
--- a/alembic/env.py
+++ b/alembic/env.py
@@ -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()
diff --git a/docker-compose.yml b/docker-compose.yml
index 3b835a3cd..4936e33c9 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -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
diff --git a/skyvern/cli/database.py b/skyvern/cli/database.py
index e707f92d1..a9124ccc2 100644
--- a/skyvern/cli/database.py
+++ b/skyvern/cli/database.py
@@ -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"})
diff --git a/skyvern/cli/llm_setup.py b/skyvern/cli/llm_setup.py
index be1027b17..c75319930 100644
--- a/skyvern/cli/llm_setup.py
+++ b/skyvern/cli/llm_setup.py
@@ -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",
diff --git a/skyvern/utils/__init__.py b/skyvern/utils/__init__.py
index d30f0232a..4b7df21b4 100644
--- a/skyvern/utils/__init__.py
+++ b/skyvern/utils/__init__.py
@@ -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: