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

how to run/debug a monorepo project? #193

Open
fnicastri opened this issue Mar 19, 2023 · 10 comments
Open

how to run/debug a monorepo project? #193

fnicastri opened this issue Mar 19, 2023 · 10 comments

Comments

@fnicastri
Copy link

fnicastri commented Mar 19, 2023

Hi,
I'm trying to setup doom emacs to develop a flutter app.
The project is structured as a monorepo, meaning that the main
application is located in a subfolder of the monorepo root.
ex:

mca                      <---- monorepo root
├── Gemfile
├── Gemfile.lock
├── apps                 
│   └── mycollege_app    <---- main app root
├── cl_mycollege.iml
├── codemagic.yaml
├── dictionary.dic
├── mason-lock.json
├── mason.yaml
├── melos.yaml
├── packages
│   ├── cicolabs_analysis
│   ├── cicolabs_authentication_service
│   ├── cicolabs_device_info
│   ├── cicolabs_endpoint
│   ├── cicolabs_http
│   ├── cicolabs_logger
│   ├── cicolabs_payload
│   ├── cicolabs_push_notifications_manager
│   ├── cicolabs_storage
│   ├── cicolabs_widgets
│   ├── cl_utils
│   ├── custom_bubble_navigation_bar
│   ├── error_notifier_for_provider
│   ├── http_interceptor
│   ├── image_picker_widget
│   └── mycollege_widgets
└── todo.md

I managed to edit the dap template (but not save it!?!?) but anyway
when I try to run or debug the app I get an error message:

Error: No pubspec.yaml file found.
This command should be run from the root of your Flutter project.

Any idea how I can configure it?

Thanks

@ericdallo
Copy link
Member

@fnicastri where is your pubspec.yaml?

@fnicastri
Copy link
Author

fnicastri commented Mar 21, 2023

here:

├── apps                 
│   └── mycollege_app    <---- main app root; app pubspec.yaml

Somehow I managed to make it work adding projectile projects in the main root and in the main app.

Is it the right solution?

@fnicastri
Copy link
Author

Nothing, I had to reset my config (did some damage) and now I can't debug it anymore.
I have this structure:

mca                      <---- monorepo root
├── pubspec.yaml.        <---- needed by melos, almost empty
├── Gemfile
├── Gemfile.lock
├── apps                 
│   └── mycollege_app    <---- main app root
│       ├── pubspec.yaml
│       ├── launch.json
│       ├── .vscode/launch.json
│       ├── build/...
│       ├── lib/
│       |   ├── main_development.dart
│       |   ├── main_production.dart
│       |   └── ...
|       └── ...
├── codemagic.yaml
├── melos.yaml
├── packages
│   └── ...
└── ...

For some reason even if I open directly the main app root folder everything keep point to the monorepo root now, no launch.json is recognized (I get only the default templates).
But the lsp server works, I get insights, I can jump to definitions in the project, I get errors just can't run or debug the project.

@ericdallo Any clue?

@ericdallo
Copy link
Member

I see, so it's something only related to debugging.
The way debugging works is via DAP, lsp-dart uses dap-mode and set some flags depending on the project type like flutter, dart etc.

THe current work directory (cwd) is set here, so one thing you can debug in your project is M-: (lsp-dart-get-project-root) and check what the root lsp-dart is returning for that buffer, and check if it's correct.

@fnicastri
Copy link
Author

@ericdallo
I have made some progress but I'm really not familiar with elisp so I'm very slow ;)

I've made a small project to reproduce the issue, you can find it here: fnicastri/flutter_monorepo_test.git

The project works perfectly in VSCode but not in Emacs,

I'm facing three different issues:

  • apparently the cwd parameter in launch.json works differently than vscode, where you can omit ${workspaceFolder}, and produce Setting current directory: No such file or directory, apps/tflutter
  • even adding ${workspaceFolder} is not working, apparently dap-debug try to run the project as a dart project and not like a flutter project nad produce ../../../../fvm/versions/3.3.10/packages/flutter/lib/src/material/animated_icons.dart:9:8: Error: Not found: 'dart:ui' import 'dart:ui' as ui show Paint, Path, Canvas;[...]
  • Even opening the internal app folder apps/tflutter as project lsp-dart-get-project-root still return the main repo folder

Thanks for the support!

@ericdallo
Copy link
Member

Thanks for the repro, I can take a look later in the weekend, but if lsp-dart is not recognizing as a flutter project, that's probably a problem, it should detect using lsp-dart-utils functions that is a valid Flutter project, not a Dart one

@fnicastri
Copy link
Author

@ericdallo

Thank you!

I'm Sorry I can't help more but for now my elisp skills are almost zero, for now... ;)

@fnicastri
Copy link
Author

@ericdallo

trying to make my current project work with Emacs I've simplified the structure moving everything inside a single app project, not the best solution but this project is not very big so I can do that.

With much surprise lsp-dart or dap-dart still think my project is a dart project and not Flutter, spitting out Error: Not found: 'dart:ui' etc etc...

lsp-dart-flutter-project-p return not nil so in theory it should be recognized as a Flutter project.

Everything works in VSCode

Any clue?

@ericdallo
Copy link
Member

hum, it could be related with your flutter instalation so, how you installed flutter?
Could you try setting the variable lsp-dart-flutter-sdk-dir to your flutter installation?

@fnicastri
Copy link
Author

@ericdallo
Flutter sdk was pointing already at the right location but I made some progress.

I noticed in launch.json that VSCode use type dart but lsp-dart needs type flutter and those settings are not interchangeable in the two editors.
With type dart Emacs will run the project as a dart project and with flutter vscode refuse to run the project at all because type flutter is not supported
image

I think this could be one of the reasons why the test project (created with vscode) refuse to run.

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

No branches or pull requests

2 participants