From 2e39a5fff07685cd06af1b96c882e059a18e6924 Mon Sep 17 00:00:00 2001 From: Jacob Beck Date: Thu, 25 Jun 2020 10:30:32 -0600 Subject: [PATCH] handle unmarked path too long errors --- CHANGELOG.md | 1 + core/dbt/clients/system.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f43b063498..5c69a9ecc3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Fixes - dbt config-version: 2 now properly defers rendering `+pre-hook` and `+post-hook` fields. ([#2583](https://github.com/fishtown-analytics/dbt/issues/2583), [#2854](https://github.com/fishtown-analytics/dbt/pull/2854)) +- dbt handles too-long paths on windows that do not report that the path is too long ([#2591](https://github.com/fishtown-analytics/dbt/pull/2591)) ## dbt 0.17.1rc1 (June 19, 2020) diff --git a/core/dbt/clients/system.py b/core/dbt/clients/system.py index 2193e6e7bc9..bf99dc7ee90 100644 --- a/core/dbt/clients/system.py +++ b/core/dbt/clients/system.py @@ -138,13 +138,20 @@ def write_file(path: str, contents: str = '') -> bool: except FileNotFoundError as exc: if ( os.name == 'nt' and - getattr(exc, 'winerror', 0) == 3 and len(path) >= 260 ): + # 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 + # windows/python version. + if getattr(exc, 'winerror', 0) == 3: + reason = 'Path was too long' + else: + reason = 'Path was possibly too long' # all our hard work and the path was still too long. Log and # continue. logger.debug( - f'Could not write to path {path}: Path was too long ' + f'Could not write to path {path}: {reason} ' f'({len(path)} characters)' ) else: