Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

improve local dev setup docs

Nick Sweeting49747738ca46
diff --git a/browser_use/cli.py b/browser_use/cli.py
index cb22cb2bc..82fcfb184 100644
--- a/browser_use/cli.py
+++ b/browser_use/cli.py
@@ -7,16 +7,24 @@ import time
from pathlib import Path
from typing import Any
-import click
+from dotenv import load_dotenv
+
+load_dotenv()
+
+try:
+ import click
+ from textual import events
+ from textual.app import App, ComposeResult
+ from textual.binding import Binding
+ from textual.containers import Container, HorizontalGroup, VerticalScroll
+ from textual.widgets import Footer, Header, Input, Label, Link, RichLog, Static
+except ImportError:
+ print('⚠️ CLI addon is not installed. Please install it with: `pip install browser-use[cli]` and try again.')
+ sys.exit(1)
+
import langchain_anthropic
import langchain_google_genai
import langchain_openai
-from dotenv import load_dotenv
-from textual import events
-from textual.app import App, ComposeResult
-from textual.binding import Binding
-from textual.containers import Container, HorizontalGroup, VerticalScroll
-from textual.widgets import Footer, Header, Input, Label, Link, RichLog, Static
try:
import readline
@@ -30,10 +38,20 @@ from browser_use import Agent, Browser, BrowserConfig, BrowserContextConfig, Con
from browser_use.agent.views import AgentSettings
from browser_use.logging_config import addLoggingLevel
-# User settings file
-USER_CONFIG_FILE = Path.home() / '.browser_use.json'
+# Paths
+USER_CONFIG_DIR = Path.home() / '.config' / 'browseruse'
+USER_CONFIG_FILE = USER_CONFIG_DIR / 'config.json'
+CHROME_PROFILES_DIR = USER_CONFIG_DIR / 'profiles'
+USER_DATA_DIR = CHROME_PROFILES_DIR / 'default'
+
+# Default User settings
MAX_HISTORY_LENGTH = 100
+# Ensure directories exist
+USER_CONFIG_FILE.parent.mkdir(parents=True, exist_ok=True)
+USER_DATA_DIR.mkdir(parents=True, exist_ok=True)
+
+
# Logo components with styling for rich panels
BROWSER_LOGO = """
[white] ++++++ +++++++++ [/]
@@ -117,9 +135,6 @@ def save_user_config(config: dict[str, Any]) -> None:
if len(config['command_history']) > MAX_HISTORY_LENGTH:
config['command_history'] = config['command_history'][-MAX_HISTORY_LENGTH:]
- # Create parent directories if they don't exist
- USER_CONFIG_FILE.parent.mkdir(parents=True, exist_ok=True)
-
with open(USER_CONFIG_FILE, 'w') as f:
json.dump(config, f, indent=2)
diff --git a/docs/development/local-setup.mdx b/docs/development/local-setup.mdx
index 33162ca20..b65cc7ad7 100644
--- a/docs/development/local-setup.mdx
+++ b/docs/development/local-setup.mdx
@@ -30,7 +30,10 @@ source .venv/bin/activate
```bash
# Install the package in editable mode with all development dependencies
-uv sync
+uv sync --all-extras
+
+# Install the default browser
+playwright install chromium --with-deps --no-shell
```
## Configuration
@@ -70,6 +73,39 @@ After setup, you can:
- Run tests with `uv run pytest`
- Build the package with `uv build`
+### Linting
+
+```bash
+# Run the linter on the whole project (must pass for PR to be allowed to merge)
+uv run pre-commit run --all-files
+
+# Install the linter & formatter pre-commit hooks to run automatically
+pre-commit install --install-hooks
+
+# Experimental: run the type checker
+uv run type
+```
+
+### Tests
+
+```bash
+# Run tests
+uv run pytest # run everything
+uv run pytest tests/test_controller.py # run a specific test file
+uv run pytest tests/test_sensitive_data.py tests/test_tab_management.py # run two test files
+uv run pytest tests/test_tab_management.py::TestTabManagement::test_user_changes_tab # run a single test
+```
+
+### Build
+
+```bash
+uv build
+uv pip install dist/*.whl
+
+# bush build to PyPI (automatically run by Github Actions CI)
+uv publish
+```
+
## Getting Help
If you run into any issues: