- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2025 07:13 AM
The error you encountered when running your dbt project in Databricks Workflows comes from Databricks trying to copy the entire repository, including the virtual environment (venv) folder and its cached bytecode files (__pycache__), into a temporary workspace path (/tmp/tmp-dbt-run-...). When those directories no longer exist or can’t be accessed, the cp command fails, throwing a CalledProcessError with “cannot stat” messages.
This issue is known and documented in multiple community discussions and Stack Overflow posts. It is caused by unnecessary virtual environment or compiled Python directories being included in the workspace repository. These files are not needed to run your dbt command but cause cp to fail during Databricks’ internal job setup step.
Resolution
The fix is straightforward:
-
Exclude local environment and cache directories from your repository:
-
At the root of your dbt project (in Azure DevOps), create or update a
.gitignorefile to include:textvenv/ __pycache__/ -
Then remove any committed versions of those directories from your repo:
bashgit rm -r --cached venv __pycache__ git commit -m "Remove local virtual environment and cache from repo" git push
-
-
Avoid committing the virtual environment entirely.
Databricks manages its environment using the cluster interpreter and any libraries specified in your workflow (through PyPI or libraries configuration). You don’t need your localvenvincluded; instead, rely on Databricks to installdbt-databricksand dependencies. -
Re-run the workflow.
After cleaning the repo and committing changes, Databricks should copy the repo without attempting to include those missing files, and the workflow should proceed normally.
Root Cause Recap
This happens because Databricks creates a temporary working directory (/tmp/tmp-dbt-run-*) by recursively copying the repo from /Workspace/Repos/.internal/.... When files are missing or dynamically excluded (often inside venv), the cp -a command can’t locate them. Excluding those runtime local directories prevents the copy failure.
After applying the .gitignore change and cleaning your repo, your dbt project should run correctly inside Databricks Workflows without the CalledProcessError