Open upcliujie opened 4 weeks ago
@upcliujie I tried the problem you described on my machine, but I was not able to reproduce the problem you described, can you give me some advice?
@v-frankwang The terminal on win don't set XDGSESSION* to env so don't have this problem.
Using a win PC to connect a linux PC by ssh-remote can reproduce this problem
@v-frankwang This is a relevant code from the cmakeProject.ts file
/**
* Both debugTarget and launchTarget called this funciton, so it's refactored out
* Array.concat's performance would not beat the Dict.merge a lot.
* This is also the point to fixing the issue #1987
*/
async getTargetLaunchEnvironment(drv: CMakeDriver | null, debugEnv?: DebuggerEnvironmentVariable[]): Promise<Environment> {
const env = util.fromDebuggerEnvironmentVars(debugEnv);
// Add environment variables from ConfigureEnvironment.
const configureEnv = await drv?.getConfigureEnvironment();
if ((drv?.useCMakePresets ?? false) && (checkConfigureOverridesPresent(this.workspaceContext.config) ?? false)) {
log.info(localize('launch.with.overrides', `NOTE: You are launching a target and there are some environment overrides being applied from your VS Code settings.`));
}
return EnvironmentUtils.merge([env, configureEnv]);
}
XDFSESSION* is set in ConfigureEnvironment on linux so it will overwrite the environment we set in debugConfig.environment.
@upcliujie Thank you very much for your reply, I have retried the problem as you have given advice, does this reproduce the problem you have described?
@v-frankwang Yes,it's the problem I described.
@gcampbell-msft I reproduced the issue based on the user's prompts and here are the steps I took to reproduce it:
ENV: VS code version: 1.90.0 CMake Extension version: 1.18.42 Remote-ssh: v0.112.0
cmake_minimum_required(VERSION 3.8)
project(test)
add_executable(test main.cpp)
#include <iostream>
#include <cstdlib>
int main() { char xdgSessionId = getenv("XXDG_SESSION_ID"); if (xdgSessionId != nullptr) { std::cout << "XXDG_SESSION_ID: " << xdgSessionId << std::endl; } else { std::cout << "XXDG_SESSION_ID not set" << std::endl; } char xdgSessionType = getenv("XDG_SESSION_TYPE"); if (xdgSessionType != nullptr) { std::cout << "XDG_SESSION_TYPE: " << xdgSessionType << std::endl; } else { std::cout << "XDG_SESSION_TYPE not set" << std::endl; }
return 0;
}
6. Search for Cmake:debug Config in settings, then click Edit in settings.json and add the following code:
{ "cmake.debugConfig": { "environment": [ { "name": "XXDG_SESSION_ID", "value": "2" }, { "name": "XDG_SESSION_TYPE", "value": "wayland" } ] } }
7. Click on "**Launch the selected target in the terminal window**" in the navigation bar below.
Actual result:
![image](https://github.com/microsoft/vscode-cmake-tools/assets/160998958/202ae870-386d-4748-8c4c-f1eb48b51046)
@upcliujie @gcampbell-msft If I manually set the value of XDG_SESSION_TYPE to "wayland" in the terminal using the command: export XDG_SESSION_TYPE=wayland
, and then click the "Launch the selected target in the terminal window" in the navigation bar below, the correct result is displayed.
Brief Issue Summary
Problem 1: The workspace vcode settings :
The code to get XDG_SESSION_ID and XDG_SESSION_TYPE environment with c++ : We can't get the XDG_SESSION_ID and XDG_SESSION_TYPE in debugConfig.environment.
Problem 2: Delete the worksapce vscode settings. Use tmux connect to another tty. Run the code in Problem 1:
We can't get the same XDG_SESSION_ID and XDG_SESSION_TYPE environment value with tmux
CMake Tools Diagnostics
No response
Debug Log
No response
Additional Information
No response