{"action":"opened","issue":{"url":"https://api.github.com/repos/bazelbuild/vscode-bazel/issues/24","repository_url":"https://api.github.com/repos/bazelbuild/vscode-bazel","labels_url":"https://api.github.com/repos/bazelbuild/vscode-bazel/issues/24/labels{/name}","comments_url":"https://api.github.com/repos/bazelbuild/vscode-bazel/issues/24/comments","events_url":"https://api.github.com/repos/bazelbuild/vscode-bazel/issues/24/events","html_url":"https://github.com/bazelbuild/vscode-bazel/issues/24","id":387987033,"node_id":"MDU6SXNzdWUzODc5ODcwMzM=","number":24,"title":"Breakpoints may or may not fire depending on the form of `load()` being used","user":{"login":"allevato","id":1062427,"node_id":"MDQ6VXNlcjEwNjI0Mjc=","avatar_url":"https://avatars0.githubusercontent.com/u/1062427?v=4","gravatar_id":"","url":"https://api.github.com/users/allevato","html_url":"https://github.com/allevato","followers_url":"https://api.github.com/users/allevato/followers","following_url":"https://api.github.com/users/allevato/following{/other_user}","gists_url":"https://api.github.com/users/allevato/gists{/gist_id}","starred_url":"https://api.github.com/users/allevato/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allevato/subscriptions","organizations_url":"https://api.github.com/users/allevato/orgs","repos_url":"https://api.github.com/users/allevato/repos","events_url":"https://api.github.com/users/allevato/events{/privacy}","received_events_url":"https://api.github.com/users/allevato/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-12-05T23:12:49Z","updated_at":"2018-12-05T23:12:49Z","closed_at":null,"author_association":"MEMBER","body":"This affects debugging of `.bzl` files that are in the same repository as the target being built.\r\n\r\nLet's imagine we have a workspace named `foo` that contains `bar.bzl`, and we want to place a breakpoint in that file. Under Bazel's `execroot`, there will be a symlink `foo` to the actual directory where the workspace exists (let's call it `$HOME/Scratch/foo`), and `bar.bzl` will be in there as expected.\r\n\r\nLikewise, files referenced from external repository references are under Bazel's `external` directory (relative to `output_base`). _This includes \"external-looking\" references to the **same** workspace._ So in our case, if we refer to `@foo//:bar.bzl`, then that shows up as a symlink in `.../external/foo/bar.bzl` that points to the original file.\r\n\r\nThe problem is, the source location that Bazel tests in the debug server to decide whether a breakpoint should fire differs depending on how the file was `load`ed.\r\n\r\nFor example, if I do the following:\r\n\r\n```\r\nload(\"@foo//:bar.bzl\", ...)\r\n```\r\n\r\nThen Bazel asks \"is there a breakpoint at `/private/var/tmp/_bazel_allevato/<HASH>/external/foo/bar.bzl`?\" This is the form of breakpoint that we send to the debug server [today](https://github.com/bazelbuild/vscode-bazel/blob/master/src/debug-adapter/client.ts#L212-L226). (The reason I implemented this one is because it just happened to work with the repository I was testing against, which references its own `.bzl` files using the repo name.)\r\n\r\nHowever, if I do the following:\r\n\r\n```\r\nload(\"//:bar.bzl\", ...)\r\n```\r\n\r\nThen Bazel asks \"is there a breakpoint at `$HOME/Scratch/foo/bar.bzl`?\" In this case, it appears that it's resolving the `execroot/foo` symlink and then looking relative to that location.\r\n\r\nEven though these are _the same file_, Bazel's path comparison sees them as being different, and a breakpoint set for one won't fire for the other.\r\n\r\nThe only way I can see around this for now is for us to send _two_ breakpoints to the server so that the breakpoint fires regardless of whether the `.bzl` file was loaded using a repository-qualified path or not. 😕"}}
{"actor":{"display_login":"allevato"}}