You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Recent projects shows "/" when started in non-git directory #15719
When opencode is started in a directory that does not contain a git repository, the recent projects list displays / as the project path instead of the actual working directory.
Steps to reproduce
Start opencode in a directory without a .git folder (e.g. mkdir /tmp/test && cd /tmp/test && opencode)
Open the home page / recent projects view
The project path shows / instead of /tmp/test
Root cause
In packages/opencode/src/project/project.ts, Project.fromDirectory() walks up the directory tree looking for .git. When none is found, it falls back to hardcoded "/":
return{id: "global",worktree: "/",// should be `directory`sandbox: "/",// should be `directory`vcs: Info.shape.vcs.parse(Flag.OPENCODE_FAKE_VCS),}
The directory argument passed into fromDirectory is available but not used in this fallback path.
Expected behavior
Recent projects should display the actual working directory (e.g. ~/projects or /tmp/test), not /.
Environment
opencode version: v1.2.15+
OS: Linux (also reproducible on macOS)
Affects any non-git directory
Reacted by Alexey Volkov, stefaneidelloth, Jiehan Zheng and voidman
This issue might be a duplicate of (or closely related to) existing issues that share the same root cause in Project.fromDirectory() returning worktree: "/" for non-git directories. Please check:
Further, there's zero documentation as to where it starts; trying to run this in a Docker container without root permissions basically makes it useless as the only thing that pops up is '/':
# OpenCode Docker Image for server
FROM node:24-slim
# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive \
OPENCODE_SERVER_PORT=42005 \
OPENCODE_SERVER_HOSTNAME=0.0.0.0 \
OPENCODE_CONFIG_DIR=/opt/opencode/config \
PATH="/root/.opencode/bin:/root/.cargo/bin:/root/.local/bin:${PATH}"
# Install system dependencies
RUN apt-get update && apt-get install -y \
curl \
gnupg \
ca-certificates \
apt-transport-https \
lsb-release \
vim \
wget \
build-essential \
libreoffice \
libreoffice-gtk3 \
poppler-utils \
docker.io \
openssh-server \
&& rm -rf /var/lib/apt/lists/*
# Add Node.js repository
RUN mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
# Install nvm (Node Version Manager) and Node.js 24 with yarn
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
# Source nvm and install Node.js 24 + yarn
RUN . ~/.nvm/nvm.sh && \
nvm install 24 && \
nvm use 24 && \
npm install -g yarn
# Set up environment for nvm in container
ENV PATH="/root/.nvm/versions/node/v24*/bin:${PATH}:${PATH}"
# Get the GID of the host's docker group and create a matching group in container
RUN getent group docker || groupadd -g 1001 docker
# Install OpenSSH server again after docker.io (to avoid conflicts)
RUN apt-get update && \
apt-get install -y openssh-server && \
rm -rf /var/lib/apt/lists/*
# Create SSH directory for root user and set permissions
RUN mkdir -p /root/.ssh && \
chmod 700 /root/.ssh && \
chown root:root /root/.ssh
# Set default password for root user (for SSH access)
RUN echo "root:adO1Zh7CAjUhh1" | chpasswd
# Configure SSH daemon to run on port 42004
RUN sed -i 's/#Port 22/Port 42004/' /etc/ssh/sshd_config && \
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin no/' /etc/ssh/sshd_config && \
echo "UsePAM yes" >> /etc/ssh/sshd_config
# Expose SSH port
EXPOSE 42004
# Install Rust toolchain
RUN curl -sSf https://sh.rustup.rs --output rustup-init && \
sh rustup-init -y && \
rm rustup-init && \
. /root/.cargo/env && \
rustup component add rustfmt clippy
# Install OpenCode from official source
RUN curl -fsSL https://opencode.ai/install | bash
# Create config directory for OpenCode configuration files
RUN mkdir -p ${OPENCODE_CONFIG_DIR}
# Create a working directory
WORKDIR /workspace
# Expose the OpenCode port
EXPOSE 42005
# Set up volume for config files
VOLUME ${OPENCODE_CONFIG_DIR}
# Set up volume for workspace
VOLUME /workspace
RUN apt-get update \
&& apt-get install -y \
nano \
&& rm -rf /var/lib/apt/lists/*
USER node
# Default command - start the opencode server
ENTRYPOINT ["opencode", "serve", "--hostname", "0.0.0.0", "--port", "42005"]
One would think it should serve /workspace as the working directory; or at least /home/node since it was started by the user node; it doesn't appear to have permissions or anything and lives in root.
I'm having a similar issue but with an extra step.
If I start a chat in a directory without a git repo being initialized, it effectively shows all global sessions, but if after just doing opencode within that directory, no starting chats required, and I then start a git repo, it stays within that global context, there's no opt-in (or at least I couldn't find a way to do so in the docs) so this newly started git repo can have its own sessions.
Activity
github-actions commentedon Mar 2, 2026
This issue might be a duplicate of (or closely related to) existing issues that share the same root cause in
Project.fromDirectory()returningworktree: "/"for non-git directories. Please check:worktree: "/"fallback inproject.tsas the root causeopencode serveuses/as base directory when started from a non-root path — same incorrectworktreevalue causes the file browser to show root instead of the actual working directoryworktree="/") can show empty sidebar even when/sessionAPI returns sessions #14572: Global project (worktree="/") can show empty sidebar even when sessions exist — same fallback causes session/project scoping issuesdisarticulate commentedon Mar 21, 2026
Further, there's zero documentation as to where it starts; trying to run this in a Docker container without root permissions basically makes it useless as the only thing that pops up is '/':
One would think it should serve
/workspaceas the working directory; or at least/home/nodesince it was started by the usernode; it doesn't appear to have permissions or anything and lives in root.gitrequests commentedon Mar 22, 2026
Related issue: #14656
sergio-asenjo commentedon Mar 24, 2026
I'm having a similar issue but with an extra step.
If I start a chat in a directory without a git repo being initialized, it effectively shows all global sessions, but if after just doing
opencodewithin that directory, no starting chats required, and I then start a git repo, it stays within that global context, there's no opt-in (or at least I couldn't find a way to do so in the docs) so this newly started git repo can have its own sessions.github-actions commentedon Jul 3, 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.