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
Unignoring the .gitignore with .ignore should allow reading the file #4739
I'm working on a reproduction of a bug, and created a dummy .env file that was ignored by .gitignore (config from Next.js).
I added the file to .ignore as:
!.env
Now the file is visible in OpenCode. I can select it, but the Agent is not allowed to read that file. I think that it's a bug if I unignore I want the agent to read the file, not only allow to find its name on the file system.
This appears to be related to the same underlying issue where OpenCode doesn't properly respect .gitignore patterns. In #4694, glob tool doesn't honor .gitignore rules (showing .tfvars files even though they're ignored), while in this issue, unignoring a file with ! syntax allows it to be visible but the agent can't read it.
Feel free to ignore if this doesn't address your specific case.
afaik .env is kinda hardcoded as ignore pattern for the read tool (with exemption for .env.example) and .gitignore contents aren't considered..
the .ignore appears to be something ripgrep specific (a ripgrep feature) which is used in tools like grep etc. i guess the docs could be more specific here
(pretty amazing to be able to tell opencode to checkout the opencode code and analyze it's own code.. (insert xzibit meme here))
Then it should not appear when you type @, it's confusing that you can mention that file, but the Agent can't read it.
Also, this file is only used by JavaScript. IMHO, generic Agent should not ignore random files only by one technology. To remove .env there should be a default config file with list of files that are always ignored and away to change that file.
Just my 2c but id like there to be a .llmignore or such, just in case I wanted to explicitly tell the tool that I don't want something to ever be read, even if its not in .gitignore or .ignore.
.ignore is great for being picked up by most tools such as rg and the like, but sometimes you want to target the specific tool set.
Activity
github-actions commentedon Nov 25, 2025
This issue might be a duplicate of existing issues. Please check:
This appears to be related to the same underlying issue where OpenCode doesn't properly respect .gitignore patterns. In #4694, glob tool doesn't honor .gitignore rules (showing .tfvars files even though they're ignored), while in this issue, unignoring a file with
!syntax allows it to be visible but the agent can't read it.Feel free to ignore if this doesn't address your specific case.
brechr commentedon Nov 25, 2025
afaik .env is kinda hardcoded as ignore pattern for the read tool (with exemption for .env.example) and .gitignore contents aren't considered..
the .ignore appears to be something ripgrep specific (a ripgrep feature) which is used in tools like grep etc. i guess the docs could be more specific here
(pretty amazing to be able to tell opencode to checkout the opencode code and analyze it's own code.. (insert xzibit meme here))
jcubic commentedon Nov 25, 2025
Then it should not appear when you type
@, it's confusing that you can mention that file, but the Agent can't read it.Also, this file is only used by JavaScript. IMHO, generic Agent should not ignore random files only by one technology. To remove
.envthere should be a default config file with list of files that are always ignored and away to change that file.rekram1-node commentedon Nov 25, 2025
Lol thats a good point, ill take a look
rekram1-node commentedon Nov 25, 2025
We wanna make it configurable I just blacklisted env for safety but that's a good point
fix: allow unignoring files in .ignore
fix: allow unignoring files in .ignore
brandtcormorant commentedon Feb 12, 2026
I opened a pr that resolves this: #12876
I've made a local build and been testing it for a couple days and it's working great.
jcubic commentedon Feb 12, 2026
I'm not sure if this is needed anymore.
OpenCode now ask you for permission to read
.envfile.@rekram1-node For me this can be closed.
boyter commentedon Feb 13, 2026
Just my 2c but id like there to be a
.llmignoreor such, just in case I wanted to explicitly tell the tool that I don't want something to ever be read, even if its not in.gitignoreor.ignore..ignoreis great for being picked up by most tools such asrgand the like, but sometimes you want to target the specific tool set.github-actions commentedon Apr 14, 2026
To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.