-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Closed
Labels
has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyWeb applications specificallytoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.
Description
Steps to reproduce
- Create a Flutter web project:
flutter create bug_repro - Add a
{{VERSION}}placeholder toweb/index.html:<script> {{flutter_js}} {{flutter_build_config}} // Append version query parameter to main.dart.js URL for cache invalidation // The {{VERSION}} placeholder should be replaced by --web-define=VERSION=... _flutter.buildConfig.builds[0].mainJsPath = "main.dart.js?v={{VERSION}}"; _flutter.loader.load({ onEntrypointLoaded: async function (engineInitializer) { const appRunner = await engineInitializer.initializeEngine(); await appRunner.runApp(); }, }); </script>
- Run
flutter build web --web-define=VERSION=1.0.0
Expected results
- Build succeeds without errors
- The
{{VERSION}}placeholder is replaced with1.0.0in the outputbuild/web/index.html - The generated file contains:
main.dart.js?v=1.0.0 - Verification:
grep "mainJsPath" build/web/index.htmlshowsmain.dart.js?v=1.0.0
Actual results
Build fails with error:
Target web_templated_files failed: Error: Missing web-define variable: VERSION
Please provide the missing variable using:
flutter run --web-define=VERSION=VALUE
or
flutter build web --web-define=VERSION=VALUE
Code sample
Code sample
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Bug Reproduction</title>
</head>
<body>
<script>
{{flutter_js}}
{{flutter_build_config}}
// This {{VERSION}} placeholder should be replaced by --web-define=VERSION=...
_flutter.buildConfig.builds[0].mainJsPath = "main.dart.js?v={{VERSION}}";
_flutter.loader.load({
onEntrypointLoaded: async function (engineInitializer) {
const appRunner = await engineInitializer.initializeEngine();
await appRunner.runApp();
},
});
</script>
</body>
</html>Logs
Logs
[ +16 ms] executing: sysctl hw.optional.arm64
[ +3 ms] Exit code 0 from: sysctl hw.optional.arm64
[ ] hw.optional.arm64: 1
[ +4 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
[ ] Artifact Instance of 'GradleWrapper' is not required, skipping update.
[ ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[ ] Artifact Instance of 'LegacyCanvasKitRemover' is not required, skipping update.
[ ] Artifact Instance of 'FlutterSdk' is not required, skipping update.
[ ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'PubDependencies' is not required, skipping update.
[ ] executing: [/Users/michalkucharski/fvm/versions/3.41.0-0.2.pre/] git -c log.showSignature=false log HEAD -n 1 --pretty=format:%ad
--date=iso
[ +16 ms] Exit code 0 from: git -c log.showSignature=false log HEAD -n 1 --pretty=format:%ad --date=iso
[ ] 2026-01-28 11:28:23 -0800
[ +12 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[ ] Artifact Instance of 'FlutterEngineStamp' is not required, skipping update.
[ ] Artifact Instance of 'LegacyCanvasKitRemover' is not required, skipping update.
[ ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +18 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
[ ] Artifact Instance of 'GradleWrapper' is not required, skipping update.
[ ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterEngineStamp' is not required, skipping update.
[ ] Artifact Instance of 'FlutterSdk' is not required, skipping update.
[ ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[ ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
[ +7 ms] Artifact Instance of 'PubDependencies' is not required, skipping update.
[ +7 ms] executing: [/Users/michalkucharski/Desktop/flutter_web_define_reproduction/]
/Users/michalkucharski/fvm/versions/3.41.0-0.2.pre/bin/cache/dart-sdk/bin/dart pub --suppress-analytics --color --directory . get --example
Resolving dependencies...
Downloading packages...
meta 1.17.0 (1.18.1 available)
test_api 0.7.8 (0.7.9 available)
Got dependencies!
2 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.
[ +97 ms] Skipping generating web_plugin_registrant.dart because it is up-to-date.
[ +42 ms] generated_plugin_registrant.dart not found. Skipping.
[ ] Compiling lib/main.dart for the Web...
[ +2 ms] Initializing file store
[ +1 ms] Done initializing file store
[ +18 ms] Skipping target: web_entrypoint
[ ] invalidated build due to missing files: /Users/michalkucharski/Desktop/flutter_web_define_reproduction/web/*/index.html,
/Users/michalkucharski/Desktop/flutter_web_define_reproduction/web/flutter_bootstrap.js
[ ] Skipping target: dart_build
[ ] Skipping target: gen_localizations
[ ] web_templated_files: Starting due to {InvalidatedReasonKind.buildKeyChanged: The target build key changed.,
InvalidatedReasonKind.outputSetAddition: The following outputs were added to the output set:
/Users/michalkucharski/Desktop/flutter_web_define_reproduction/build/web/*/index.html,/Users/michalkucharski/Desktop/flutter_web_define_reprodu
ction/build/web/flutter_bootstrap.js, InvalidatedReasonKind.inputMissing: The following inputs were missing:
/Users/michalkucharski/Desktop/flutter_web_define_reproduction/web/*/index.html,/Users/michalkucharski/Desktop/flutter_web_define_reproduction/
web/flutter_bootstrap.js}
[ ] web_static_assets: Starting due to {InvalidatedReasonKind.outputMissing: The following outputs were missing:
/Users/michalkucharski/Desktop/flutter_web_define_reproduction/.dart_tool/flutter_build/825161eebb3468bc1b39a75b1eaba464/flutter.js,/Users/mich
alkucharski/Desktop/flutter_web_define_reproduction/.dart_tool/flutter_build/825161eebb3468bc1b39a75b1eaba464/canvaskit/wimp.wasm,/Users/michal
kucharski/Desktop/flutter_web_define_reproduction/.dart_tool/flutter_build/825161eebb3468bc1b39a75b1eaba464/canvaskit/skwasm.js,/Users/michalku
charski/Desktop/flutter_web_define_reproduction/.dart_tool/flutter_build/825161eebb3468bc1b39a75b1eaba464/canvaskit/skwasm_heavy.js,/Users/mich
alkucharski/Desktop/flutter_web_define_reproduction/.dart_tool/flutter_build/825161eebb3468bc1b39a75b1eaba464/canvaskit/skwasm.js.symbols,/User
s/michalkucharski/Desktop/flutter_web_define_reproduction/.dart_tool/flutter_build/825161eebb3468bc1b39a75b1eaba464/canvaskit/canvaskit.js.symb
ols,/Users/michalkucharski/Desktop/flutter_web_define_reproduction/.dart_tool/flutter_build/825161eebb3468bc1b39a75b1eaba464/canvaskit/skwasm_h
eavy.js.symbols,/Users/michalkucharski/Desktop/flutter_web_define_reproduction/.dart_tool/flutter_build/825161eebb3468bc1b39a75b1eaba464/canvas
kit/skwasm.wasm,/Users/michalkucharski/Desktop/flutter_web_define_reproduction/.dart_tool/flutter_build/825161eebb3468bc1b39a75b1eaba464/canvas
kit/chromium/canvaskit.js.symbols,/Users/michalkucharski/Desktop/flutter_web_define_reproduction/.dart_tool/flutter_build/825161eebb3468bc1b39a
75b1eaba464/canvaskit/chromium/canvaskit.js,/Users/michalkucharski/Desktop/flutter_web_define_reproduction/.dart_tool/flutter_build/825161eebb3
468bc1b39a75b1eaba464/canvaskit/chromium/canvaskit.wasm,/Users/michalkucharski/Desktop/flutter_web_define_reproduction/.dart_tool/flutter_build
/825161eebb3468bc1b39a75b1eaba464/canvaskit/canvaskit.js,/Users/michalkucharski/Desktop/flutter_web_define_reproduction/.dart_tool/flutter_buil
d/825161eebb3468bc1b39a75b1eaba464/canvaskit/wimp.js,/Users/michalkucharski/Desktop/flutter_web_define_reproduction/.dart_tool/flutter_build/82
5161eebb3468bc1b39a75b1eaba464/canvaskit/canvaskit.wasm,/Users/michalkucharski/Desktop/flutter_web_define_reproduction/.dart_tool/flutter_build
/825161eebb3468bc1b39a75b1eaba464/canvaskit/wimp.js.symbols,/Users/michalkucharski/Desktop/flutter_web_define_reproduction/.dart_tool/flutter_b
uild/825161eebb3468bc1b39a75b1eaba464/canvaskit/skwasm_heavy.wasm}
[ +317 ms] Skipping target: dart2js
[ +1 ms] web_static_assets: Complete
[ +1 ms] dart2wasm: Starting due to {}
[ +4 ms] executing: /Users/michalkucharski/fvm/versions/3.41.0-0.2.pre/bin/cache/dart-sdk/bin/dart compile wasm
--packages=/Users/michalkucharski/Desktop/flutter_web_define_reproduction/.dart_tool/package_config.json
--extra-compiler-option=--platform=/Users/michalkucharski/fvm/versions/3.41.0-0.2.pre/bin/cache/flutter_web_sdk/kernel/dart2wasm_platform.dill
-Ddart.vm.profile=false -Ddart.vm.product=true --extra-compiler-option=--delete-tostring-package-uri=dart:ui
--extra-compiler-option=--delete-tostring-package-uri=package:flutter --extra-compiler-option=--import-shared-memory
--extra-compiler-option=--shared-memory-max-pages=32768 -DFLUTTER_VERSION=3.41.0-0.2.pre -DFLUTTER_CHANNEL=beta
-DFLUTTER_GIT_URL=https://github.com/flutter/flutter.git -DFLUTTER_FRAMEWORK_REVISION=a7c4c6bf74 -DFLUTTER_ENGINE_REVISION=15d137647e
-DFLUTTER_DART_VERSION=3.11.0 (build 3.11.0-296.4.beta) -DFLUTTER_WEB_USE_SKIA=false -DFLUTTER_WEB_USE_SKWASM=true
-DFLUTTER_WEB_CANVASKIT_URL=https://www.gstatic.com/flutter-canvaskit/15d137647e372c59e8dcb78f670ab7686a0d1031/
--extra-compiler-option=--depfile=/Users/michalkucharski/Desktop/flutter_web_define_reproduction/.dart_tool/flutter_build/825161eebb3468bc1b39a
75b1eaba464/dart2wasm.d -O2 --strip-wasm --no-source-maps --minify --extra-compiler-option=--dry-run -o
/Users/michalkucharski/Desktop/flutter_web_define_reproduction/.dart_tool/flutter_build/825161eebb3468bc1b39a75b1eaba464/main.dart.wasm
/Users/michalkucharski/Desktop/flutter_web_define_reproduction/.dart_tool/flutter_build/825161eebb3468bc1b39a75b1eaba464/main.dart
[+12424 ms] Wasm dry run succeeded. Consider building and testing your application with the `--wasm` flag. See docs for more info:
https://docs.flutter.dev/platform-integration/web/wasm
[ +1 ms] Use --no-wasm-dry-run to disable these warnings.
[ +14 ms] dart2wasm: Complete
[ +6 ms] Persisting file store
[ +6 ms] Done persisting file store
[ +5 ms] Target web_templated_files failed: Error: Missing web-define variable: VERSION
Please provide the missing variable using:
flutter run --web-define=VERSION=VALUE
or
flutter build web --web-define=VERSION=VALUE
#0 throwToolExit (package:flutter_tools/src/base/common.dart:34:3)
#1 WebTemplate._applyVariableSubstitutions (package:flutter_tools/src/web_template.dart:191:5)
#2 WebTemplate.withSubstitutions (package:flutter_tools/src/web_template.dart:136:18)
#3 WebTemplatedFiles.build (package:flutter_tools/src/build_system/targets/web.dart:756:59)
<asynchronous suspension>
#4 _BuildInstance._invokeInternal (package:flutter_tools/src/build_system/build_system.dart:937:9)
<asynchronous suspension>
#5 Future.wait.<anonymous closure> (dart:async/future.dart:546:21)
<asynchronous suspension>
#6 _BuildInstance.invokeTarget (package:flutter_tools/src/build_system/build_system.dart:875:32)
<asynchronous suspension>
#7 Future.wait.<anonymous closure> (dart:async/future.dart:546:21)
<asynchronous suspension>
#8 _BuildInstance.invokeTarget (package:flutter_tools/src/build_system/build_system.dart:875:32)
<asynchronous suspension>
#9 FlutterBuildSystem.build (package:flutter_tools/src/build_system/build_system.dart:684:16)
<asynchronous suspension>
#10 WebBuilder.buildWeb (package:flutter_tools/src/web/compile.dart:101:34)
<asynchronous suspension>
#11 BuildWebCommand.runCommand (package:flutter_tools/src/commands/build_web.dart:299:5)
<asynchronous suspension>
#12 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1590:27)
<asynchronous suspension>
#13 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:154:19)
<asynchronous suspension>
#14 CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#15 FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:496:9)
<asynchronous suspension>
#16 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:154:19)
<asynchronous suspension>
#17 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:431:5)
<asynchronous suspension>
#18 FlutterCommandRunner.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:307:33)
<asynchronous suspension>
#19 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:104:11)
<asynchronous suspension>
#20 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:154:19)
<asynchronous suspension>
#21 main (package:flutter_tools/executable.dart:103:3)
<asynchronous suspension>
[ +1 ms] Compiling lib/main.dart for the Web... (completed in 12.8s)
[ ] "flutter web" took 12,993ms.
[ +3 ms] executing: sw_vers -productName
[ +9 ms] Exit code 0 from: sw_vers -productName
[ ] macOS
[ ] executing: sw_vers -productVersion
[ +7 ms] Exit code 0 from: sw_vers -productVersion
[ ] 14.6
[ ] executing: sw_vers -buildVersion
[ +7 ms] Exit code 0 from: sw_vers -buildVersion
[ ] 23G80
[ ] executing: uname -m
[ +2 ms] Exit code 0 from: uname -m
[ ] arm64
[ +24 ms] Error: Failed to compile application for the Web.
[ ]
#0 throwToolExit (package:flutter_tools/src/base/common.dart:34:3)
#1 WebBuilder.buildWeb (package:flutter_tools/src/web/compile.dart:145:7)
<asynchronous suspension>
#2 BuildWebCommand.runCommand (package:flutter_tools/src/commands/build_web.dart:299:5)
<asynchronous suspension>
#3 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1590:27)
<asynchronous suspension>
#4 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:154:19)
<asynchronous suspension>
#5 CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#6 FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:496:9)
<asynchronous suspension>
#7 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:154:19)
<asynchronous suspension>
#8 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:431:5)
<asynchronous suspension>
#9 FlutterCommandRunner.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:307:33)
<asynchronous suspension>
#10 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:104:11)
<asynchronous suspension>
#11 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:154:19)
<asynchronous suspension>
#12 main (package:flutter_tools/executable.dart:103:3)
<asynchronous suspension>
[ ] Running 1 shutdown hook
[ ] Shutdown hooks complete
[ +63 ms] exiting with code 1Flutter Doctor output
Doctor output
$ flutter doctor -v
[✓] Flutter (Channel beta, 3.41.0-0.2.pre, on macOS 14.6 23G80 darwin-arm64, locale en-PL)
• Flutter version 3.41.0-0.2.pre on channel beta at /Users/michalkucharski/fvm/versions/3.41.0-0.2.pre
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision a7c4c6bf74 (12 days ago), 2026-01-28 11:28:23 -0800
• Engine revision 15d137647e
• Dart version 3.11.0 (build 3.11.0-296.4.beta)
• DevTools version 2.54.1
• Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google ChromeReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyWeb applications specificallytoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.