Skip to content

[regression] opencode 1.2.21 freezes on session start if the current working directory is a symlink #16522

@smola

Description

@smola

Description

The following code fixed it for me:

--- a/packages/opencode/src/cli/cmd/tui/thread.ts
+++ b/packages/opencode/src/cli/cmd/tui/thread.ts
@@ -120,11 +120,14 @@ export const TuiThreadCommand = cmd({
         return
       }

-      // Resolve relative paths against PWD to preserve behavior when using --cwd flag
+      // Use PWD as the base for resolving relative --project paths so that
+      // symlink-aware shells see the right directory. For the no-project case,
+      // use the real OS cwd so that Instance.directory always matches the
+      // canonical path that git and other tools report.
       const root = Filesystem.resolve(process.env.PWD ?? process.cwd())
       const cwd = args.project
         ? Filesystem.resolve(path.isAbsolute(args.project) ? args.project : path.join(root, args.project))
-        : root
+        : Filesystem.resolve(process.cwd())
       const file = await target()
       try {
         process.chdir(cwd)

Plugins

No response

OpenCode version

1.2.21

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

Linux, Ubuntu 24.04

Terminal

Ghostty

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions