Skip to content

Commit 246599b

Browse files
committed
Enhance find_flutter_batch to normalize executable paths, on windows
1 parent 8d27ab7 commit 246599b

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

sdk/python/packages/flet-cli/src/flet_cli/commands/flutter_base.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,18 +312,31 @@ def _prompt_input(self, prompt: str) -> bool:
312312
self.live.start()
313313

314314
def find_flutter_batch(self, exe_filename: str):
315+
"""Locate the Flutter/Dart executable, preferring the managed SDK install."""
315316
assert self.required_flutter_version
317+
316318
install_dir = get_flutter_dir(str(self.required_flutter_version))
317319
ext = ".bat" if is_windows() else ""
318320
batch_path = os.path.join(install_dir, "bin", f"{exe_filename}{ext}")
321+
319322
if os.path.exists(batch_path):
320323
return batch_path
321324

325+
# Fall back to system-installed executable
322326
batch_path = shutil.which(exe_filename)
323327
if not batch_path:
324328
return None
325-
if is_windows() and batch_path.endswith(".file"):
326-
return batch_path.replace(".file", ".bat")
329+
330+
if is_windows():
331+
# convert shim paths
332+
if batch_path.endswith(".file"):
333+
return batch_path.replace(".file", ".bat")
334+
335+
# normalize .exe casing
336+
root, ext = os.path.splitext(batch_path)
337+
if ext.lower() == ".exe":
338+
return f"{root}.exe"
339+
327340
return batch_path
328341

329342
def run(self, args, cwd, env: Optional[dict] = None, capture_output=True):

0 commit comments

Comments
 (0)