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

Unable to build anything (no .packages file) #681

Open
MrCyjaneK opened this issue Dec 4, 2022 · 2 comments
Open

Unable to build anything (no .packages file) #681

MrCyjaneK opened this issue Dec 4, 2022 · 2 comments

Comments

@MrCyjaneK
Copy link

Hover doctor

$ flutter doctor
Flutter 3.6.0-0.1.pre • channel beta • https://github.com/flutter/flutter.git
Framework • revision 75927305ff (3 tygodnie temu) • 2022-11-17 05:52:50 +0530
Engine • revision b754eabc98
Tools • Dart 2.19.0 (build 2.19.0-374.1.beta) • DevTools 2.19.0
[...]

Error output

Using hover build [...] --XXX to build my application, I get the following
error:

hover: Generating kernel snapshot
result 97ec1709-f58d-434b-b3b3-f41ff40bad12
Error: Error when reading '.packages': No such file or directory
Error: Error when reading '.packages': No such file or directory
[...]

How to reproduce?

$ flutter create testapp
$ cd testapp
$ flutter run --device-id linux # confirm that the app runs
$ hover init
$ hover build linux # press y when asked

Build will fail.

@MrCyjaneK
Copy link
Author

to fix:

create generate_dot_packages.dart in project root directory with following content:

import 'dart:convert';
import 'dart:io';

Future<void> main() async {
  File file = File(".dart_tool/package_config.json");
  dynamic pkgconfig = jsonDecode(await file.readAsString());
  List<dynamic> pkgs = pkgconfig["packages"];
  for (var elm in pkgs) {
    if (elm["rootUri"] == "../") {
      elm["rootUri"] = "./";
    }
  }
  pkgconfig["packages"] = pkgs;
  print(jsonEncode(pkgconfig));
}

run:

$ dart run generate_dot_packages.dart > .packages

hover build linux-appimage should work.

@evorts
Copy link

evorts commented Jan 29, 2023

I face the same issues and your fix suggestion save the day. thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants