Dart-code: Cannot launch DevTools without having Chrome installed

Created on 29 May 2019  路  15Comments  路  Source: Dart-Code/Dart-Code

Flutter app is in debug mode, run "Dart: Open DevTools" command in command palette, it alert below error message "The DevTools service failed to launch the browser. Please raise a bug against the Dart extension for VS Code." pls help check and share a solution to fix it. Thanks in advance~

in commands is enhancement

Most helpful comment

I've made a change for the next version that will launch the local default browser if DevTools reports an error. It will also show a warning ("Dart DevTools was unable to launch Chrome so your default browser was launched instead.") to indicate that this wasn't the intended behaviour.

All 15 comments

Can you click Help -> Toggle Dev Tools in VS Code and see if there's a full error+stack in the Console tab?

Also - do you see this with the simulator or a real device?

Can you also include the output of running flutter packages global list from a terminal.

Thanks!

Debug with simulator

Um...Nothing output while running "flutter packages global list" from terminal

Please check below stack info:

DevTools failed to launch browser Failed to launch browser: ProcessException: No such file or directory
Command: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome http://127.0.0.1:50026/?hide=debugger&theme=dark&uri=http%3A%2F%2F127.0.0.1%3A50015%2FMovkwQuk-XE%3D

0 Chrome._startProcess (package:browser_launcher/src/chrome.dart:128:12)

1 Chrome.start (package:browser_launcher/src/chrome.dart:120:11)

2 registerLaunchDevToolsService. (package:devtools_server/src/server.dart:238:24)

3 VmService._routeRequest (package:vm_service_lib/vm_service_lib.dart:1447:39)

4 VmService._processRequest (package:vm_service_lib/vm_service_lib.dart:1425:25)

5 VmService._processMessageStr (package:vm_service_lib/vm_service_lib.dart:1393:9)

6 VmService._processMessage (package:vm_service_lib/vm_service_lib.dart:1351:7)

7 _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)

8 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)

9 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)

10 _SyncBroadcastStreamController._sendData (dart:async/broadcast_stream_controller.dart:375:20)

11 _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:250:5)

12 _AsBroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:474:11)

13 _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)

14 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)

15 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)

16 _SyncStreamController._sendData (dart:async/stream_controller.dart:764:19)

17 _StreamController._add (dart:async/stream_controller.dart:640:7)

18 _StreamController.add (dart:async/stream_controller.dart:586:5)

19 new _WebSocketImpl._fromSocket. (dart:_http/websocket_impl.dart:1138:21)

20 _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)

21 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)

22 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)

23 _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:68:11)

24 _EventSinkWrapper.add (dart:async/stream_transformers.dart:15:11)

25 _WebSocketProtocolTransformer._messageFrameEnd (dart:_http/websocket_impl.dart:334:22)

26 _WebSocketProtocolTransformer.add (dart:_http/websocket_impl.dart:229:46)

27 _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:120:24)

28 _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)

29 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)

30 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)

31 _SyncStreamController._sendData (dart:async/stream_controller.dart:764:19)

32 _StreamController._add (dart:async/stream_controller.dart:640:7)

33 _StreamController.add (dart:async/stream_controller.dart:586:5)

34 _Socket._onData (dart:io-patch/socket_patch.dart:1774:41)

35 _RootZone.runUnaryGuarded (dart:async/zone.dart:1314:10)

36 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:336:11)

37 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:263:7)

38 _SyncStreamController._sendData (dart:async/stream_controller.dart:764:19)

39 _StreamController._add (dart:async/stream_controller.dart:640:7)

40 _StreamController.add (dart:async/stream_controller.dart:586:5)

41 new _RawSocket. (dart:io-patch/socket_patch.dart:1323:33)

42 _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:844:14)

43 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)

44 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)

45 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:115:13)

um... after install google chrome browser in Mac OS, it works well.
So the DevTool is only able to run with google chrome browser?

Yes, that's correct. DevTools only works with Chrome (for now, at least). We used to launch the default browser but since DevTools might not work in that it was changed to launch Chrome.

I'll update the standard popup message to be more descriptive to give a hint that this might be the issue.

Actually, when the error occurs there should be a button that says Show Full Error that already opens this error. Do you not see this?

Yes, I see that.

Ok, then I think there's nothing to do here for now. The button provides a way to get at the real error that came from DevTools, and DevTools only supporting Chrome is known/expected.

LMK if you think there's something that should be changed and we can revisit :-)

ok, thanks for the info, issue could be closed

Is there a way I can force this to use chromium or some other chromium-based browser rather than chrome?

@point-source it may work if you set the CHROME_EXECUTABLE environment variable, but it's not something I've tried.

Note that the Brave browser - although Chromium-based - fails to work because its anti-fingerprinting feature messes up the canvas rendering (see https://github.com/flutter/devtools/issues/367).

Can confirm that overriding env variable for chromium works on Linux.

export CHROME_EXECUTABLE=chromium

IMHO it would be more user friendly to:

  • start chrome OR chromium by default
  • let override executable in vscode settings
  • catch executable not found exception and print user friendly message

In ba85435cb09f67a1ae11e42751d6ef3e24918ef1 the message was changed slightly to "Dart DevTools was unable to launch Chrome."

Looking for Chromium would need to be done in https://github.com/dart-lang/browser_launcher since that's what DevTools is using to launch the browser (it's not being done by the VS Code extension).

I don't think there's much value in adding a VS Code setting versus using CHROME_EXECUTABLE, they'd just do the same thing but it would leak knowledge about how DevTools/browser_launcher work into VS Code.

That said, when running in remote workspaces, we'll now use the default browser (since we can't launch Chrome when running remotely).. I wonder if we should either fall back to that here, or at least add a button to the message for "User default browser instead". DevTools does show a message about unsupported browsers.

message was changed slightly to "Dart DevTools was unable to launch Chrome."

For me (non-native english speaker) first conclusion comes in to mind while reading this error: Chrome was starting, but failed in process. Since I have open source Chrome (chromium). That must be a case.

What actually happens: google-chrome is required but not installed.

I understand reasoning why it is as is :) Just one of these changes would greatly improve situation:
a) Catch explicit exception that executable not found. Give message that google-chrome is required. Show solution to override that env variable. For me overriding variable is not hard, but finding info to do so, requires time and effort.
b) Auto-handle google-chrome/chromium case. That requires modify that 3rd party lib, user other lib, or smth else. That is not blocked by vscode.

And of-course it's priorities question. Thanks for your work on dart4vscode. It is amazing!

What actually happens: google-chrome is required but not installed.

Unfortunately from the error that occurs (a ProcessException), it's hard to tell that's the case - it could be something else (like it wasn't found in the default location or on PATH, or it just threw an error during launch, etc.). I don't want to code too many assumptions into the VS Code extension about how a dependencies dependency behaves, as it could change.

I think adding a button to that message that says "Use Default Browser" or similar should help. It lets people use it, but still makes it clear that we wanted to (but failed) launch Chrome.

That said, I do think it's a valid request for https://github.com/flutter/devtools or https://github.com/dart-lang/browser_launcher to support Chromium, so I think it's worth also opening an issue there (that would mean avoid you seeing the error with the new button, for ex.).

I've made a change for the next version that will launch the local default browser if DevTools reports an error. It will also show a warning ("Dart DevTools was unable to launch Chrome so your default browser was launched instead.") to indicate that this wasn't the intended behaviour.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FeimiSzy picture FeimiSzy  路  4Comments

mccadi picture mccadi  路  3Comments

rgb1380 picture rgb1380  路  3Comments

mayorbyrne picture mayorbyrne  路  5Comments

jascodes picture jascodes  路  4Comments