"could not read file as String: devtools_extensions/..." if pointing to different version of package without extension present
This is splitting off a separate issue from #8912 from https://github.com/flutter/devtools/issues/8912#issuecomment-2672370477 based on discussion in comment https://github.com/flutter/devtools/issues/8912#issuecomment-2679871965.
If you point to a version of a package that has a devtool extension, then point to another version that does not have that extension present (i.e. built), you get an error about "could not read file".
If you point to a version of rohd which has a devtools extension present (e.g. the artifacts branch), and get it loaded up successfully, it then adds to the devtools_options.yaml file:
description: This file stores settings for Dart & Flutter DevTools. documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states extensions:
- rohd: true If you then point to a version of rohd which does not have the devtools extension (e.g. the main branch), then when you open devtools, the rohd tab is still present but you get an error
could not read file as String: devtools_extensions/rohd_0.0.1/index.html
Is that the intended error message when an extension is not present?
A couple questions:
- Did you run
pub getafter you changed dependencies? Did you also perform a hot restart after making this change? - Did you restart DevTools or was the same DevTools window open the whole time while you were changing dependencies?
Did you run pub get after you changed dependencies?
Yes
Did you also perform a hot restart after making this change?
This is a pure Dart program we're debugging, and we're not doing any hot reload/restart. We stop and restart the entire debug session.
Did you restart DevTools or was the same DevTools window open the whole time while you were changing dependencies?
We closed the DevTools and re-opened it on the new debug session after the pub get
We're seeing the same thing when running the examples locally on Flame too: https://github.com/flame-engine/flame/tree/main/examples
After rebuilding the devtools extension it started to work again for us.
I'm working on reproducing this, and haven't yet. 😁 I have some ideas though and a question while I look:
- When you say "If you point to a version of a package ...", do you mean that you are debugging an app (running DevTools against an app), which depends on a package, which provides a DevTools extension? I think so. In your cases, is the dependency a pub dependency, or a git dependency, or a path dependency? The paths referenced in the
package_config.jsonthat results frompub getare sort of handled differently in those cases; might be relevant.
I tried reproducing with the shared_preferences example app as the app. and the shared_preferences package as the dependency package. I toggled between versions 2.5.3 and 2.4.0 of the shared_preferences package. The devtools app correctly showed and hid the extension as appropriate. I could not get the "could not read file as String" error.
I will also try reproducing with rohd. It doesn't look like intel/rohd is an app, is it? Which app should I debug, which has a dependency on rohd (which provides a DevTools extension), that I can try?
I can also try to reproduce with the flave DevTools extension. It looks like I can use the flame/examples as the app, and the flame package as the dependency package that provides the DevTools extension.
In your cases, is the dependency a pub dependency, or a git dependency, or a path dependency?
In Flame's case it is listed as a pub dependency in the pubspec, but connected locally via pub workspaces.
I don't really remember much from how we triggered it anymore, but it happened to several people. I'll try to see if I can reproduce it too, but I haven't seen the issue since... Could it have been due to moving to a new version of the devtools extension developer packages but not rebuilding the devtools extension itself, or something like that?
I will also try reproducing with rohd. It doesn't look like intel/rohd is an app, is it? Which app should I debug, which has a dependency on rohd (which provides a DevTools extension), that I can try?
ROHD and most dependencies on ROHD are not actually Flutter apps, they are just Dart packages/projects. A good pair for testing could be:
- ROHD (https://github.com/intel/rohd) as the "dependency package"
- ROHD-HCL (https://github.com/intel/rohd-hcl) as the "app", or rather the "project using ROHD"
For ROHD-HCL, you may try testing with something from the example/ or test/ directory
When you say "If you point to a version of a package ...", do you mean that you are debugging an app (running DevTools against an app), which depends on a package, which provides a DevTools extension?
Correct, that's what I meant
In your cases, is the dependency a pub dependency, or a git dependency, or a path dependency?
I think I remember trying it multiple ways, but one way I definitely remember trying is a git dependency on two different branches, one which has the devtools extension and the other that does not.
dependency_overrides:
rohd:
git:
url: https://github.com/intel/rohd.git
# choose one of these:
ref: main # does not have devtool extension present
# ref: artifacts # has devtool extension present