Skip to content

Unexpected file named "nul" is repeatedly created after updating OpenCode #11403

Closed as not planned

Description

@cyberprophet

Description

After updating to the latest version of OpenCode, I’m seeing an unexpected file named nul being created in my working directory.

-rw-rw-r--  1 jim jim   29 Jan 31 03:52 nul

This file keeps appearing even though I did not create it manually.

Plugins

oh-my-opencode

OpenCode version

v1.1.47

Steps to reproduce

No response

Screenshot and/or share link

Image

Operating System

Ubuntu-24.04

Terminal

Windows Terminal

Activity

  1. github-actions commented on Jan 31, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if your specific case differs from this one.

  2. cyberprophet commented on Jan 31, 2026

    @cyberprophet
    ContributorAuthor

    Thanks for the reference. I’ve checked #11330, but I believe my case is different.

    The linked issue appears to be Windows-specific and related to Bash redirection syntax leaking into PowerShell execution (nul being created as a side effect on Windows).

    In my case, this is happening on Linux (Ubuntu Server), accessed via SSH, with no PowerShell involved.
    The nul file is created directly on an ext4 filesystem after running the latest OpenCode version.

    Because nul is a Windows-specific device name, seeing it created as a regular file on Linux suggests a different cross-platform handling issue rather than the PowerShell redirection problem described in #11330.

    Happy to provide additional logs or a minimal repro if needed.

  3. JSCOP commented on Feb 25, 2026

    @JSCOP

    Why this issue not start to resolve?

  4. cyberprophet commented on Feb 26, 2026

    @cyberprophet
    ContributorAuthor

    I also hope this gets resolved as soon as possible.

  5. phate7 commented on Mar 9, 2026

    @phate7

    Still happening from time to time.

  6. tppawelgrzesik commented on Mar 19, 2026

    @tppawelgrzesik

    Still happening on OpenCode Desktop
    v1.2.27 on Windows 11 all the time

  7. HiddenDude commented on Mar 19, 2026

    @HiddenDude

    this seriously needs fixing. opencode created a "nul" file in my workspace root, which can't be removed. its automatically recreated after deletion in explorer even without opencode running..?

  8. sSANATGAR commented on Mar 20, 2026

    @sSANATGAR

    Using OpenCode v1.2.27 on Windows (PowerShell).

    The nul file that get created are very annoying. They interfere with my Git workflow — I can't stage all files at once and have to stage them one by one to avoid the nul file. On top of that, the nul file can only be deleted via cmd.

    Please fix this.

  9. filadog commented on Mar 27, 2026

    @filadog

    bump, still happening, on windows cli version with powershell

  10. dakujem commented on Mar 31, 2026

    @dakujem

    The desktop version too. Not sure if it is related to the model, I'm using mostly Sonnet model.

  11. cyberprophet commented on Mar 31, 2026

    @cyberprophet
    ContributorAuthor

    Hi maintainers,

    I submitted PR #15183 that fixes this issue for POSIX systems (Linux/macOS). It prevents the literal nul file creation during shell tool execution by sanitizing the redirect target.

    This issue has been open since January and continues to affect users across platforms (Linux, Windows, Desktop app) as recently as today. Could someone on the team review and merge the fix?

    Thanks!

  12. countzero commented on Apr 21, 2026

    @countzero

    Still happening on windows please fix.

  13. removed
    bugSomething isn't working
    on May 3, 2026
  14. alexbeewise commented on May 10, 2026

    @alexbeewise

    The key breakthrough: ProcMon

    The entire root cause analysis was done with AI's help, but the most important debugging tool was:

    Sysinternals Process Monitor (ProcMon)

    Instead of guessing whether the problem came from:

    • Git
    • pre-commit hooks
    • IDE plugins
    • Python scripts
    • PowerShell
    • filesystem corruption
    • antivirus

    I used ProcMon to identify the exact process creating the file.

    ProcMon setup

    1. Run ProcMon as Administrator
    2. Add these filters:
    Path contains C:\path\to\repo\NUL   Include
    Operation is CreateFile                Include
    
    1. Clear events (Ctrl+X)
    2. Open the IDE and reproduce the issue
    3. Stop capture (Ctrl+E)

    ProcMon immediately showed:

    Process: ssh.exe
    Operation: CreateFile
    Path: C:\repo\NUL
    Result: SUCCESS
    

    That narrowed the problem down instantly.


    Root cause

    After tracing the SSH configuration with:

    ssh -G github.com

    I discovered this bad configuration:

    Host *
        StrictHostKeyChecking no
        UserKnownHostsFile NUL

    That line caused ssh.exe to create a literal NUL file in the repo working directory when GitHub fetches or IDE Git integrations executed SSH commands.

    Git then failed because NUL is a reserved Windows filename.


    Correct fix

    I fixed the SSH config by removing the problematic global configuration and replacing it with properly scoped SSH rules.

    After that:

    • NUL stopped appearing
    • IDE startup no longer recreated the file
    • git add . worked normally again
    • GitHub SSH operations behaved correctly

    Important lesson

    If random files appear in your repo or working directory:

    • use ProcMon early
    • filter on CreateFile
    • identify the exact process touching the file

    Without ProcMon this could easily turn into hours of blind guessing.

    @cyberprophet

  15. github-actions commented on Jul 10, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 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

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions