The issue is as follows.
I usually work with Python to develop my apps. yesterday I wanted to try UV framework, and I found it very nice. However, I soon found out that the .venv folder created is not showing in my vscode tree view. Seethe picture as follows:
Basically, the .venv folder exists.. but I just cannot see it in my tree view. I want to know why. and even better, how can I fix this?
I will also copy and paste my user and workspace settings.. Maybe its related to that, but I don’t exactly know.
User settings:
{
// General settings
"security.workspace.trust.untrustedFiles": "newWindow",
"window.zoomLevel": 1,
"window.commandCenter": false,
"files.exclude": {
".git": true,
"**/.git": false
},
"extensions.autoUpdate": "onlyEnabledExtensions",
// Git settings
"git.autofetch": true,
"git.confirmSync": false,
"git.enableSmartCommit": true,
"git.showActionButton": {
"commit": false,
"publish": false,
"sync": false
},
"github.copilot.enable": {
"*": true,
"plaintext": false,
"scminput": false,
"yaml": false
},
// Explorer settings
"explorer.excludeGitIgnore": true,
"explorer.autoReveal": true,
"explorer.confirmDelete": false,
"explorer.confirmDragAndDrop": false,
// Workbench settings
"workbench.colorTheme": "Default Light+",
"workbench.editor.tabSizing": "shrink",
"workbench.settings.editor": "json",
// Editor settings
"ruff.importStrategy": "useBundled",
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "file",
"editor.codeActionsOnSave": {
"source.organizeImports": "always",
"source.fixAll": "always"
},
"files.autoSave": "onFocusChange",
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"[jsonc]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
// Debug settings
"debug.toolBarLocation": "docked",
// Terminal settings
"terminal.integrated.tabs.enabled": true,
"terminal.integrated.tabs.hideCondition": "never",
"terminal.integrated.tabs.location": "right",
// Markdown settings
"markdown.preview.scrollEditorWithPreview": true,
"markdown.preview.scrollPreviewWithEditor": true,
"python.createEnvironment.contentButton": "show",
"python.venvFolders": [
""
]
}
Workspace settings:
// Python settings
"python.analysis.autoSearchPaths": true,
"python.analysis.diagnosticSeverityOverrides": {
"reportMissingImports": "none"
},
"python.analysis.extraPaths": [
"${workspaceFolder}/src"
],
"python.envFile": "${workspaceFolder}/.env",
"python.terminal.activateEnvironment": true,
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
// Test settings
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
"python.testing.cwd": "${workspaceFolder}/tests",
"python.testing.pytestPath": "${workspaceFolder}/.venv/bin/pytest",
"python.testing.autoTestDiscoverOnSaveEnabled": true,
}
I would be very appreciated if someone can help me with this…
2
Answers
open vs code settings (ctrl + ,)
then search files.exclude in top
Look for setting called
"files.exclude": {".*": true}
and uncheck the checkbox next to it to disable file exclusion for hidden fileAlternatively you can add a new setting to override the default exclusion for the
.venv
folder by adding the following line to your settings:json "files.exclude": { ".**": true, "*.code-workspace": true, "*.log": true, "*.sqlite3": true, "*.db": true, "*.sublime-workspace": true, ".vscode": true, "**/.vscode": true, "**/.sass-cache": true, "**/.metals": true, "**/.git": true, "**/.hg": true, "**/.svn": true, "**/.DS_Store": true, "**/.gitignore": true, "**/.project": true, "**/.settings": true, "**/.nyc_output": true, "**/.env": true, "!.venv": false }
this will exclude all hidden files and folders except for the.venv
foldelastly save the settings and restart Vscode let me knwo if it work
answer to your comment-
The setting
"explorer.excludeGitIgnore": false
in your VS Code settings.json file overrides the"files.exclude"
setting for".venv"
folder, because it specifically tells VS Code to include Git Ignored files and folders in the Explorer view. When"explorer.excludeGitIgnore": false
is set, VS Code will ignore the"files.exclude"
setting for any Git Ignored item, including the".venv"
folder. This is why the".venv"
folder is appearing in your Explorer view even when you have"!.venv": true
set in the"files.exclude"
setting. To exclude the".venv"
folder from the Explorer view, you can either remove or set totrue
the"explorer.excludeGitIgnore"
setting, or you can add".venv/**"
to the"files.exclude"
setting to explicitly exclude it. Here is an example of what thesettings.json
file would look like with the".venv"
folder explicitly excluded:json { "files.exclude": { "**.pyc": true, "**.pyo": true, "**.pyd": true, "**.pyd$: true, "**.pyw": true, "**.obj": true, "**.exe": true, "**.dll": true, "**.ipynb_checkpoints": true, ".venv": true, ".venv/**": true }, "explorer.excludeGitIgnore": false }
With this configuration the".venv"
folder will be excluded from the Explorer view regardless of the"explorer.excludeGitIgnore"
setting. Let me know is it works!