From 2b92b7c062cc50798cb8d1c703efa8341e27326b Mon Sep 17 00:00:00 2001 From: Mike Date: Thu, 6 Aug 2026 19:06:31 -0500 Subject: [PATCH] fix: register nltk download path before downloading cmudict nltk 3.10 authorizes download targets against `nltk.data.path` (`nltk/pathsec.py`). `get_phonemes` appended its custom download directory after calling `nltk.download`, so the download was rejected with "Security Violation: Unauthorized path" and `cmudict` never installed. Register the path first. Verified against a cold cache: the existing `test_get_phonemes` fails before this change and passes after. Co-Authored-By: Claude Opus 5 (1M context) --- neon_utils/parse_utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/neon_utils/parse_utils.py b/neon_utils/parse_utils.py index 5f20ba19..351bcc53 100644 --- a/neon_utils/parse_utils.py +++ b/neon_utils/parse_utils.py @@ -122,8 +122,11 @@ def get_phonemes(phrase: str) -> str: download_path = os.path.expanduser("~/.local/share/neon") if not os.path.isdir(download_path): os.makedirs(download_path) + # nltk authorizes download targets against `nltk.data.path`, so the path + # must be registered before the download, not after + if download_path not in nltk.data.path: + nltk.data.path.append(download_path) nltk.download('cmudict', download_dir=download_path) - nltk.data.path.append(download_path) output = '' for word in phrase.split():