Skip to content

fix: windows flutter.bat compatibility for update command#439

Open
karnemanideep wants to merge 5 commits intoinvertase:mainfrom
karnemanideep:fix/windows-update-command
Open

fix: windows flutter.bat compatibility for update command#439
karnemanideep wants to merge 5 commits intoinvertase:mainfrom
karnemanideep:fix/windows-update-command

Conversation

@karnemanideep
Copy link
Copy Markdown

@karnemanideep karnemanideep commented Apr 19, 2026

Description

flutterfire update crashes on Windows with ProcessException: System cannot find the specified file because the update command uses Linux/Mac-only commands.

Two bugs found in update.dart:

  1. flutter command needs to be flutter.bat on Windows
  2. rm command does not exist on Windows

How I Found It

Searched issue #252 where users reported flutterfire update crashing on Windows. The stack trace pointed directly to update.dart line 79 where Process.run('flutter', ...) fails because Windows requires the .bat extension.

User jibbers42 also identified the exact lines in the issue comments.

What I Changed

File: packages/flutterfire_cli/lib/src/commands/update.dart

Fix 1 — flutter.bat on Windows:

// Before 
await Process.run('flutter', ['clean']);

// After 
final flutterCmd = Platform.isWindows ? 'flutter.bat' : 'flutter';
await Process.run(flutterCmd, ['clean']);

Fix 2 — Cross-platform file deletion:

Initial fix used if/else Platform.isWindows to handle rm not existing on Windows.

After Gemini code review suggested a simpler approach, updated to use Dart's built-in File API which works across all platforms:

// Before 
await Process.run('rm', ['pubspec.lock']);

// After 
final pubspecLockFile = File('pubspec.lock');
if (pubspecLockFile.existsSync()) {
  await pubspecLockFile.delete();
}

flutterCmd is reused for all 3 flutter command calls in the file.

Fixes #252

Type of change

  • feat -- New feature (non-breaking change which adds functionality)
  • 🛠️ fix -- Bug fix (non-breaking change which fixes an issue)
  • ! -- Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 refactor -- Code refactor
  • ci -- Build configuration change
  • 📝 docs -- Documentation
  • 🗑️ chore -- Chore

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request improves Windows compatibility in the update command by correctly identifying the Flutter executable and handling file deletions. It also ensures that generated configuration files end with a trailing newline. Review feedback suggests using Dart's cross-platform File API for deleting pubspec.lock to simplify the code and avoid unnecessary process spawning, as well as removing redundant inline comments.

Comment on lines +84 to +91
if (Platform.isWindows) {
await File('pubspec.lock').delete();
} else {
await Process.run(
'rm',
['pubspec.lock'],
);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Instead of branching on the platform and spawning a shell process for rm, you can use Dart's built-in File API which is cross-platform. This is more efficient as it avoids the overhead of creating a new process. Additionally, checking for existence with existsSync() prevents potential exceptions if the file is already missing, maintaining the robustness of the command.

    final pubspecLockFile = File('pubspec.lock');
    if (pubspecLockFile.existsSync()) {
      await pubspecLockFile.delete();
    }

Comment thread packages/flutterfire_cli/lib/src/commands/update.dart Outdated
Comment thread packages/flutterfire_cli/lib/src/commands/update.dart Outdated
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@karnemanideep karnemanideep changed the title Fix/windows update command fix: windows flutter.bat compatibility for update command Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: flutterfire update throws ProcessException: System cannot find the specified file.

1 participant