Skip to content

Commit 34662ba

Browse files
committed
utils/env: ensure user directories are created
1 parent d660b51 commit 34662ba

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

poetry/masonry/builders/editable.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def _add_scripts(self):
131131
entry_points = self.convert_entry_points()
132132

133133
for scripts_path in self._env.script_dirs:
134-
if is_dir_writable(scripts_path):
134+
if is_dir_writable(path=scripts_path, create=True):
135135
break
136136
else:
137137
self._io.error_line(

poetry/utils/env.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def writable_candidates(self): # type: () -> List[Path]
170170

171171
self._writable_candidates = []
172172
for candidate in self._candidates:
173-
if not is_dir_writable(candidate):
173+
if not is_dir_writable(path=candidate, create=True):
174174
continue
175175
self._writable_candidates.append(candidate)
176176

tests/utils/test_env_site.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
from poetry.utils.env import SitePackages
66

77

8-
def test_env_site_simple(tmp_dir):
8+
def test_env_site_simple(tmp_dir, mocker):
9+
# emulate permission error when creating directory
10+
mocker.patch("poetry.utils._compat.Path.mkdir", side_effect=OSError())
911
site_packages = SitePackages(Path("/non-existent"), fallbacks=[Path(tmp_dir)])
1012
candidates = site_packages.make_candidates(Path("hello.txt"), writable_only=True)
1113
hello = Path(tmp_dir) / "hello.txt"

0 commit comments

Comments
 (0)