Skip to content

ElixirLS uses git root instead of opened Mix app in Elixir monorepos #17208

@0xSSDD

Description

@0xSSDD

Description

Problem

When OpenCode is started in a nested Elixir app inside a git monorepo, ElixirLS appears to attach to the git root instead of the opened app root.

That breaks Elixir navigation in the subproject:

  • document-symbols returns [] for valid .ex files
  • some runs time out during ElixirLS initialize
  • sessions keep the correct directory, but the resolved project root stays the monorepo root

Why this looks like the root cause

I started OpenCode in a nested Mix app:

opencode /path/to/monorepo/apps/example_app

But the local API still resolves the current project to the git root:

curl -s http://127.0.0.1:4099/project/current
{
  "id": "<project-id>",
  "worktree": "/path/to/monorepo",
  "vcs": "git"
}

At the same time, sessions keep the nested app as their directory:

curl -s 'http://127.0.0.1:4099/experimental/session?directory=/path/to/monorepo/apps/example_app&roots=true'

Example response shape:

{
  "directory": "/path/to/monorepo/apps/example_app",
  "project": {
    "worktree": "/path/to/monorepo"
  }
}

So OpenCode distinguishes directory from project.worktree, but ElixirLS appears to follow the git-root project.

Expected behavior

If I open:

opencode /path/to/monorepo/apps/example_app

then ElixirLS should attach to:

/path/to/monorepo/apps/example_app

or at least to the nearest ancestor containing mix.exs, not to:

/path/to/monorepo

Actual behavior

For valid Elixir files inside the nested app:

opencode debug lsp document-symbols file:///path/to/monorepo/apps/example_app/lib/example_app/application.ex

returns:

[]

And:

opencode debug lsp diagnostics /path/to/monorepo/apps/example_app/lib/example_app/application.ex

returns:

{
  "/path/to/monorepo/apps/example_app/lib/example_app/application.ex": []
}

Environment

  • OpenCode 1.2.24
  • macOS
  • Elixir 1.15.6-otp-26
  • Erlang 26.1.2

Notes

The nested app itself is valid:

  • it has its own mix.exs
  • it has its own .tool-versions
  • it already has .elixir_ls/

This looks like an OpenCode workspace/project-root issue rather than an ElixirLS project setup issue.

Plugins

No response

OpenCode version

1.2.24

Steps to reproduce

Minimal reproduction

Repo shape:

  • /path/to/monorepo/.git
  • /path/to/monorepo/apps/example_app/mix.exs

Commands:

opencode /path/to/monorepo/apps/example_app
opencode debug lsp document-symbols file:///path/to/monorepo/apps/example_app/lib/example_app/application.ex

Screenshot and/or share link

No response

Operating System

macOS

Terminal

cmux

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