Bug 424436 - Add environment variable support in C/C++ remote launch
Summary: Add environment variable support in C/C++ remote launch
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-other (show other bugs)
Version: Next   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
: 384050 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-12-19 07:09 EST by Xavier Raynaud CLA
Modified: 2020-09-04 15:21 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Xavier Raynaud CLA 2013-12-19 07:09:52 EST
It's not yet possible to set environment variable for C/C++ Remote Application.
Comment 1 Xavier Raynaud CLA 2013-12-19 07:26:58 EST
patch proposal submitted here: https://git.eclipse.org/r/20042
Comment 2 Marc Khouzam CLA 2013-12-23 15:43:12 EST
When testing I noticed a strange behaviour.

The Environment tab has options at the bottom to:
"Append env to native end"
OR
"Replace native env with specified env"

Does that make sense in the case of a remote launch?  What do we mean by the 'native' env?  I'm thinking the 'native' env would be the one on the remote machine, no?

Currently, we use the local's machine 'native' env and push it to the remote machine.  This probably wrong.

Furthermore, doing this causes the other strange behaviour that if we define a variable in the new env tab and leave 'append' selected, the remote environment will have many variables defined (the one we defined plus all 'native' of the host); on the contrary, if we don't define any vars in the new env tab, no environment is sent to the remote at all.

I think that when nothing is define, we should leave the remote env as it is (I'm not sure this is what was happening before this change).  If we do define a variable and choose 'append' we should keep the remote env and add the var.  If we define a var and choose 'replace', then we should only use the new var.

I'm not sure this is possible, as it may require obtaining the remote env...

What do you think?
Comment 3 Xavier Raynaud CLA 2013-12-24 08:44:03 EST
Hi Marc,

Many thanks for your comments.

As far as I know, before this patch, commands are run in a empty environment. Yes, empty env, not the default environment of the target.

For now, I do not know how to retrieve the target environment. I will check.

Perhaps we have to define our own Environment Tab, with 3 options:
* Append to remote env
* Append to local env, and use it on remote
* Replace remote env with specified env
Comment 4 Marc Khouzam CLA 2013-12-24 10:39:56 EST
(In reply to Xavier Raynaud from comment #3)

> As far as I know, before this patch, commands are run in a empty
> environment. Yes, empty env, not the default environment of the target.

You are right.  I wasn't aware of this.  I think it would have been better to keep the default target env, but I'm not sure if RSE supports that, or if we have to find the target env first and pass it to RSE.

> For now, I do not know how to retrieve the target environment. I will check.

Thanks.  I don't know either.

> Perhaps we have to define our own Environment Tab, with 3 options:
> * Append to remote env

Yes.

> * Append to local env, and use it on remote

I'm not sure this one is really necessary.  A target can often be very different than the host so the local env often will not make sense for the target.  And if it does make sense, it should/could be made part of the default remote env anyway.  I don't think we need to provide this option.

> * Replace remote env with specified env

Yes.

So, the good news is that we can keep the env tab as it is, we just have to treat the "native env" it mentions as the one of the remote target.
Comment 5 Xavier Raynaud CLA 2014-01-06 11:24:12 EST
for info: https://bugs.eclipse.org/bugs/show_bug.cgi?id=162018
Comment 6 Marc Khouzam CLA 2014-01-07 13:34:49 EST
(In reply to Xavier Raynaud from comment #5)
> for info: https://bugs.eclipse.org/bugs/show_bug.cgi?id=162018

Xavier, do you want to implement the fix in CDT anyway?  If I understand correctly, we could work around RSE's current behaviour to provide partial functionality now and full functionality automatically once RSE's bug is fixed.  But I didn't look deeply into it so maybe I'm wrong.  Or maybe it is not worth the effort until RSE's bug is fixed?
Comment 7 Xavier Raynaud CLA 2014-01-08 04:25:05 EST
The issue with current implementation in RSE is that we cannot retrieve environment of the target system when using ssh.
Therefore, it's not possible to implement the behaviour described in comment #2 to #4.

I've logged a comment in the RSE bug, in order to know if there is a fix or workaround.
Comment 8 Marc Khouzam CLA 2014-01-10 06:07:36 EST
(In reply to Xavier Raynaud from comment #7)
> The issue with current implementation in RSE is that we cannot retrieve
> environment of the target system when using ssh.
> Therefore, it's not possible to implement the behaviour described in comment
> #2 to #4.

Currently, the only thing the remote launch supports is an empty remote environment.  What we could do to improve this is to add the Env tab with the two options 
"Replace native env with specified env"
"Append env to native end"

The "replace" case would work as expected by only setting the variables set in the Env tab on the target.
The "append" case would not work perfectly because of the RSE bug and would end up doing the same thing as the "replace" case.  But it would automatically start to work as soon as the RSE bug was fixed (no need to update CDT).

I think this would be an improvement on the current situation.  I find that having a broken "append" case is not worse than the current behaviour of always having an empty remote env.
Comment 9 Xavier Raynaud CLA 2014-01-10 06:09:40 EST
Ok for me.
I will submit a patch proposal ASAP.
Comment 10 Marc Khouzam CLA 2014-01-14 15:41:11 EST
Xavier, I just remembered Bug 384050 where some of this work was discussed before.  I believe your efforts got further along, but I thought you should know about it.
Comment 11 Marc Khouzam CLA 2016-04-02 16:21:13 EDT
*** Bug 384050 has been marked as a duplicate of this bug. ***
Comment 12 Marc Khouzam CLA 2016-04-02 16:29:34 EDT
(In reply to Xavier Raynaud from comment #5)
> for info: https://bugs.eclipse.org/bugs/show_bug.cgi?id=162018

There hasn't been any progress on the RSE side, or at least nothing mentioned in the bug.

However, we plan of migrating from RSE to o.e.remote.  See bug 452356.  Once that is done, we can get this bug fixed.