Skip to content

Instantly share code, notes, and snippets.

@simbo1905
Last active January 29, 2026 12:50
Show Gist options
  • Select an option

  • Save simbo1905/79f40c5621b8ec7670d16a1dfe4b035e to your computer and use it in GitHub Desktop.

Select an option

Save simbo1905/79f40c5621b8ec7670d16a1dfe4b035e to your computer and use it in GitHub Desktop.

OpenCode Desktop v1.1 on Windows 11 with custom MSYS2 install in user folder

Prerequisites

Download and install MSYS2 into C:\Users\UserName\MSYS2. Confirm the installation has msys2.exe, ucrt64.exe, and other shell variants present. Open msys2.exe directly and run pacman -S git to verify pacman works and git installs correctly. Verify you can use both tools in the shell before proceeding.

Locate your OpenCode v1.1 installation. Find OpenCode.exe at a path like C:\Users\UserName\AppData\Local\OpenCode\OpenCode.exe. Confirm opencode-cli.exe is also present in the same directory. Test the CLI by running opencode-cli.exe web to ensure it boots correctly.

Shut down OpenCode. Close the web interface and any running OpenCode processes.

Setup: Running OpenCode CLI with MSYS2 environment

Step 1: Start the OpenCode CLI server with MSYS2 environment variables

Open PowerShell and run:

$ENV:MSYSTEM = "MSYS"
$ENV:OPENCODE_GIT_BASH_PATH = "C:\Users\UserName\MSYS2\usr\bin\bash.exe"
$ENV:SHELL = "C:\Users\UserName\MSYS2\usr\bin\bash.exe"
& "C:\Users\UserName\AppData\Local\OpenCode\opencode-cli.exe" serve --port 8193

Leave this PowerShell window open. The server is now running on port 8193 with MSYS2 bash as the default shell.

Step 2: Start the OpenCode Desktop client

Open a new PowerShell window and run:

& "C:\Users\UserName\AppData\Local\OpenCode\OpenCode.exe" --connect localhost:8193

The Desktop app will launch and connect to your MSYS2-backed server.

Step 3: Configure the Desktop app to use the correct server

If the Desktop app previously connected to the built-in server, it may ignore your new server connection. Click Status at the top of the OpenCode Desktop window. Click Manage Servers. Select and configure the server details for localhost:8193. Confirm the connection is active. Later on when you are sure things all work you use the Manage Servers button in the Status area and set the new server as the default one and/or delete older servers.

Step 4: Fix the MSYS PATH issue

When you first run bash commands in OpenCode, you may notice make and other tools installed in MSYS2 are not found because the Windows PATH is being used instead of the MSYS PATH. Fix this by creating a proper .bashrc in your MSYS2 home directory.

In OpenCode's bash tool, run:

cat > ~/.bashrc << 'BASHRC'
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH"
BASHRC

Source the profile:

source ~/.bashrc

Verify tools are now accessible:

which make
make --version
echo $MSYSTEM

You should see make located at /usr/bin/make, version 4.4.1 (or your installed version), and $MSYSTEM prints MSYS.

Notes

Keep the CLI server window open while using the Desktop app. This is your connection to the MSYS2-backed shell environment. The environment variables (MSYSTEM, OPENCODE_GIT_BASH_PATH, SHELL) are only active in that PowerShell window and inherited by the sidecar processes it spawns. If you close the server window, the Desktop app will lose its connection; restart both windows. This setup avoids the Windows Start Menu shortcut limitation (which cannot pass custom environment variables) by explicitly running the server with the correct environment.

Troubleshooting

Problem: Desktop app says server unavailable. Ensure the CLI server PowerShell window is still open and shows no errors. Verify the port 8193 is not in use by another process.

Problem: $MSYSTEM shows MINGW64 instead of MSYS. The $ENV:MSYSTEM = "MSYS" line in the server startup was skipped or not set. Re-run the server startup command exactly as shown, including all three environment variable lines.

Problem: Tools like make still not found after .bashrc update. Verify .bashrc was created: run cat ~/.bashrc and confirm the PATH export is there. Run source ~/.bashrc again to reload it. Check /usr/bin/make exists: ls -l /usr/bin/make.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment