Why does dart run flutter_oss_licenses:generate fail with PathNotFoundException for '/programs/flutter/version'?

Last updated: August 8, 2026

Context

When running dart run flutter_oss_licenses:generate as part of a build workflow (e.g., in a pre-build script), the command fails with the following error:

PathNotFoundException: Cannot open file, path = '/Users/builder/programs/flutter/version' (OS Error: No such file or directory, errno = 2)

This error occurs even if the command previously worked without any changes to the project's dependencies.

Answer

This is a project-side issue caused by an outdated version of the dart_pubspec_licenses package. Specifically, versions of dart_pubspec_licenses prior to 3.0.14 attempt to read Flutter version information from a version file that no longer exists in newer Flutter installations. This file was replaced by bin/cache/flutter.version.json, and the fix was introduced in dart_pubspec_licenses 3.0.14.

To resolve this issue, update your flutter_oss_licenses and/or dart_pubspec_licenses dependencies so that dart_pubspec_licenses resolves to at least version 3.0.14:

  1. Open your project's pubspec.yaml file.

  2. Update the flutter_oss_licenses dependency to a version that pulls in dart_pubspec_licenses 3.0.14 or higher.

  3. Run flutter pub upgrade to update your pubspec.lock file.

  4. Commit the updated pubspec.lock to your repository.

  5. Re-run your build workflow.

For more details on the underlying fix, refer to the related issue on GitHub.