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

Remote attach - Breakpoint in file that does not exist #318

Closed
carmalegno opened this issue Jun 26, 2020 · 11 comments
Closed

Remote attach - Breakpoint in file that does not exist #318

carmalegno opened this issue Jun 26, 2020 · 11 comments

Comments

@carmalegno
Copy link

Environment data

  • debugpy version: 1.0.0b11
  • OS and version: Win10
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.6.9
  • Using VS Code or Visual Studio: VSCode

Actual behavior

  1. Message saying "Breakpoint in file that does not exist" after setting a breakpoint in VSCode.
  2. Breakpoint is not working.

Expected behavior

Breakpoint works.

Steps to reproduce:

This problem is similar to issue #144 that @int19h is trying to fix.

launch.json file

			{
				"name": "Python: Remote Attach",
				"type": "python",
				"request": "attach",
				"port": 5678,
				"host": "localhost",
				"pathMappings": [
					{
						"localRoot": "${workspaceFolder}",
						"remoteRoot": "."
					}
				"logToFile": true
				]
			}
  1. Run python3 -m debugpy --listen localhost:5678 --log-to /odoo/debug/ /odoo/odoo-server/odoo-bin --config=/etc/odoo-server.conf
  2. Open python file in VSCode
  3. Set breakpoint
  4. Start remote attach debug

Log files from the server:
debugpy.adapter-3689.log
debugpy.server-3679.log

@int19h
Copy link
Collaborator

int19h commented Jun 26, 2020

From the logs, the mapped path for that breakpoint was /odoo/custom/addons/asset_tracking/asset.py, but the file didn't physically exist (you should be able to see this while the app is running if you hover over the breakpoint). Is that path correct? If not, you might need to adjust "pathMappings" accordingly.

@carmalegno
Copy link
Author

That is correct. The file exists only on the remote server. Does that mean i should copy it locally ?
Sorry, i'm new with this remote debugger thing.

@int19h
Copy link
Collaborator

int19h commented Jun 26, 2020

Sorry, I meant - does the file exist at that exact path remotely, and can be accessed? E.g. if you do cat /odoo/custom/addons/asset_tracking/asset.py on the remote machine, does that work?

@carmalegno
Copy link
Author

Yes. The file exists on that path and i can read it. No permission issue.

@int19h
Copy link
Collaborator

int19h commented Jun 26, 2020

Can you share debugpy.pydevd*.log as well?

@carmalegno
Copy link
Author

i can't find that file. Both in the remote server and the local directory under extensions\ms-python.python-2020.6.90262.

@carmalegno
Copy link
Author

i managed to make it work by modifying my "remoteRoot" in launch.json. From "." to the actual path.

		"configurations": [
			{
				"name": "Python: Remote Attach",
				"type": "python",
				"request": "attach",
				"port": 5678,
				"host": "localhost",
				"pathMappings": [
					{
						"localRoot": "${workspaceFolder}",
						"remoteRoot": "/odoo/custom/addons/asset_tracking"
					},
				
				],
				"logToFile": true
			}
		]

@int19h
Copy link
Collaborator

int19h commented Jun 28, 2020

"." indicates current directory, so the effect of that mapping depends on what that was when you launched debugpy server. I didn't pay close enough attention to your debugpy command line, unfortunately - but it does make sense, since you use absolute path to indicate the starting script (which usually means that the directory where it's located is not your current directory). So, looks like everything is working as it should here. Using absolute paths takes the guesswork out.

@int19h int19h closed this as completed Jun 28, 2020
@aryan02420
Copy link

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Python: Remote Attach",
      "type": "python",
      "request": "attach",
      "connect": {
        "host": "localhost",
        "port": 5678
      },
      "pathMappings": [
        {
          "localRoot": "${workspaceFolder}",
          "remoteRoot": "???"
        }
      ],
      "justMyCode": true
    }
  ]
}

I am inside a dev container and the debugpy server is running on the host. Is there a way to not hardcode the host path "remoteRoot": "/home/aryan/path/to/projectRoot" and use something like "remoteRoot": "${localWorkspaceFolder}" instead?

@int19h
Copy link
Collaborator

int19h commented Jun 6, 2022

Those substitutions are all done by VSCode, so it can only substitute the things that are known on that end.

You can use ${env:...} to substitute arbitrary environment variables tho, so if you can ensure that there is one that is correctly computed and set before running VSCode (e.g. via a script), you could use that instead of hardcoding.

@aryan02420
Copy link

Thank you very much. This is my final setup

devcontainer.json

"containerEnv": {
  "LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}"
},

launch.json

"pathMappings": [
  {
    "localRoot": "${workspaceFolder}",
    "remoteRoot": "${env:LOCAL_WORKSPACE_FOLDER}"
  }
],

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

3 participants