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

Using "args" in launch.json for an attach request reports an error #3431

Closed
cycloss opened this issue Jun 25, 2021 · 7 comments
Closed

Using "args" in launch.json for an attach request reports an error #3431

cycloss opened this issue Jun 25, 2021 · 7 comments
Labels
in debugger Relates to the debug adapter or process of launching a debug session is bug
Milestone

Comments

@cycloss
Copy link

cycloss commented Jun 25, 2021

Describe the bug

When trying to attach the debugger to a flutter app I get the error message:

There are multiple observatory ports available.
Rerun this command with one of the following passed in as the appId:

  flutter attach --app-id com.example.myApp
  flutter attach --app-id com.example.myApp (2)

However, there is no configuration option available for type dart in the launch.json for me to be able to specify app-id

My launch.json looks like this:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "debug app",
            "request": "attach",
            "type": "dart",
            "deviceId": "51ABDF9C-C54D-4811-BBDA-E733639AEC51",
        },
    ]
}

To Reproduce
Steps to reproduce the behavior:

  1. Run an app in the terminal with flutter run
  2. Run the debug app launch config specified above.

I've also tried not launching with flutter run by just tapping on the app in the emulator and then trying to attach but the same problem occurs.

Expected behavior

I expected to be able to attach to the running process.

Versions (please complete the following information):

  • VS Code version: 1.57.1
  • Dart extension version: 3.23.1
  • Dart/Flutter SDK version: Flutter 2.2.1, Dart 2.13.1
@cycloss cycloss added the is bug label Jun 25, 2021
@DanTup
Copy link
Member

DanTup commented Jun 25, 2021

There's an open issue about improving this at #2722, although it will require some Flutter tooling changes (since the current message is just text that VS Code can't understand, nor does it know where to get those IDs from).

As a short-term workaround, you should be able to add to the args field in launch.json (["--app-id", "foo"]) though (if that doesn't work for you, let me know and we can re-open this to fix that). Thanks!

@DanTup DanTup closed this as completed Jun 25, 2021
@cycloss
Copy link
Author

cycloss commented Jun 25, 2021

@DanTup thanks for your response. Adding to the args field worked a treat. I initially thought of doing that, but the linter actually reports it as a problem if you add the args field when type is dart so I just assumed it wouldn't work.

The problem message is just: Property args is not allowed, even though it does actually work. Maybe a simple fix is just to allow the args field for the dart type?

@DanTup
Copy link
Member

DanTup commented Jun 25, 2021

Thanks for confirming!

It definitely shouldn't be an error to add args.. I'll re-purpose this to take a look at that. Thanks!

@DanTup DanTup reopened this Jun 25, 2021
@DanTup DanTup changed the title Unable to flutter attach because of multiple observatory ports available Using "args" in launch.json reports an error Jun 25, 2021
@DanTup DanTup changed the title Using "args" in launch.json reports an error Using "args" in launch.json for an attach request reports an error Jun 25, 2021
@DanTup DanTup added the in debugger Relates to the debug adapter or process of launching a debug session label Jun 25, 2021
@DanTup DanTup added this to the v3.24.0 milestone Jun 25, 2021
@cycloss
Copy link
Author

cycloss commented Jun 25, 2021

No problem. It's also worth mentioning that it's only reported as an error when the request is attach. It doesn't report an error when request is launch.

@DanTup
Copy link
Member

DanTup commented Jun 25, 2021

Thanks - I suspected that might be the case as I was updating the title - if I remember correctly they have their own definitions. There's probably not been much reason to use args in attach before this, so may have been left off intentionally, but this seems like good reason to change it - we shouldn't report errors on settings that actually change behaviour.

Thanks!

@cycloss
Copy link
Author

cycloss commented Jun 25, 2021

It's a fairly niche use case, but it is useful to be able to attach the debugger to a running app instead of having to wait a while for a restart when issuing a launch debug request. Thanks for your help.

@DanTup DanTup closed this as completed in 3368f98 Jun 25, 2021
@ksilz
Copy link

ksilz commented Aug 14, 2021

I had the same thing happening when debugging a Flutter app on iOS in IntelliJ. Adding --app-id com.yourhomeingoodhands.mobile.yhigh in the "Additional attach args" field of the "Run/Debug Configuration" of my Flutter app fixed it. That was suggested by somebody in the forum.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in debugger Relates to the debug adapter or process of launching a debug session is bug
Projects
None yet
Development

No branches or pull requests

3 participants