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

debug: prompt users with helpful info when launch is requested without main or test packages #94

Open
sivan-koren opened this issue May 25, 2020 · 6 comments
Labels
debug/config Issues for config discrepancies b/n settings.json, launch.json, launch with F5, run test, debug test Debug Issues related to the debugging functionality of the extension. FeatureRequest NeedsFix The path to resolution is known, but the work has not been done.

Comments

@sivan-koren
Copy link

Is your feature request related to a problem? Please describe.
If the active tab does not contain the main package when we start debugging the debugger exits with the following message:
go run: cannot run non-main package

This forces the user to change tabs before debugging, distracting from the code of interest.

Describe the solution you'd like
When debugging starts, all currently open tabs should be checked for a main package and if found the file associated with that tab should be passed to go run instead of the file associated with the active tab.

Describe alternatives you've considered
Custom workspace settings maybe?

@sivan-koren sivan-koren changed the title Debugger should try to run the main package instead of failling. Debugger should try to run the main package instead of failing. May 25, 2020
@hyangah
Copy link
Contributor

hyangah commented May 26, 2020

@00Sivan Thanks for the feature request.

If launching a specific program in different location needs to be done frequently, isn't it possible to configure a custom launch.json to point to the program? https://code.visualstudio.com/docs/editor/debugging#_launch-configurations

If you commit launch.json, it will help other project members sharing the workflow, instead depending on the ad-hoc way of finding a main package to run.

And, if multiple main packages or unrelated main package files are open, I am afraid this implicit target choice can lead confusion.

@hyangah hyangah added Debug Issues related to the debugging functionality of the extension. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels May 26, 2020
@sivan-koren
Copy link
Author

sivan-koren commented May 26, 2020 via email

@hyangah
Copy link
Contributor

hyangah commented May 26, 2020

@00Sivan I am not worried about the go compiler. I am worried whether the main package with the open window is really the right one to run. We can't make any assumption about users workflow or authoring pattern in this case.

It's not uncommon to have multiple windows for different main packages open. It's not uncommon to have an unrelated main package open for edit, while editing a different package. Accidentally leaving an unrelated main package source code open can start debugging with that implicitly chosen main package, and I fear that will confuse users.

Since launch.json already allows that kind of customization and provides more flexibility (you can pass parameters and data files) and ability to share with team members, I am not sure if we need this feature.

cc/ @quoctruong @ramya-rao-a

@stamblerre stamblerre changed the title Debugger should try to run the main package instead of failing. debug: automatically infer main package from open files Jun 3, 2020
@sivan-koren
Copy link
Author

sivan-koren commented Jun 25, 2020

You've made some valid points. I can see why the launch.json is the go to. It seems with this in mind that users should be offered for VS to make the appropriate json for us, like other packages and VS features do when faced with ambiguity. A prompt would be much better than a panic with no instructions.

@hyangah
Copy link
Contributor

hyangah commented Jun 25, 2020

@00Sivan yes, that's a reasonable request. The extension should be able to detect this type of errors early (auto/debug mode running against a file with non-main or test package). Or alternatively, we should be able to translate the error from dlv (e.g.: could not launch process: not an executable file currently) to a more user-friendly error message.

@hyangah hyangah changed the title debug: automatically infer main package from open files debug: prompt users with helpful info when launch is requested without main or test packages Jun 25, 2020
@hyangah hyangah added NeedsFix The path to resolution is known, but the work has not been done. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Jun 25, 2020
@gopherbot gopherbot added this to the Untriaged milestone Apr 8, 2021
@hyangah hyangah modified the milestones: Untriaged, Backlog Apr 14, 2021
@polinasok
Copy link
Contributor

Issue #114 is also attempting to rewrite "not an executable file" message as well.

@hyangah hyangah added the debug/config Issues for config discrepancies b/n settings.json, launch.json, launch with F5, run test, debug test label Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debug/config Issues for config discrepancies b/n settings.json, launch.json, launch with F5, run test, debug test Debug Issues related to the debugging functionality of the extension. FeatureRequest NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants