- Installing dependencies
- Copying environment files
- Creating database branches
- Starting Docker containers
- Cleaning up resources
Configuration File
Setup and teardown scripts are configured in.superset/config.json at the root of your repository:
.superset/config.json
Both
setup and teardown accept arrays of commands. You can run multiple scripts or inline commands.Setup Scripts
Setup scripts run when a new workspace is created. They prepare the workspace environment.Basic Setup Script
.superset/setup.sh
Advanced Setup Script
Here’s a more comprehensive example from the Superset repository:.superset/setup.sh (Advanced)
- Loads environment variables from the root repository
- Checks for required dependencies (bun, neonctl, jq, docker, caddy)
- Installs npm/bun dependencies
- Creates a Neon database branch for the workspace
- Starts an Electric SQL Docker container
- Allocates unique ports for all services
- Writes a workspace-specific
.envfile - Sets up local MCP server configuration
- Seeds authentication tokens and local database
Teardown Scripts
Teardown scripts run when a workspace is deleted. They clean up resources.Basic Teardown Script
.superset/teardown.sh
Advanced Teardown Script
From the Superset repository:.superset/teardown.sh (Advanced)
- Stops and removes Electric SQL Docker container
- Deletes the Neon database branch
- Releases allocated ports
- Removes workspace-specific configuration files
Environment Variables
Superset provides these environment variables to setup/teardown scripts:| Variable | Description |
|---|---|
SUPERSET_WORKSPACE_NAME | Name of the workspace (e.g., fix-auth-bug) |
SUPERSET_ROOT_PATH | Absolute path to the main repository |
SUPERSET_PORT_BASE | Base port allocated for this workspace (e.g., 3000) |
PWD | Current workspace directory path |
Using Environment Variables
Common Setup Tasks
Installing Dependencies
Copying Environment Files
Creating Database Branches
Starting Docker Containers
Allocating Unique Ports
Common Teardown Tasks
Stopping Docker Containers
Deleting Database Branches
Cleaning Up Files
Testing Scripts
Test your setup script before committing:Create a Test Workspace
Use
⌘N to create a new workspace. Watch the setup script output in the terminal.Error Handling
Make your scripts robust with proper error handling:Best Practices
Make Scripts Idempotent
Scripts should work correctly when run multiple times. Check if resources already exist before creating them.
Use Exit Codes
Return
0 for success, non-zero for failure. Superset will show an error if setup fails.Provide Clear Output
Use
echo to show progress. Helps debug issues when scripts fail.Clean Up on Failure
Use
trap to clean up resources if setup fails halfway through.Test Thoroughly
Test both setup and teardown scripts before deploying to your team.
Document Dependencies
Add comments listing required CLI tools (bun, docker, neonctl, etc.).
Troubleshooting
Setup script fails silently
Setup script fails silently
If the script fails without showing errors:
- Add
set -eto exit on any error - Add
set -xto print commands as they execute - Check the terminal output in Superset
- Test the script manually:
./.superset/setup.sh
Environment variables not available
Environment variables not available
If
SUPERSET_WORKSPACE_NAME or SUPERSET_ROOT_PATH are empty:- Make sure you’re running the script through Superset, not manually
- Check that the script is configured in
.superset/config.json - Verify the config file is in the repository root
Dependencies not found
Dependencies not found
If commands like
bun or docker aren’t found:- Make sure they’re installed on your system
- Check that they’re in your PATH
- Try running the command manually first
- Add the full path to the binary (e.g.,
/usr/local/bin/docker)
Teardown leaves resources behind
Teardown leaves resources behind
If Docker containers or database branches aren’t cleaned up:
- Add error suppression:
command 2>/dev/null || true - Check resource names match what setup created
- Manually clean up:
docker ps -a,neonctl branches list - Test teardown script manually before deleting workspace
Example: Full Setup Script
Here’s a complete, production-ready setup script:.superset/setup.sh
Related Topics
Workspace Management
Learn how workspaces are created and deleted
Running Agents
Prepare environments for coding agents
Integrations
Connect to external services and tools