Skip to content

Commit 836a06b

Browse files
marc-hbpdgendt
authored andcommitted
project: "fail fast" west init when directories cannot be renamed
In October 2024, a problem reported in #558 showed that some Windows systems can be configured to allow directory and file creations but not renames. Test this _before_ git cloning to "fail fast" and remove git from the very confusing picture. Signed-off-by: Marc Herbert <[email protected]>
1 parent 8a23e03 commit 836a06b

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/west/app/project.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,28 @@ def bootstrap(self, args) -> Path:
307307
if not topdir.is_dir():
308308
self.create(topdir, exist_ok=False)
309309

310-
# Clone the manifest repository into a temporary directory.
311310
tempdir: Path = west_dir / 'manifest-tmp'
312311
if tempdir.is_dir():
313312
self.dbg('removing existing temporary manifest directory', tempdir)
314313
shutil.rmtree(tempdir)
314+
315+
# Test that we can rename and delete directories. For the vast
316+
# majority of users this is a no-op but some filesystem
317+
# permissions can be weird; see October 2024 example in west
318+
# issue #558. Git cloning can take a long time, so check this
319+
# first. Failing ourselves is not just faster, it's also much
320+
# clearer than when git is involved in the mix.
321+
322+
tempdir.mkdir(parents=True)
323+
(tempdir / 'not empty').mkdir()
324+
# Ignore the --rename-delay hack here not to double the wait;
325+
# we only have a couple directories and no file at this point!
326+
tempdir2 = tempdir.parent / 'renamed tempdir'
327+
os.rename(tempdir, tempdir2)
328+
# No need to delete west_dir parent
329+
shutil.rmtree(tempdir2)
330+
331+
# Clone the manifest repository into a temporary directory.
315332
try:
316333
self.small_banner(
317334
f'Cloning manifest repository from {manifest_url}' +

0 commit comments

Comments
 (0)