How to set environment variables for remote debugging?
I have set environment variables for my program in the Run/Debug Configurations (see screenshot below).
When I run the program normally, the program sees the environment variables I have set (ROS_MASTER_URI, in this case). But when I run it with the debugger, the environments variables I have set in the Run/Debug Configurations are ignored (are not set).
I am doing remote development/debugging.
Here the snippet of code I am using to print out the env. variables actually set
int main(int argc, char **argv, char **envp) {
for (char **env = envp; *env != 0; env++) {
char *thisEnv = *env;
std::cout << thisEnv << std::endl;
}
\\ ...
How can I set the environment variables for my program, when doing remote debugging?
As a workaround, I have tried setting those variables in the .bashrc of the remote system, but they got ignored nevertheless.
Because of this issue, I am unable to remote debug ROS applications.

请先登录再写评论。
Hello!
We can't reproduce the issue with a default "Hello, World!" project in CLion 2019.3.3 on our side - environment variables are printed when debugging in full remote mode.
Is the issue reproducible with the "Hello, World!" project (`File | New Project` > `C++ Executable` > `Create`) for you?
No, I couldn't reproduce it either. Thank you for checking.
The project where I observed the issue uses ROS, setting up the environment is quite involved. I will see if I manage to make a simpler project which still reproduces the issue.
I managed to reproduce it with "Hello, World!" and full remote development, both when remote running and remote debugging the program.
It seems related to the fact that the environment variable ROS_MASTER_URI is already defined in my local environment, with that same value "http://localhost:11311".
Here how I reproduced it.
Type the environment variable and its value in the "Environment Variables" field; it must be a variable-value pair already defined in the local environment:
Click on the rectangular icon at the right end of the input field, to open the "Environment Variables" dialog.
Make sure that "Include system environment variables" is not checked, but don't change anything else, and click "OK". The "Environment Variables" field is now blank. At the next remote run of the program (debug or not), that env. variable will not be defined.
Francesco, thanks a lot for the testing and for the detailed description! It seems to be https://youtrack.jetbrains.com/issue/IDEA-230507. Please comment or upvote the issue in order to get updates. The issue's author describes some workaround with the "Rollback" button, you can try using it.
See https://intellij-support.jetbrains.com/hc/en-us/articles/207241135-How-to-follow-YouTrack-issues-and-receive-notifications if you are not familiar with YouTrack.