OpenAI Codex Cannot Access Project Files
When Codex can’t see your project files, the problem is usually the attached folder, missing workspace indexing, or a permission or visibility limit in your environment. The safest first fixes are to confirm the project root, refresh the workspace, and make sure the file is actually inside the connected project. If those checks do not help, you’re probably dealing with hidden files, symlinks, monorepo boundaries, a remote repo setup, or a folder that Codex does not index cleanly.
Symptom
Codex cannot find the file you can see locally, or it answers as if only part of the workspace exists.This usually shows up when you ask Codex about a file that is clearly present in the project, but it says the file is missing, ignores folders deeper in the tree, or only seems to know a few top-level files. In some setups, the exact message varies; the pattern is that Codex is not seeing the same workspace you are.
Before you start
This applies to OpenAI Codex in a connected project, browser-based workspace, local CLI setup, or remote repo environment where Codex is supposed to read local files.
- You do not need Administrator or
sudofor the first checks. - No backup is required for the first steps.
- A reload or reconnect is safe and reversible.
- First, confirm the file exists on disk where you expect it.
- Then check that Codex is attached to the same root folder, not just a parent or sibling folder.
What it usually means when Codex can’t see your files
Most of the time, Codex is not reading the same folder you think it is. The attached workspace may point at a parent folder, a sibling folder, or only part of a repo, so the file you expect is outside the area Codex can inspect.
Another common cause is indexing. Some environments need a fresh scan before Codex can answer from local files, and until that finishes it may only know a small slice of the tree or none of it. In other cases, the file is there but blocked by permissions, ignored paths, hidden-folder rules, symlinks, or size limits.
The symptom is usually one of these: Codex says it cannot find a file that you can clearly see, it answers as if only a few files exist, or it ignores folders deeper in the tree. That points to a workspace scope issue more often than a code problem.
When this problem applies and when it doesn’t
If you are using a browser-based workspace or a connected project, the problem is usually attachment, scope, or indexing. If you are using a CLI or agent setup, the problem may be the current working directory, a missing repo checkout, or a permissions rule in the local environment.
This article applies when Codex is supposed to read project files from a connected workspace and cannot. It does not apply to unrelated code errors, prompt quality problems, or cases where the file never existed in the connected folder.
Before you change anything:
- Check that the file really exists in the folder Codex is attached to.
- Check whether the environment uses a hidden-files rule, a remote repo boundary, or a partial index.
- Keep the first pass to safe checks only; no resets, reinstalls, or deletions yet.
Check the project root first
Start by confirming that Codex is attached to the real project root. This is the most common fix, especially in nested projects where the visible folder structure looks right but the connected root is one level too high or too low.
- Open the workspace root and compare it with the folder you use for builds, tests, and version control.
- Check whether Codex is attached to the same folder, not a parent, sibling, or one subfolder too deep.
- Test a known file from that root before you assume the index is broken.
pwd
lsExpected result: the path shown by pwd matches the project root you meant to connect, and ls shows the files you expect at that level.
If the root is wrong, Codex will not see files outside that boundary no matter how many times you ask. In a monorepo, the correct root may be the repo root, not a package folder. In a nested repo, it may be the inner repository, not the outer workspace.
Refresh or reattach the workspace
If the root is correct, refresh the workspace so Codex can re-scan what is attached. This is the safest next step when the workspace opened before files finished loading, after a branch switch, or after the tree changed.
- Use the refresh, reload, or reconnect action in your environment.
- If your tool supports it, reattach the project instead of changing settings by hand.
- After the workspace comes back, check whether the same file is now visible.
Project settings > Workspace > Refresh indexExpected result: the workspace reloads and the file tree or index updates.
If nothing changes, the problem is probably not stale state. At that point, scope, permissions, ignored paths, or a feature limit in your environment is a better place to look.
Make sure the file is readable and in scope
Even when the folder is attached, Codex may still skip a file if the file is not readable in that environment. Check the obvious blockers first: file permissions, hidden paths, ignore rules, symlinks, and very large or generated folders.
Hidden files such as .env, .gitignore, or files inside dot-directories may be treated differently depending on the product and policy. If the file is private or sensitive, some environments intentionally restrict access. Symlinks can also confuse indexing if they point outside the workspace or into a location the tool does not follow.
Large generated directories are another common issue. Folders like dist, build, vendor, node_modules, coverage output, logs, and cache folders may be skipped or partially indexed. If the file lives there, move the source of truth to a normal source folder if possible.
If you have local shell access, confirm the file is readable and located where you think it is. The exact command depends on your system, but the goal is simple: verify the file exists, has the right permissions, and is not being excluded by your tool’s own ignore rules. If Codex still cannot see it afterward, the issue is probably not the file itself but a workspace rule or indexing limit.
How to confirm the fix worked
Use one file you already know should be visible, then ask Codex something that forces it to read that file rather than guess from context.
- Pick a small, stable file in the attached project root, such as
README.mdor a source file with one clear function. - Ask Codex to quote a specific line or summarize one named function from that file.
- Compare the answer with the file contents you can see locally.
For example, ask: Open src/app.ts and quote the first line of the main function. If the file is visible, Codex should either quote the correct line or explain the relevant content accurately.
Expected result:
- It names the file correctly.
- It returns text that matches the file.
- It does not say the file is missing or unknown.
If it still cannot find a file you know is attached, the fix has not taken effect. Go back to the root, refresh, and visibility checks before changing anything else.
If your repo is a monorepo or uses nested folders
Monorepos often confuse file visibility because Codex may treat one package folder as the practical boundary even when the larger repo contains many packages. That means a file inside packages/web may be visible while a file in packages/api is not, especially if only part of the tree was attached or indexed.
If you work in a monorepo, attach the repo root first and then test a file from each package you need. If one package is visible and another is not, check whether the workspace has package-level boundaries, size limits, or a partial index.
Nested folders can also hide the real root. For example, if you opened repo/apps/web, Codex may not see shared code in repo/packages/shared. In that case, open repo instead, or attach both relevant roots if your environment supports that.
When the file you need lives deeper in the structure, the fix is usually to widen the connected root, not to force the model to guess. If your environment supports a file tree or folder picker, use it to confirm the boundary before asking for code help.
What to do when the file exists but still doesn’t show up
If the file exists on disk and should be in scope, but Codex still misses it, you are probably dealing with stale indexing, a rename, unsupported path rules, or cached state.
Start with the simplest checks:
- Make sure the file was not renamed after the workspace opened.
- Confirm you are asking for the current path, not an old one.
- Check whether the file sits under an ignored or generated directory.
- Reopen the workspace after any branch switch or mass file move.
If the file was recently created, give the workspace a moment to index it, then ask again. If the file was renamed, ask using the new path and avoid relying on old references. If the file is in an unusual path, such as one with a symlink or a mounted remote folder, move a test copy into a normal source directory and try again.
When a real file stays invisible after those checks, the issue is usually in the environment rather than the codebase. That is the point to inspect workspace settings or contact whoever manages the Codex setup you are using.
How to prevent this next time
The easiest prevention is to attach the right root before you ask Codex to inspect code. If you often work in nested repos or monorepos, open the top-level project folder you actually build from, not just a subfolder that happened to be convenient.
A few habits reduce surprises:
- Keep source code in normal tracked folders, not in generated output directories.
- Avoid relying on symlinks for core project files.
- Check visibility after branch changes or folder moves.
- Use a small known file as a quick test before asking for broad code analysis.
- Keep sensitive files out of places your environment is likely to ignore or restrict.
If you regularly switch between local folders, remote repos, and browser workspaces, verify the active workspace every time. Most visibility bugs start with the wrong attachment, not with the file itself.
Common questions about Codex file access
Can Codex read .env files? Sometimes, but not always. Many environments treat hidden or sensitive files differently, so do not assume .env is visible just because it exists in the folder.
Can it access uncommitted changes? In many setups, yes, if the workspace is attached to the live working tree. If you recently edited files and Codex still sees older content, refresh the workspace and test again.
What if I’m in a restricted environment? Then the limitation may be intentional. Some setups only expose part of the tree or block specific paths. In that case, use an allowed folder or change the workspace configuration if you control it.
Should I move the file to make Codex see it? Only as a test, not as a permanent workaround. If a copied file inside a normal source folder becomes visible, that tells you the issue is path scope or indexing, not the file content itself.
Conclusion
If Codex still cannot see your files after these checks, verify the active workspace settings for the environment you are using. The next best move is to test one known readable file in the attached root, then adjust the root or indexing rules based on that result.
Frequently Asked Questions
Can OpenAI Codex read hidden files like `.env`?
Sometimes, but not always. Hidden files are often treated differently for privacy or workspace-policy reasons, so visibility depends on the environment.
Does Codex see uncommitted changes in my local project?
Usually it can see the current workspace state if the session is attached to the live working tree. If it appears to miss recent edits, refresh or reattach the project and test again.
Why can Codex see part of my monorepo but not another package?
The workspace may be attached to only one folder boundary, or the index may have stopped at a package limit. Try attaching the repo root and then verify each package with a known file.
What’s the fastest way to test whether file access is fixed?
Ask Codex to quote a specific line or summarize a known function from a file you can already see locally. If it returns the correct text, file access is working.