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

remove length check + catch any exceptions on windows #2603

Merged
merged 2 commits into from Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,7 @@

### Fixes
- Hash name of local packages ([#2600](https://github.com/fishtown-analytics/dbt/pull/2600))
- Swallow all file-writing related errors on Windows, regardless of path length or exception type. ([#2603](https://github.com/fishtown-analytics/dbt/pull/2603))

## dbt 0.17.1rc2 (June 25, 2020)

Expand Down
13 changes: 8 additions & 5 deletions core/dbt/clients/system.py
Expand Up @@ -135,11 +135,14 @@ def write_file(path: str, contents: str = '') -> bool:
make_directory(os.path.dirname(path))
with open(path, 'w', encoding='utf-8') as f:
f.write(str(contents))
except FileNotFoundError as exc:
if (
os.name == 'nt' and
len(path) >= 260
):
except Exception as exc:
drewbanin marked this conversation as resolved.
Show resolved Hide resolved
# note that you can't just catch FileNotFound, because sometimes
# windows apparently raises something else.
# It's also not sufficient to look at the path length, because
# sometimes windows fails to write paths that are less than the length
# limit. So on windows, suppress all errors that happen from writing
# to disk.
if os.name == 'nt':
# sometimes we get a winerror of 3 which means the path was
# definitely too long, but other times we don't and it means the
# path was just probably too long. This is probably based on the
Expand Down