Skip to content

Unignoring the .gitignore with .ignore should allow reading the file #4739

Closed

Description

@jcubic

Description

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.

OpenCode version

1.0.110

Operating System

Fedora 43

Terminal

Xfce Terminal (VTE)

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Nov 25, 2025
  2. github-actions commented on Nov 25, 2025

    @github-actions
    Contributor

    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.

  3. brechr commented on Nov 25, 2025

    @brechr

    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))

  4. jcubic commented on Nov 25, 2025

    @jcubic
    Author

    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.

  5. rekram1-node commented on Nov 25, 2025

    @rekram1-node
    Contributor

    Lol thats a good point, ill take a look

  6. self-assigned this
    on Nov 25, 2025
  7. rekram1-node commented on Nov 25, 2025

    @rekram1-node
    Contributor

    We wanna make it configurable I just blacklisted env for safety but that's a good point

  8. added a commit that references this issue on Nov 27, 2025
    1442792
  9. added a commit that references this issue on Jan 2, 2026
    611663b
  10. brandtcormorant commented on Feb 12, 2026

    @brandtcormorant

    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.

  11. jcubic commented on Feb 12, 2026

    @jcubic
    Author

    I'm not sure if this is needed anymore.

    OpenCode now ask you for permission to read .env file.

    @rekram1-node For me this can be closed.

  12. boyter commented on Feb 13, 2026

    @boyter

    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.

  13. github-actions commented on Apr 14, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingopentuiThis relates to changes in v1.0, now that opencode uses opentui

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions