fix: handle permission errors gracefully when writing package-lock.yml#12729
Open
claygeo wants to merge 2 commits into
Open
fix: handle permission errors gracefully when writing package-lock.yml#12729claygeo wants to merge 2 commits into
claygeo wants to merge 2 commits into
Conversation
Contributor
|
Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide. |
claygeo
added a commit
to claygeo/dbt-core
that referenced
this pull request
Mar 30, 2026
ec282da to
445431a
Compare
claygeo
added a commit
to claygeo/dbt-core
that referenced
this pull request
Mar 30, 2026
claygeo
added a commit
to claygeo/dbt-core
that referenced
this pull request
Mar 30, 2026
445431a to
542393f
Compare
claygeo
added a commit
to claygeo/dbt-core
that referenced
this pull request
Mar 30, 2026
542393f to
b71ec6d
Compare
When dbt deps runs in a directory where the user lacks write
permissions (e.g. inside containers with read-only project mounts),
the lock file write fails silently. The user sees no error and no
packages are installed.
Wrap the lock file write in a try/except for OSError. On failure,
log a warning and proceed without the lock file, matching the
maintainer's preferred behavior from issue discussion (option 2:
handle and proceed).
The rest of dbt deps still works because load_yml_dict returns {}
for missing files, and the resolver falls back to packages.yml.
Fixes dbt-labs#9241
b71ec6d to
958adb1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #9241.
dbt depsfails with an unhandledPermissionErrorwhen run in a read-only directory (common in container environments with mounted project volumes). Thelock()method tries to writepackage-lock.ymlviaopen(lock_filepath, 'w'), which raisesPermissionError; dbt exits with no output and no packages installed.Fix
Wrap the lock-file write in a
try/except OSError(which coversPermissionError,FileNotFoundError, etc.). On failure, fire aWARN-level log message and proceed — packages continue to install normally usingpackages.yml.The warning is fired at
EventLevel.WARN(notINFO) so it stands out in the console and structured log consumers can route it correctly.The rest of
dbt depsstill works becauseload_yml_dictreturns{}for missing files and the resolver falls back topackages.yml.Checklist