Repository navigation
Description
Description
Summary
I observed that a plugin which works in OpenCode CLI can fail or behave differently in OpenCode Desktop.
During investigation, I found that in Desktop:
- a plugin bundle using
import.meta.requirefailed to load - a plugin that reads its API key only from shell environment variables could not access that key
- a plugin that derives project identity from
gitcommands andprocess.cwd()resolved a different project identity than expected
The same repositories behaved correctly in CLI mode.
I am reporting this here because the behavior appears specifically related to OpenCode Desktop runtime and Desktop instance/project context.
Environment
- OS: Linux (Ubuntu GNOME / Wayland)
- OpenCode CLI: works as expected
- OpenCode Desktop: different behavior observed
Example repositories:
/home/zhusinian/Code/yishu_projects/soms/home/zhusinian/Code/yishu_projects/soms_analysis_go
Observed behavior in Desktop
Desktop logs show that OpenCode creates a user-level/global instance such as:
creating instance directory=/home/zhusinian
fromDirectory directory=/home/zhusinian
bootstrapping directory=/home/zhusinian
Desktop also creates project instances, for example:
creating instance directory=/home/zhusinian/Code/yishu_projects/soms
fromDirectory directory=/home/zhusinian/Code/yishu_projects/soms
bootstrapping directory=/home/zhusinian/Code/yishu_projects/soms
and:
creating instance directory=/home/zhusinian/Code/yishu_projects/soms_analysis_go
fromDirectory directory=/home/zhusinian/Code/yishu_projects/soms_analysis_go
bootstrapping directory=/home/zhusinian/Code/yishu_projects/soms_analysis_go
Observed difference 1: bundle loading
A published plugin bundle failed to load in Desktop with:
failed to load plugin
error=__require is not a function
The bundle contained:
var __require = import.meta.require;Observed difference 2: environment variable access
A plugin that reads its API key from:
process.env.MEM0_API_KEYworked in CLI but did not obtain that value in Desktop.
Desktop logs showed:
MEM0_API_KEY environment variable not set. Get one at https://app.mem0.ai/dashboard/api-keys
Observed difference 3: project identity resolution
A plugin computed project identity once during initialization using logic like:
async function getProjectId($) {
if (process.env.MEM0_APP_ID) return process.env.MEM0_APP_ID;
try {
const r = await $`git remote get-url origin`.quiet();
const project = parseProjectFromRemote(r.stdout.toString());
if (project) return project;
} catch {}
try {
const r = await $`git rev-parse --show-toplevel`.quiet();
const top = r.stdout.toString().trim();
if (top) return basename(top);
} catch {}
return basename(process.cwd());
}In CLI, this resolved the expected project identity.
In Desktop, the resolved project identity differed from the active repository context.
Why I am reporting this to OpenCode
The same plugin logic behaves differently between CLI and Desktop.
From observation, Desktop includes:
- a user-level/global instance
- project instances
- a runtime context that differs from a shell-launched CLI process
Because of this, behavior based on:
process.cwd()- shell environment variables
- runtime-specific module loading assumptions
can differ between CLI and Desktop.
Minimal evidence
Desktop user-level/global instance
creating instance directory=/home/zhusinian
fromDirectory directory=/home/zhusinian
bootstrapping directory=/home/zhusinian
Desktop project instance
creating instance directory=/home/zhusinian/Code/yishu_projects/soms_analysis_go
fromDirectory directory=/home/zhusinian/Code/yishu_projects/soms_analysis_go
bootstrapping directory=/home/zhusinian/Code/yishu_projects/soms_analysis_go
Desktop bundle load failure
failed to load plugin
error=__require is not a function
Desktop environment variable access failure
MEM0_API_KEY environment variable not set. Get one at https://app.mem0.ai/dashboard/api-keys
Expected outcome
I am sharing these observations so the Desktop plugin runtime behavior and plugin author expectations can be clarified.
The main point is that the same plugin logic behaves differently in CLI and Desktop with respect to:
- module loading
- environment variable access
- project identity resolution
Plugins
mem0
OpenCode version
OpenCode Desktop v1.17.11
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response
Activity
github-actions commentedon Jun 30, 2026
This issue might be a duplicate of existing issues. Please check:
github-actions commentedon Aug 30, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.