GoogleCloudPlatform / cloud-code-intellij

Plugin to support the Google Cloud Platform in IntelliJ IDEA - Docs and Issues Repository
Apache License 2.0
318 stars 59 forks source link

Debug mode mapping is hard-coded to project root #3021

Open yfried opened 2 years ago

yfried commented 2 years ago

(Please ensure you are running the latest version of Cloud Code for IntelliJ with Help > Check for Updates)

Pycharm version:

PyCharm 2021.2.3 (Professional Edition)
Build #PY-212.5457.59, built on October 19, 2021
Runtime version: 11.0.12+7-b1504.40 x86_64

macOS 11.6

Non-Bundled Plugins: com.intellij.ideolog (203.0.27.0), com.mnr.java.intellij.idea.plugin.base64helper (2.0.3), zielu.gittoolbox (212.7.15), de.netnexus.camelcaseplugin (3.0.8), org.jetbrains.plugins.go-template (212.5457.62), mobi.hsz.idea.gitignore (4.3.0), org.intellij.plugins.hcl (0.7.14), fr.alexisvisco.gitlablinks (1.2), com.intellij.kubernetes (212.5457.4), com.google.gct.core (21.10.1), izhangzhihao.rainbow.brackets (6.21)

When launching it debug mode, there's a prompt to map the project root dir to the target image. This is problematic for mono-repos and any case where the dockerized code isn't the project root.

What is the point of the debug mapping in the run configuration if it's not respected?

etanshaul commented 2 years ago

What is the point of the debug mapping in the run configuration if it's not respected?

If you dismiss the prompt (hitting cancel) then it will ignore the prompt and respect the values in the debug mapping of the run configuration.

I can see how this might be confusing (and we can add some wording). Let me know if this addresses the issue.

But to answer your question specifically - the point of the prompt is to provide some attempted guesses at what the mapping might be. We can't know for sure since the container configuration can vary, which is why we also provide the ability to manually enter the mapping in the run configuration. Also, we prompt after hitting the debug button because Skaffold provides the guesses and it can't know until runtime.

yfried commented 2 years ago

@etanshaul Thank you, but if I hit cancel, then there's no mapping at all. I get:

[billing-bot] pydev debugger: warning: Trying to add breakpoint to file that does not exist: /Users/yfried/<path_on_my_local_machine>/main.py (will have no effect).

I might be missing something here, but unless I create a fake path in my docker image that correlates to the project root, debug doesn't work

yfried commented 2 years ago

In the old remote server config, I could configure mapping as I saw fit and even configure paths to exclude from sync. For example, I could exclude an entire dir, and then only map a certain subdir in it to the remote server

etanshaul commented 2 years ago

Thank you, but if I hit cancel, then there's no mapping at all.

We may have a bug here, but just to confirm: did you set the necessary mapping in the Run Configuration debug tab? Even with that set, debug is not working after hitting cancel on the dialog - correct?

In the old remote server config, I could configure mapping as I saw fit and even configure paths to exclude from sync.

Sorry - what is the "old remove server config" you are referencing?

yfried commented 2 years ago

We may have a bug here, but just to confirm: did you set the necessary mapping in the Run Configuration debug tab? Even with that set, debug is not working after hitting cancel on the dialog - correct?

Yes, I did, and they weren't used.

Sorry - what is the "old remove server config" you are referencing?

Pycharm has a feature for remote debugging, where you can map and sync file to a remote server via ssh and then run debug on it. I assumed Cloud Code mapping would work the same. https://www.jetbrains.com/help/pycharm/remote-debugging-with-product.html#remote-debug-config

etanshaul commented 2 years ago

sounds good. we'll investigate this.

etanshaul commented 2 years ago

Kamino cloned this issue to GoogleCloudPlatform/cloud-code-intellij-internal

shoskensMagics commented 2 years ago

I can add the following; I have a single project with multiple source roots (same as OP). Running embedded skaffold v1.32.0 in PyCharm on Windows. I have configured source mapping in the "Run Configuration debug tab". If I press cancel, it seems the aforementioned source mapping is taken into account (I don't get the 'Trying to add breakpoint to file ...' warning, it seems it can apply the breakpoint), but I can't seem to stop at the set breakpoint... If I press OK (actually for me, the suggested mapping is good), no mapping is configured (I get the 'Trying to add breakpoint to file ...' warning mentioning my project directory on Windows).

Hope it helps, and also waiting patiently for a solution.

etanshaul commented 2 years ago

@shoskensMagics thanks for those details. To confirm - in neither scenario we’re you able to stop at breakpoints? Or did it work when you clicked OK on the dialog?

shoskensMagics commented 2 years ago

@etanshaul no, I could never jump into the debugger at those breakpoints.

uriariel commented 1 year ago

@etanshaul What is the status of the issue? I just encountered it as well.