Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot clear docs/_build directory due to locked database files #865

Closed
marcel-22 opened this issue Jul 24, 2024 · 7 comments · Fixed by #903
Closed

Cannot clear docs/_build directory due to locked database files #865

marcel-22 opened this issue Jul 24, 2024 · 7 comments · Fixed by #903
Labels
bug Something isn't working lsp Issues that relate to the language server
Milestone

Comments

@marcel-22
Copy link

Expected behavior

We have a script to clear (remove) the build directory. This does not work anymore due to locked Esbonio database files.

Actual behavior

When I try to delete the docs/_build directory I get the following errors:

$ rm -fr docs/_build
rm: cannot remove 'docs/_build/html/esbonio.db': Device or resource busy
rm: cannot remove 'docs/_build/html/esbonio.db-shm': Device or resource busy
rm: cannot remove 'docs/_build/html/esbonio.db-wal': Device or resource busy

If I try to delete it in Windows Explorer, it says The action can't be completed because the file is open in Python. When I close VS Code and then delete the folder it's gone. How can we make sure the docs/_build directory can be removed successfully? This should work independently from the Preview function. For example, we have scripts to clear the entire code and documentation builds and rebuild everything from scratch, if necessary.

Log output

No response

(Optional) Settings from conf.py

No response

@marcel-22 marcel-22 added bug Something isn't working triage Issues needing triage labels Jul 24, 2024
@marcel-22
Copy link
Author

The easiest and cleanest solution would be to store the database files outside of docs/_build so that they don't interfere.

My thoughts would be to have some Esbonio storage folder - in %APPDATA% or %LOCALAPPDATA%, I am not sure - and create a directory for each project there with the preview database files stored in them.

I snooped around a bit and I found something like %APPDATA%\Code\User\workspaceStorage. You could create a hash for each folder location like is seen here and store documents inside them, but then I found some older project/hash folder inside workspaceStorage that already had a subfolder called swyddfa.esbonio. So wouldn't it be possible to use this? It seems like you have done it before.

@marcel-22
Copy link
Author

An alternative option could be to store the Esbonio database files in the .vscode folder. But this should be user configurable I guess. Or we could build the Esbonio documentation in another folder instead. Is there a way to reference the exact folder location in workspaceStorage for the open folder/workspace that you know of?

The comments in this topic might be of interest to you: microsoft/vscode#22557

@alcarney
Copy link
Member

I found some older project/hash folder inside workspaceStorage that already had a subfolder called swyddfa.esbonio. So wouldn't it be possible to use this? It seems like you have done it before.

Yes... but it's VSCode specific and the server would have to be told about it via a config option set by the extension (not necessarily a bad thing and how it works in the stable release).

Or we could build the Esbonio documentation in another folder instead

If the esbonio.sphinx.buildCommand option accepted something like ["sphinx-build", "-M", "html", "docs", "${defaultBuildDir}", "-t", "preview", "-W", "--keep-going"], so that the server could place the files "somewhere else" but still allow you to set the other cli flags would that be enough?

Or shall I also add a separate esbonio.sphinx.databaseDir option as well?

Is there a way to reference the exact folder location in workspaceStorage for the open folder/workspace that you know of?

The only way to reference it I know of is via the VSCode API in the extension itself...

@alcarney alcarney added lsp Issues that relate to the language server and removed triage Issues needing triage labels Jul 27, 2024
@alcarney alcarney added this to Esbonio Jul 27, 2024
@github-project-automation github-project-automation bot moved this to Todo in Esbonio Jul 27, 2024
@alcarney alcarney added this to the 1.0 milestone Jul 27, 2024
@marcel-22
Copy link
Author

If the esbonio.sphinx.buildCommand option accepted something like ["sphinx-build", "-M", "html", "docs", "${defaultBuildDir}", "-t", "preview", "-W", "--keep-going"], so that the server could place the files "somewhere else" but still allow you to set the other cli flags would that be enough?

Hm, yes, that would fix the whole issue! And this behavior would be similar to the current stable release version I think.

Or shall I also add a separate esbonio.sphinx.databaseDir option as well?

With the above solution it won't be needed in our case, but for people who want to have the exact same build location for the preview docs and normal docs that would be an option to solve the issue with the locked database files.

The only way to reference it I know of is via the VSCode API in the extension itself...

Thanks. Yes, I thought that as well. But with your suggested solution using ${defaultBuildDir} which resolves to some other folder, and not part of our workspace, this won't be needed.

alcarney added a commit to alcarney/esbonio that referenced this issue Sep 25, 2024
Unless esbonio finds a `sphinx-build` command to use from the
user's config it will attempt to guess something reasonable. During
this process it generates a default build directory to use, in a
subfolder of `platformdirs.user_cache_dir()` so that it does not
interfere with the user's files.

Up until now, the moment a user sets their own `sphinx-build` command
this behavior is lost, which can lead to issues on some systems
(see swyddfa#865).

This commit introduces a `${defaultBuildDir}` placeholder value that
the user can use to provide their own build flags, while maintaining
the default choice of build dir provided by esbonio.
alcarney added a commit to alcarney/esbonio that referenced this issue Sep 25, 2024
Unless esbonio finds a `sphinx-build` command to use from the
user's config it will attempt to guess something reasonable. During
this process it generates a default build directory to use, in a
subfolder of `platformdirs.user_cache_dir()` so that it does not
interfere with the user's files.

Up until now, the moment a user sets their own `sphinx-build` command
this behavior is lost, which can lead to issues on some systems
(see swyddfa#865).

This commit introduces a `${defaultBuildDir}` placeholder value that
the user can use to provide their own build flags, while maintaining
the default choice of build dir provided by esbonio.
alcarney added a commit that referenced this issue Sep 29, 2024
Unless esbonio finds a `sphinx-build` command to use from the
user's config it will attempt to guess something reasonable. During
this process it generates a default build directory to use, in a
subfolder of `platformdirs.user_cache_dir()` so that it does not
interfere with the user's files.

Up until now, the moment a user sets their own `sphinx-build` command
this behavior is lost, which can lead to issues on some systems
(see #865).

This commit introduces a `${defaultBuildDir}` placeholder value that
the user can use to provide their own build flags, while maintaining
the default choice of build dir provided by esbonio.
@github-project-automation github-project-automation bot moved this from Todo to Done in Esbonio Sep 29, 2024
@marcel-22
Copy link
Author

Is this included in the new pre-release?

@alcarney
Copy link
Member

The ${defaultBuildDir} variable, yes

@marcel-22
Copy link
Author

Thanks! I have it running now, in a multi-root workspace setup 😊 Nice work 👍👍👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lsp Issues that relate to the language server
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants