dbt-packages error cannot access the file...

The problem I’m having is I tried to update my packages using dbt deps and I got an error stating: The process cannot access the file because it is being used by another process: ‘dbt_packages\dbt-expectations-0.8.2\integration_tests’ and I have no idea how to fix this?

I am using dbt-sqlserver and my IDE is VsCode. I have tried dbt clean but it doesnt get rid of two of the folders. To delete those I have found that I need to exit vscode then re-open in which I can delete them.

I have put my packages yaml down below.


  - package: dbt-labs/codegen
    version: 0.9.0

  - package: calogica/dbt_date
    version: 0.7.2
  - package: calogica/dbt_expectations
    version: 0.8.2
  - package: dbt-labs/metrics
    version: 1.4.0

  - package: Datavault-UK/dbtvault
    version: 0.9.3

Does the error message say which process is accessing the file? What extensions do you have installed in VS Code? It sounds like something else is getting its hooks into the files which is causing problems when dbt deps tries to overwrite the folders with updated files.

So I was able to get out of the error by deleting my repo restarting my computer then cloning my repo again then dbt deps worked. This is the second time that this has happened to me, and I think you’re on the right train of thought with it being something to do with the extensions.

This an error I also received when shifting around the packages and always seems to have to do with integration tests:
[WinError 32] The process cannot access the file because it is being used by another process: ‘dbt_packages\dbt_metrics-1.4.0\integration_tests’ 15:03:05 Traceback (most recent call last): File “C:\Users\jb_admin\AppData\Local\Programs\Python\Python310\lib\shutil.py”, line 816, in move os.rename(src, real_dst) PermissionError: [WinError 5] Access is denied: ‘dbt_packages\dbt_metrics-1.4.0’ → ‘dbt_packages\metrics’.

Here is the list of extensions I am using:
Better Jinja
C/C++ Extension Pack
Code Spell Checker
Data Workspace
dbt Power User
Github Theme
indent rainbow
IntelliCode API Usage
jupyter Cell Tags
Jupyter Keymap
Jupyter Notebook renderers
jupyter slide show
markdown preview Github sytling
markdown lint
material icon theme
python indent
search lights
sql bindings
sql database projects
sql server
vscode icons

From this issue on the VS Code repo, it looks like this article might help (haven’t tried it myself). It looks like it uses Process Explorer to identify which process is holding the file lock, which might get down to the extension level

I was having this exact problem and solved it by disabling the dbt Power User extension, and then running dbt deps.


Interesting! Maybe this is a sibling to Duplicate dbt_utils folder when running dbt deps · Issue #4372 · dbt-labs/dbt-core · GitHub, which also seems to have power user as a culprit.

For those who use it, the vscode-dbt extension also (apparently) uses dbt-utils and needs to be disabled as well in order for the “dbt deps” to run