Skip to main content

Development Environment Setup

This guide will help you set up your development environment for contributing to Qwen Code.

Prerequisites

Required

  1. Node.js
    • Development: Use Node.js ~20.19.0 (specific version required due to upstream dependency issue)
    • Production: Any version >=20.0.0 works for running the CLI
    • Recommended: Use nvm to manage Node.js versions
  2. Git
    • For version control and repository management
  1. Docker or Podman
    • For sandboxing feature (optional but recommended for security)
    • Enables isolated code execution
  2. VS Code
    • Recommended IDE with excellent TypeScript support
    • Pre-configured launch configurations included

Initial Setup

1. Clone the Repository

2. Install Node.js (if needed)

Using nvm (recommended):

3. Install Dependencies

This will install dependencies for all packages in the monorepo.

Build Process

Basic Build

Build all packages:
This compiles TypeScript to JavaScript and prepares packages for execution.

Full Build (with Sandbox)

To build everything including the sandbox container:
This builds:
  • All packages
  • Sandbox Docker container
  • VS Code companion extension

Build Individual Packages

Development Mode

For faster development with hot reload:
This watches for file changes and automatically rebuilds.

Running Qwen Code

From Source

After building, run from the source directory:
To use qwen-code command from anywhere:

With Debug Mode

Run with debugging enabled:

Testing

Unit Tests

Run all unit tests:
Run tests for a specific package:

Integration Tests

Run integration tests without sandbox:
Run with different sandbox modes:

Test Coverage

Generate coverage reports:

Code Quality

Linting

Run ESLint:

Formatting

Format code with Prettier:

Type Checking

Run TypeScript type checker:

Preflight Checks

Run all checks before submitting a PR:
This runs:
  1. Clean build artifacts
  2. Fresh install of dependencies
  3. Code formatting check
  4. Linting (CI mode)
  5. Full build
  6. Type checking
  7. All tests

Sandboxing Setup

Sandboxing is highly recommended for security and requires additional setup.

Enable Sandboxing

Set the environment variable:

Docker Setup

If using Docker:

Podman Setup

If using Podman:

Sandbox Providers

Supported sandbox providers:
  • docker - Docker Desktop (recommended for most users)
  • podman - Podman (alternative to Docker)
  • macOS Seatbelt - macOS native sandboxing
  • false - Disable sandboxing (not recommended)

Development Tools

VS Code Setup

The project includes pre-configured VS Code settings:
  1. Launch Configurations (.vscode/launch.json):
    • F5 - Start with debugger attached
    • “Attach” - Attach to running debug session
    • “Launch Program” - Debug current file
  2. Recommended Extensions:
    • ESLint
    • Prettier
    • TypeScript and JavaScript Language Features
  3. Debugger Usage:

React DevTools

For debugging the CLI’s React UI:
The CLI will automatically connect to React DevTools.

Environment Configuration

Environment Variables

Key environment variables for development:

Configuration Files

Configuration hierarchy:
  1. Project settings: .qwen/settings.json (project-specific)
  2. User settings: ~/.qwen/settings.json (global)
  3. Environment variables: Override any setting
  4. CLI arguments: Highest priority

Troubleshooting

Common Issues

Node Version Mismatch

Build Failures

Test Failures

Permission Errors (Docker)

Import Resolution Errors

Getting Help

If you encounter issues:
  1. Check existing issues
  2. Review the documentation
  3. Ask in discussions
  4. Open a new issue with:
    • Node.js version (node --version)
    • npm version (npm --version)
    • OS and version
    • Error messages and stack traces

Next Steps

Now that your environment is set up: