Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot run any flutter command #55212

Closed
upasana-khatiwada opened this issue Mar 16, 2024 · 21 comments
Closed

cannot run any flutter command #55212

upasana-khatiwada opened this issue Mar 16, 2024 · 21 comments
Assignees
Labels
area-dart-cli Use area-dart-cli for issues related to the 'dart' command like tool. P0 A serious issue requiring immediate resolution

Comments

@upasana-khatiwada
Copy link

upasana-khatiwada commented Mar 16, 2024

Admin note:

Developers who used the Flutter main channel last Friday, March 15th may see the following error due to dart-lang/tools#252:

Unhandled exception:
type 'Null' is not a subtype of type 'int' in type cast
#0      Session._refreshSessionData.parseContents (package:unified_analytics/src/session.dart:94:43)

From our understanding those that use only stable and beta channels were not affected.

The issue can be worked around by taking these steps:

  1. Locate the telemetry session file: $HOME/.dart-tool/dart-flutter-telemetry-session.json
  2. Delete this file (it will get re-created when you run dart or flutter again

Original issue:

C:\Windows\System32>flutter doctor

Unhandled exception:
type 'Null' is not a subtype of type 'int' in type cast
#0      Session._refreshSessionData.parseContents (package:unified_analytics/src/session.dart:85:43)
#1      Session._refreshSessionData (package:unified_analytics/src/session.dart:89:7)
#2      new Session (package:unified_analytics/src/session.dart:28:5)
#3      new AnalyticsImpl (package:unified_analytics/src/analytics.dart:427:23)
#4      new Analytics (package:unified_analytics/src/analytics.dart:83:12)
#5      getAnalytics (package:flutter_tools/src/reporting/unified_analytics.dart:51:10)
#6      runInContext.<anonymous closure> (package:flutter_tools/src/context_runner.dart:92:24)
#7      AppContext._generateIfNecessary.<anonymous closure> (package:flutter_tools/src/base/context.dart:107:42)
#8      _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:543:23)
#9      AppContext._generateIfNecessary (package:flutter_tools/src/base/context.dart:95:20)
#10     AppContext.get (package:flutter_tools/src/base/context.dart:124:32)
#11     analytics (package:flutter_tools/src/globals.dart:96:36)
#12     _handleToolError (package:flutter_tools/runner.dart:190:13)
#13     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:142:13)
#14     _rootRunBinary (dart:async/zone.dart:1423:47)
#15     _CustomZone.runBinary (dart:async/zone.dart:1315:19)
#16     runZonedGuarded.<anonymous closure> (dart:async/zone.dart:1776:18)
#17     _Zone._processUncaughtError (dart:async/zone.dart:1081:14)
#18     _CustomZone.handleUncaughtError (dart:async/zone.dart:1285:5)
#19     Future._propagateToListeners (dart:async/future_impl.dart:788:16)
#20     Future._completeError (dart:async/future_impl.dart:651:5)
#21     Future._asyncCompleteError.<anonymous closure> (dart:async/future_impl.dart:737:7)
#22     _rootRun (dart:async/zone.dart:1399:13)
#23     _CustomZone.run (dart:async/zone.dart:1301:19)
#24     _CustomZone.runGuarded (dart:async/zone.dart:1209:7)
#25     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1249:23)
#26     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#27     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#28     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#29     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:185:5) 

yes i have checked environment variables
reinstall dart and flutter extension ,
dart version is:

C:\Windows\System32>dart --version
Dart SDK version: 3.3.1 (stable) (Wed Mar 6 13:09:19 2024 +0000) on "windows_x64" 

i cannot run flutter --version as it shows same above error but its 3.19.3 Reinstall Flutter,Restart Command Prompt , restart vs code , restart computer everything

please kindly help

@nielsenko
Copy link

nielsenko commented Mar 16, 2024

Same here. Actually running dart will fail also. I tried both flutter channel stable, beta, and master

I'm running macOS Sonoma 14.4

EDIT: flutter fails on all 3 channels, but dart works on master (the flutter channel)

@nielsenko
Copy link

nielsenko commented Mar 16, 2024

Running dart --disable-analytics (with the dart from flutter master channel, since trying with dart from one of the other channels will fail immediately) will make everything work again - on all channels.

@nielsenko
Copy link

If you can't be bothered to install flutter master just to disable analytics, then you can instead edit ~/.dart-tool/dart-flutter-telemetry.config

diff --git a/.dart-tool/dart-flutter-telemetry.config b/.dart-tool/dart-flutter-telemetry.config
index 795800f..2065c2d 100644
--- a/.dart-tool/dart-flutter-telemetry.config
+++ b/.dart-tool/dart-flutter-telemetry.config
@@ -15,7 +15,7 @@
 #
 # To disable telemetry reporting, set "reporting" to
 # the value "0" and to enable, set to "1":
-reporting=1
+reporting=0

@lrhn lrhn added the area-dart-cli Use area-dart-cli for issues related to the 'dart' command like tool. label Mar 17, 2024
@upasana-khatiwada
Copy link
Author

upasana-khatiwada commented Mar 18, 2024

PS C:\> flutter channel master


Unhandled exception:
type 'Null' is not a subtype of type 'int' in type cast
#0      Session._refreshSessionData.parseContents (package:unified_analytics/src/session.dart:85:43)
#1      Session._refreshSessionData (package:unified_analytics/src/session.dart:89:7)
#2      new Session (package:unified_analytics/src/session.dart:28:5)
#3      new AnalyticsImpl (package:unified_analytics/src/analytics.dart:427:23)
#4      new Analytics (package:unified_analytics/src/analytics.dart:83:12)
#5      getAnalytics (package:flutter_tools/src/reporting/unified_analytics.dart:51:10)
#6      runInContext.<anonymous closure> (package:flutter_tools/src/context_runner.dart:92:24)
#7      AppContext._generateIfNecessary.<anonymous closure> (package:flutter_tools/src/base/context.dart:107:42)
#8      _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:543:23)
#9      AppContext._generateIfNecessary (package:flutter_tools/src/base/context.dart:95:20)
#10     AppContext.get (package:flutter_tools/src/base/context.dart:124:32)
#11     analytics (package:flutter_tools/src/globals.dart:96:36)
#12     _handleToolError (package:flutter_tools/runner.dart:190:13)
#13     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:142:13)
#14     _rootRunBinary (dart:async/zone.dart:1423:47)
#15     _CustomZone.runBinary (dart:async/zone.dart:1315:19)
#16     runZonedGuarded.<anonymous closure> (dart:async/zone.dart:1776:18)
#17     _Zone._processUncaughtError (dart:async/zone.dart:1081:14)
#18     _CustomZone.handleUncaughtError (dart:async/zone.dart:1285:5)
#19     Future._propagateToListeners (dart:async/future_impl.dart:788:16)
#20     Future._completeError (dart:async/future_impl.dart:651:5)
#21     Future._asyncCompleteError.<anonymous closure> (dart:async/future_impl.dart:737:7)
#22     _rootRun (dart:async/zone.dart:1399:13)
#23     _CustomZone.run (dart:async/zone.dart:1301:19)
#24     _CustomZone.runGuarded (dart:async/zone.dart:1209:7)
#25     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1249:23)
#26     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#27     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#28     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#29     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:185:5) 

channel master is also not working for me
i have completely removed and install flutter sdk and checked in environment variables any other requirement part this issue is not from my side

@rutvik110
Copy link
Contributor

rutvik110 commented Mar 18, 2024

Running dart --disable-analytics (with the dart from flutter master channel, since trying with dart from one of the other channels will fail immediately) will make everything work again - on all channels.

Facing the same issue on macOS on latest Flutter stable v3.19.3. Disabling analytics does resolves the issue and things seems to work fine when running on Flutter stable versions.

@upasana-khatiwada
Copy link
Author

But for that i need to switch to flutter channel master but this command is not taken or any other flutter command is not taken

PS C:\Users\upasa> flutter channel master

Unhandled exception:
type 'Null' is not a subtype of type 'int' in type cast
#0 Session._refreshSessionData.parseContents (package:unified_analytics/src/session.dart:85:43)
#1 Session._refreshSessionData (package:unified_analytics/src/session.dart:89:7)
#2 new Session (package:unified_analytics/src/session.dart:28:5)
#3 new AnalyticsImpl (package:unified_analytics/src/analytics.dart:427:23)
#4 new Analytics (package:unified_analytics/src/analytics.dart:83:12)
#5 getAnalytics (package:flutter_tools/src/reporting/unified_analytics.dart:51:10)
#6 runInContext. (package:flutter_tools/src/context_runner.dart:92:24)
#7 AppContext._generateIfNecessary. (package:flutter_tools/src/base/context.dart:107:42)
#8 _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:543:23)
#9 AppContext._generateIfNecessary (package:flutter_tools/src/base/context.dart:95:20)
#10 AppContext.get (package:flutter_tools/src/base/context.dart:124:32)
#11 analytics (package:flutter_tools/src/globals.dart:96:36)
#12 _handleToolError (package:flutter_tools/runner.dart:190:13)
#13 run.. (package:flutter_tools/runner.dart:142:13)
#14 _rootRunBinary (dart:async/zone.dart:1423:47)
#15 _CustomZone.runBinary (dart:async/zone.dart:1315:19)
#16 runZonedGuarded. (dart:async/zone.dart:1776:18)
#17 _Zone._processUncaughtError (dart:async/zone.dart:1081:14)
#18 _CustomZone.handleUncaughtError (dart:async/zone.dart:1285:5)
#19 Future._propagateToListeners (dart:async/future_impl.dart:788:16)
#20 Future._completeError (dart:async/future_impl.dart:651:5)
#21 Future._asyncCompleteError. (dart:async/future_impl.dart:737:7)
#22 _rootRun (dart:async/zone.dart:1399:13)
#23 _CustomZone.run (dart:async/zone.dart:1301:19)
#24 _CustomZone.runGuarded (dart:async/zone.dart:1209:7)
#25 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1249:23)
#26 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#27 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#28 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#29 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:185:5)
PS C:\Users\upasa> dart --disable-analytics
An unexpected error was encountered by the Dart CLI.
Please file an issue at https://github.com/dart-lang/sdk/issues/new with the following details:

Invocation: 'dart --disable-analytics'
Exception: 'type 'Null' is not a subtype of type 'int' in type cast'
Stack Trace:
#0 Session._refreshSessionData.parseContents (package:unified_analytics/src/session.dart:85:43)
#1 Session._refreshSessionData (package:unified_analytics/src/session.dart:89:7)
#2 new Session (package:unified_analytics/src/session.dart:28:5)
#3 new AnalyticsImpl (package:unified_analytics/src/analytics.dart:427:23)
#4 new Analytics (package:unified_analytics/src/analytics.dart:83:12)
#5 createUnifiedAnalytics (package:dartdev/src/unified_analytics.dart:23:10)
#6 DartdevRunner.runCommand (package:dartdev/dartdev.dart:182:27)
#7 CommandRunner.run. (package:args/command_runner.dart:122:25)
#8 new Future.sync (dart:async/future.dart:305:31)
#9 CommandRunner.run (package:args/command_runner.dart:122:14)
#10 runDartdev (package:dartdev/dartdev.dart:57:29)
#11 main (file:///C:/b/s/w/ir/x/w/sdk/pkg/dartdev/bin/dartdev.dart:11:9)
#12 _delayEntrypointInvocation. (dart:isolate-patch/isolate_patch.dart:293:33)
#13 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)

@nielsenko
Copy link

@upasana-khatiwada The easiest way is just to edit ~/.dart-tool/dart-flutter-telemetry.config so that reporting=0. That way you don't need to install dart from flutter channel master first.

@Sid1214
Copy link

Sid1214 commented Mar 18, 2024

@nielsenko where can I find this config file?

@mraleph
Copy link
Member

mraleph commented Mar 18, 2024

We are experiencing some serious breakage with analytics. Can you take a look @eliasyishak?

This spread to our own checked in SDK and broke local builds as well. We might need to roll something back or land a hot fix quickly.

cc @mit-mit @a-siva @bkonyi @athomas

@eliasyishak
Copy link
Contributor

The changes to fix this issue are now at the tip of master for dart-lang/tools and should be rolling downstream.

The issue here is that we mistakingly removed a key from the json file we use for the package but have returned it in the latest version 5.8.8.

Deleting the json file should reset the state back to working if you can't wait for the downstream roll.

The file is located at $HOME/.dart-tool/dart-flutter-telemetry-session.json

@mit-mit
Copy link
Member

mit-mit commented Mar 18, 2024

Dart roll of the fix from /tools to SDK in https://dart-review.googlesource.com/c/sdk/+/358220

@alexmarkov
Copy link
Contributor

Roll 87473f8 doesn't fix the problem for me.
I still see this error when building Dart SDK locally at d243eb1:

Invocation: 'dart compile js -o gen/runtime/observatory/observatory/web/main.dart.js --packages=../../.dart_tool/package_config.json ../../runtime/observatory/web/main.dart --minify'
Exception: 'type 'Null' is not a subtype of type 'int' in type cast'
Stack Trace:
#0      Session._refreshSessionData.parseContents (package:unified_analytics/src/session.dart:85:43)
#1      Session._refreshSessionData (package:unified_analytics/src/session.dart:89:7)
#2      new Session (package:unified_analytics/src/session.dart:28:5)
#3      new AnalyticsImpl (package:unified_analytics/src/analytics.dart:421:23)
#4      new Analytics (package:unified_analytics/src/analytics.dart:83:12)
#5      createUnifiedAnalytics (package:dartdev/src/unified_analytics.dart:23:10)
#6      DartdevRunner.runCommand (package:dartdev/dartdev.dart:177:27)
#7      CommandRunner.run.<anonymous closure> (package:args/command_runner.dart:122:25)
#8      new Future.sync (dart:async/future.dart:306:31)
#9      CommandRunner.run (package:args/command_runner.dart:122:14)
#10     runDartdev (package:dartdev/dartdev.dart:58:29)
#11     main (file:///b/s/w/ir/x/w/sdk/pkg/dartdev/bin/dartdev.dart:11:9)
#12     _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:293:33)
#13     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)

This error is issued by dart from checked-in Dart SDK version (3.4.0-108.0.dev).
Dart SDK builds on Golem bots are also affected.

@bkonyi
Copy link
Contributor

bkonyi commented Mar 19, 2024

I encountered the same thing. I think we need to get a new checked-in version of the Dart SDK with the roll to fix this issue.

@bkonyi
Copy link
Contributor

bkonyi commented Mar 19, 2024

I've got a CL here to update the pinned SDK to a dev build from this morning: https://dart-review.googlesource.com/c/sdk/+/358540. Not sure if there's a process to do this, but I just followed the README from tools/sdks/.

copybara-service bot pushed a commit that referenced this issue Mar 19, 2024
Includes fix for #55212 which is
causing build breakages.

Change-Id: Ie665b71970fd8ff2103f6fe5d7d1411ac6f8adc0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/358540
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
@mit-mit
Copy link
Member

mit-mit commented Mar 21, 2024

@eliasyishak @bkonyi anymore known work here, or can we resolve this?

@bkonyi
Copy link
Contributor

bkonyi commented Mar 21, 2024

I think this can probably be resolved. The fix has rolled into the SDK and the pinned SDK has been rolled so we're not seeing this error during builds anymore.

@bkonyi bkonyi closed this as completed Mar 21, 2024
@mraleph
Copy link
Member

mraleph commented Mar 21, 2024

I was under the impression that original reporters were Flutter developers? Should something be cherry-picked into the stable / beta to prevent breakages when developers jump between channels?

@eliasyishak
Copy link
Contributor

Only users on the master branches for flutter and dart were affected, so likely the people affected were flutter/dart team members and community contributors.

The latest fix we made to package:unified_analytics last week ensures that our current master channel won't have backwards compatibility issues with our current stable and beta channels so I don't believe we need to make any hotfixes.

@mraleph
Copy link
Member

mraleph commented Mar 21, 2024

@eliasyishak thanks for confirming!

@SaugatPoudell
Copy link

How did you guys solved the above mentioned problem??

@eliasyishak
Copy link
Contributor

eliasyishak commented Mar 22, 2024

@SaugatPoudell please refer to the admin note in the top issue for the workaround if you are still running into this error. You should also be able to update from the master branch to get the patch to this error though and not have to use the workaround

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-dart-cli Use area-dart-cli for issues related to the 'dart' command like tool. P0 A serious issue requiring immediate resolution
Projects
None yet
Development

No branches or pull requests