Skip to content

Debug unit test code lens fails with a cargo linking failure #7608

Open
@adaszko

Description

@adaszko

Hi 👋

When I click the "Debug" code lens over a unit test, it fails with a linking error:

error: linking with `cc` failed: exit code: 1
[...]
  = note: /usr/bin/ld: cannot find -lpython3.6m
          collect2: error: ld returned 1 exit status

The source of the problem is this: The PATH environment variable needs to include the /opt/miniconda/bin directory. The problem is, even when I put in the env section in launch.json, it's seems like it's not being respected because it doesn't fix the problem:

{
    "type": "lldb",
    "request": "launch",
    "name": "Debug benchmark 'bench_main'",
    "env": {
        "PATH": ".:/root/.cargo/bin:/opt/miniconda/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin"
    },
    "cargo": {
        "args": [
            "test",
            "--no-run",
            "--bench=bench_main",
            "--package=ddx"
        ],
        "filter": {
            "name": "bench_main",
            "kind": "bench"
        }
    },
    "args": [],
    "cwd": "${workspaceFolder}"
}

OTOH, if I build the code via this launch configuration:

{
	"type": "cargo",
	"command": "build",
	"env": {
		"PATH": ".:/root/.cargo/bin:/opt/miniconda/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin"
	},
	"problemMatcher": [
		"$rustc"
	],
	"group": "build",
	"label": "rust: cargo build"
}

there isn't any linking problem and the code builds fine. So I thought I could use the preLaunchTask in launch.json:

"preLaunchTask": "rust: cargo build",

but it also is being ignored and doesn't address the linking problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-vscodevscode plugin issuesC-bugCategory: bugE-has-instructionsIssue has some instructions and pointers to code to get startedS-actionableSomeone could pick this issue up and work on it right now

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions