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

envFile is not accepted in launch configuration in Linux/WSL #968

Closed
mcrumiller opened this issue Jul 20, 2023 · 13 comments
Closed

envFile is not accepted in launch configuration in Linux/WSL #968

mcrumiller opened this issue Jul 20, 2023 · 13 comments
Labels
Not a bug Everything works as intended, not a bug.

Comments

@mcrumiller
Copy link

mcrumiller commented Jul 20, 2023

OS: Windows 11 / WSL
VSCode version: 1.80.1
CodeLLDB version: v1.9.2`
Compiler: N/A
Debuggee: N/A

When VSCode is open in Windows, I can use env adn envFile in my launch.json just fine. When I open VSCode and attach to WSL, however, I cannot use either:
image

@vadimcn
Copy link
Owner

vadimcn commented Jul 20, 2023

You are missing "type": "lldb".

@vadimcn vadimcn added the Not a bug Everything works as intended, not a bug. label Jul 20, 2023
@mcrumiller mcrumiller reopened this Jul 20, 2023
@mcrumiller
Copy link
Author

mcrumiller commented Jul 20, 2023

@vadimcn it's not missing, it was simply covered up by the hover text. I've moved it to the top so you can see the full thing:

image

@vadimcn
Copy link
Owner

vadimcn commented Jul 20, 2023

env doesn't make sense for "attach" requests - you can't change the environment of an already running process.

@mcrumiller
Copy link
Author

Hmm ok. I was hoping to read in an env var from a file using envFile and use that variable in the configuration.

@mcrumiller
Copy link
Author

With that in mind, I think envFile makes sense but env does not, correct?

@vadimcn
Copy link
Owner

vadimcn commented Jul 20, 2023

I was hoping to read in an env var from a file using envFile and use that variable in the configuration.

If you want to use expand an environment variable into the launch configuration, you can use this syntax: ${env:NAME}

@mcrumiller
Copy link
Author

Right, but I'm unable to use environmental variables stored in a file because envFile does not appear to be working.

@mcrumiller
Copy link
Author

Sorry, I'll update the issue name. My primary issue is this: I have a python debugging instance that I need to attach the rust LLDB debugger to. I need to send the process ID to the launch configuration. I'm currently doing it using an extra extension that parses the pID from a shell command, but this requires a 3rd-party requirement that I'd like to remove from the process (the shell command extension).

I'm instead writing the pID to an environmental variable file, which I'd like the LLDB launch configuration to read from, but the envFile appears not to work on Linux, although it does just fine in Windows.

@mcrumiller mcrumiller changed the title launch.json doesn't allow env/envFile in Linux/WSL envFile is not accepted in launch configuration in Linux/WSL Jul 20, 2023
@vadimcn
Copy link
Owner

vadimcn commented Jul 20, 2023

envFile is read to set up the environment of the newly launched processes, just like env. It does not participate in launch.json expansion (which, btw, is done by VSCode, not by the extension).

I suppose you could create a custom launch configuration and use Python script(s) to read pid from a file and then use it to attach.

@mcrumiller
Copy link
Author

mcrumiller commented Jul 20, 2023

@vadimcn right--I would like the LLDB launch configuration to be able to read an environmental variable from a file so that it's used when launching the LLDB process. According to #866, this was implemented in 1.9.1, but it appears to have only been implemented for Windows and doesn't work in Linux, unless I'm doing something wrong.

Thank you for the link to custom launches, I will look into that.

@vadimcn
Copy link
Owner

vadimcn commented Jul 20, 2023

it appears to have only been implemented for Windows and doesn't work in Linux, unless I'm doing something wrong.

It was never meant to make envFile entries to be available for expansion into launch.json. What you describe shouldn't be possible... unless VSCode somehow reads it for you.

@mcrumiller mcrumiller closed this as not planned Won't fix, can't repro, duplicate, stale Jul 21, 2023
@mcrumiller
Copy link
Author

Hi @vadimcn, are you willing to help me a bit? I'm attempting go the custom launch route but having a bit of trouble. This is a joint Python+Rust process. I've managed to get LLDB to attach within VSCode to the process (so I know that it works), but it requires some manual work and I'm trying to automate the process.

Here are my steps:

  1. Launch a Python debugging session in VS Code.

  2. Get the process ID, say it's currently 5911.

  3. From an external console, run the following:

    code --open-url "vscode://vadimcn.vscode-lldb/launch/config?{'request':'attach','pid':5911,'sourceLanguages':'rust'}"

    but I get the following error:

    Unable to connect to VS Code server: Error in request.
    Error: connect ENOENT /mnt/wslg/runtime-dir/vscode-ipc-a020798e-fa0b-434e-8705-006478f909d9.sock
        at PipeConnectWrap.afterConnect [as oncomplete] (node:net:1247:16) {
      errno: -2,
      code: 'ENOENT',
      syscall: 'connect',
      address: '/mnt/wslg/runtime-dir/vscode-ipc-a020798e-fa0b-434e-8705-006478f909d9.sock'
    }
    

I'm having a bit of trouble disagnosing here. Is my url malformed?

Thank you!!

@mcrumiller
Copy link
Author

Ok, this was a WSL issue and involved the vscode server cache not being invalidated: microsoft/vscode-remote-release#6997. I've made a little progress, I'll look into this some more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Not a bug Everything works as intended, not a bug.
Projects
None yet
Development

No branches or pull requests

2 participants