Codegen lets you configure custom setup commands that run once when initializing a repository’s sandbox environment. The resulting file system snapshot serves as the starting point for all future agent runs, ensuring consistency.
The most common use cases for setup commands is installing dependencies, e.g.
npm install
Codegen sandboxes are built on a custom Docker image that provides a comprehensive development environment. For detailed information about the base image, including the complete Dockerfile and available tools, see the Base Image documentation.
You will be taken to the repository’s settings page. The setup commands can be found at a URL similar to https://www.codegen.com/repos/{arepo_name}/setup-commands
Enter your desired setup commands in the provided text area, with one command per line. These commands will be executed in sequence within the sandbox environment.For example, you might want to:
Switch to a specific Node.js version.
Install project dependencies.
Run any necessary build steps or pre-compilation tasks.
After the commands are executed successfully, Codegen takes a snapshot of the sandbox’s file system. This snapshot then serves as the base environment for future agent interactions with this repository, meaning your setup commands don’t need to be re-run every time, saving time and ensuring consistency.
Here are a few common use cases for setup commands:
Copy
Ask AI
# Switch to Node.js version 20nvm use 20# Install npm dependenciesnpm install
Copy
Ask AI
# Setup with specific Python version for compatibilitypyenv install 3.12.0pyenv local 3.12.0python -m venv venvsource venv/bin/activatepip install -r requirements.txt
Copy
Ask AI
# Or a combination of commandsnvm use 18npm cinpm run build
The sandbox comes with Python 3.13 by default, but some packages may not yet be compatible with this version. Here are strategies for handling different Python versions:
If you need to work with a different Python version, you can install and use pyenv:
Copy
Ask AI
# Install pyenvcurl https://pyenv.run | bash# Add pyenv to PATH (for current session)export PATH="$HOME/.pyenv/bin:$PATH"eval "$(pyenv init -)"eval "$(pyenv virtualenv-init -)"# Install Python 3.12 (or your desired version)pyenv install 3.12.0# Set Python 3.12 as the local version for your projectpyenv local 3.12.0# Create a virtual environment with Python 3.12python -m venv venvsource venv/bin/activate# Install your dependenciespip install -r requirements.txt
When working with packages that require older Python versions:
Copy
Ask AI
# Create a virtual environment with a specific Python versionpython3.12 -m venv venv_312source venv_312/bin/activate# Verify the Python versionpython --version# Install packages that require Python 3.12pip install argis==2.4.0 # Example package that needs older Python# Deactivate when donedeactivate
Remember to activate your virtual environment in your setup commands if you need specific Python versions for your project dependencies.
Ensure your setup commands are non-interactive and can run to completion
without user input.
The environment variables listed in the “Env Variables” section are available
during the execution of these setup commands.