Skip to content

Default/automatic launch configs is missing/incorrect if project is nested inside a folder #2365

Closed

Description

@trimmdavid

i keep on having this problem : Your launch config references a program that does not exist. If you have problems launching, check the "program" field in your ".vscode/launch.json" file.

Activity

  1. DanTup commented on Apr 18, 2020

    @DanTup
    Member

    Can you try:

    • Run the Dart: Capture Logs command (untick Analysis Server, but leave everything else ticked)
    • Try to run your app
    • Click Cancel on the logging prompt to stop logging and open the log file
    • Attach the log file here (make sure there's nothing sensitive in it first)

    Thanks!

  2. added
    awaiting infoRequires more information from the customer to progress
    on Apr 18, 2020
  3. trimmdavid commented on Apr 18, 2020

    @trimmdavid
    Author
  4. DanTup commented on Apr 18, 2020

    @DanTup
    Member

    Sorry, I should've been clearer! :-)

    • Open the VS Code command palette by pressing Ctrl+Shift+P (or on macOS, Cmd+Shift+P)
    • Type "capture logs" to filter the command list, and select the Dart: Capture Logs option
    • Untick Analysis Server (those logs aren't relevant here) and click OK

    This will start capturing logs from the extension (a notification will be shown in the bottom right corner that they're being captured).

    • Try to launch your app so that you get the original error message from above
    • Click Cancel on the logging notification to stop logging, and open the log file
    • Check the log file doesn't include anything sensitive (it may have path/filenames and other things from your project depending on how long you were capturing)
    • Save the log file and attach it here

    Let me know if anything isn't clear. Thanks!

  5. trimmdavid commented on Apr 19, 2020

    @trimmdavid
    Author
  6. DanTup commented on Apr 19, 2020

    @DanTup
    Member

    It looks like in your .vscode/launch.json file, you have:

    "program":"bin/main.dart"
    

    However this file doesn't exist in your project. If it's a Flutter project, this should be "lib/main.dart"(or, if you've not customised the launch.json, you can just delete the file altogether).

    I'm not sure how you ended up with this file with the wrong value though - bin/main.dart is the default value for a (non-Flutter) Dart project. Did you create this file and select the "Dart" template, or has it been created automatically?

  7. trimmdavid commented on May 6, 2020

    @trimmdavid
    Author
  8. DanTup commented on May 6, 2020

    @DanTup
    Member

    @trimmdavid this happens if your launch.json has a program field that is not on your disk. Please capture a log by:

    • Run the Dart: Capture Logs command
    • Leave everything ticked and click OK
    • Try to start your app so that the error appears
    • Click Cancel on the logging notification to stop logging, and open the log file
    • Copy the log file here

    Thanks!

  9. muhammad-hamza-shahid commented on May 15, 2020

    @muhammad-hamza-shahid

    Hi Dan unluckily I am also facing the same problem, every thing was going fine and suddenly it stopped working and this alert started to appear at bottom right corner of my screen saying

    "Your launch config references a program that does not exist. If you have problems launching, check the "program" field in your ".vscode/launch.json" file."

    kindly help me out in this problem.

  10. muhammad-hamza-shahid commented on May 15, 2020

    @muhammad-hamza-shahid

    The above problem is solved, actually I keep on tracking with github so I have the previous working commit of this project, when I checked that out this line:

    "program":"bin/main.dart"

    It was not their and I didn't made any changes in this file aswell, so I deleted this line and and saved my project and when I reopened it every thing worked fine again like it was working before this error.
    Remember I have tried this thing before but I was not closing the editor but when I restarted my editor this alert went of and it started working fine again.

  11. fabiansalamo commented on May 31, 2020

    @fabiansalamo

    Hello, I had this isuue. I solved it by deleting the launch.js file and creating a new config using vs code.

  12. DanTup commented on Jun 1, 2020

    @DanTup
    Member

    You shouldn't really need a launch.json for simple cases, it should just work without. Some actions in VS Code will trigger creation of a launch.json though. If anyone can reproduce a situation where a launch.json is created and populated incorrectly with bin/main.dart (which is the default for a Dart project, but not Flutter), please let me know!

  13. ellonsolomon commented on Jun 3, 2020

    @ellonsolomon

    If there are other projects/folders on your vscode workspace, check and correct their ".vscode/launch.json" file configs. Or just remove those projects from the workspace.

  14. jaerts commented on Jul 1, 2020

    @jaerts

    Thanks, deleting the launch.js file and without creating a new config solved my debug/run problem.
    The problem started after a flutter and dart update.

  15. DanTup commented on Jul 1, 2020

    @DanTup
    Member

    It sounds like a launch.json is being created automatically with incorrect values in it. If anyone is able to reproduce this (and figure out exactly what they did that triggered this - it might be pressing F5 with certain files open, or when the open folder in VS Code is not directly the project root, etc.), please let me know so I can try to get to the bottom of this. Thanks!

  16. 13 remaining items

  17. DanTup commented on Aug 5, 2020

    @DanTup
    Member

    My workspace is set-up like this:

    Thanks - I can repro. The issue here is that your Flutter project is in a sub-folder, so when VS code asks us for the launch.json contents, it's not clear what we should provide (the root folder is neither a Dart or Flutter project). While we could scan the workspace in this case and find your Flutter project, it's also possible we'd find multiple projects. If we return multiple configs here, VS Code would add all of them to the file.

    I'll see if maybe we can take some hints from the current open file, so at least in the case where there's an open file (like in your screenshot) we should find something.

    Apologies, the opposite is true. Without those args, i get refused to connect. I think my laptop has some organisation/firewall that restricts connections through specific ports. When i don't force the port to be a specific value, dart seems to just give a random port, which doesn't work for me.

    Ah, got it. That makes sense now!

  18. changed the title [-]i cant debug/run my flutter app on visual studio code[/-] [+]Default launch.json configuration is incorrect if project is nested inside a folder[/+] on Aug 5, 2020
  19. removed
    awaiting infoRequires more information from the customer to progress
    on Aug 5, 2020
  20. DanTup commented on Aug 5, 2020

    @DanTup
    Member

    Ok, I think I've come up with a reasonable solution for this. For the "Create launch.config", we'll now locate the project roots and create a launch config for each one. In the example above there was only one, but here's an example where the folder had a Dart project and two Flutter projects in it:

    Screenshot 2020-08-05 at 11 26 04

    Similarly, for the "Automatic launch configs" we'll now scan each of those project roots, rather than just the main workspace root and also include options for Dart web and Test:

    Screenshot 2020-08-05 at 11 25 54

  21. changed the title [-]Default launch.json configuration is incorrect if project is nested inside a folder[/-] [+]Default/automatic launch configs is missing/incorrect if project is nested inside a folder[/+] on Aug 5, 2020
  22. modified the milestones: On Deck, v3.14.0 on Aug 5, 2020
  23. added
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    and removed on Aug 5, 2020
  24. Azhar978 commented on Aug 23, 2020

    @Azhar978

    i fixed it by replacing package name.

    from "bin/main.dart"

    to "web/main.dart"

  25. erayhamurlu commented on Apr 1, 2021

    @erayhamurlu

    Ekran Resmi 2021-06-02 08 05 59

    1- Click debug icon from left side

    2- Choose Flutter from dropdown menu

    3- Run your project

    OR

    2- Choose Flutter with your project name

    3- Then click create lauch.json

  26. ranadhaval123 commented on Apr 19, 2021

    @ranadhaval123

    flutter error

    sir i am facing problem in which configuration "flutter_first_application" launch.jason missing

  27. DanTup commented on Apr 19, 2021

    @DanTup
    Member

    @ranadhaval123 please file a new issue, and include the exact steps that led you to that error. Thanks!

  28. Azurik52 commented on Aug 31, 2024

    @Azurik52

    if any of the solutions above didn't help, try to change launch program config like this.

    "program" : "Users/smth/your/way/to/file"
    

    Only this helped me

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    in debuggingRelates to the debug adapter or process of running debug sessionsin flutterRelates to running Flutter appsis enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions