OpenCode: OpenCode Installation

Last updated: 2026-08-31

OpenCode supports multi-platform installation. The one-click script is recommended for quick setup.

1. What You Will Learn


2. System Requirements

(1) Operating Systems

OS Support
macOS ✅ Fully supported
Linux ✅ Fully supported
Windows ⚠️ WSL recommended

(2) Terminal Tools

A modern terminal is recommended for the best experience:

Terminal Platform Notes
WezTerm Cross-platform Recommended
Alacritty Cross-platform Excellent performance
Ghostty Linux/macOS Emerging choice
Kitty Linux/macOS GPU accelerated

(3) API Key

OpenCode doesn't include models—you need to configure an AI provider:


For macOS / Linux / WSL:

BASH
curl -fsSL https://opencode.ai/install | bash

After installation, navigate to your project and start:

BASH
cd <project>
opencode

4. Node.js Installation

If you're familiar with Node.js:

BASH
npm install -g opencode-ai

Or with pnpm:

BASH
pnpm install -g opencode-ai

Or with yarn:

BASH
yarn global add opencode-ai

5. Platform-Specific Installation

(1) macOS (Homebrew)

BASH
brew install anomalyco/tap/opencode

The official tap is recommended for faster updates. brew install opencode updates more slowly.

(2) Windows

WSL is recommended for stability and full feature support.

Other methods:

BASH
# Chocolatey
choco install opencode

# Scoop
scoop install opencode

# NPM
npm install -g opencode-ai

# Mise
mise use -g github:anomalyco/opencode

# Docker
docker run -it --rm ghcr.io/anomalyco/opencode

You can also download binaries directly from the GitHub Releases page.

(3) Linux

BASH
# Universal method (recommended)
curl -fsSL https://opencode.ai/install | bash

# Arch Linux
sudo pacman -S opencode
# or
paru -S opencode-bin

# Docker
docker run -it --rm ghcr.io/anomalyco/opencode

6. Verify Installation

BASH
opencode --version

Output similar to the following indicates success:

TEXT 📖 Display only
1.1.50

7. Start OpenCode

BASH
opencode

If you encounter EACCES: permission denied, fix directory permissions:

BASH
sudo chown -R $(whoami) ~/.local
chmod -R 755 ~/.local

8. Permission Troubleshooting

Issue Solution
EACCES: permission denied sudo chown -R $(whoami) ~/.local
command not found Check if PATH includes the installation directory
Version too old Run opencode upgrade

❓ FAQ

Q Windows native or WSL?
A WSL is recommended. Windows native has limited feature support, while WSL provides a complete Linux experience with better OpenCode compatibility.
Q command not found after installation?
A This is usually a PATH issue. Run npm prefix -g to find the global installation path, then add its bin directory to PATH.
Q Alice installs on macOS, Bob on Windows—who has an easier time?
A Alice. macOS has native support with a single command. Bob needs to install WSL first. Bob should prioritize WSL.
Q What are Docker installation limitations?
A Docker runs in a container and can't access host project files by default. Mount the project directory with -v: docker run -it --rm -v $(pwd):/workspace ghcr.io/anomalyco/opencode.

📖 Summary


📝 Exercises

  1. Basic: Install OpenCode on your OS and verify the version number.

  2. Intermediate: Try two different installation methods and compare their pros and cons.

  3. Advanced: Run OpenCode in Docker with a mounted local project directory.

Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏