Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 240030 - Environment incorrect for remote process builders
Summary: Environment incorrect for remote process builders
Status: RESOLVED FIXED
Alias: None
Product: PTP
Classification: Tools
Component: Remote Tools (show other bugs)
Version: 2.1M2   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Daniel Felix Ferber CLA
QA Contact: Greg Watson CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-08 13:32 EDT by Chris Recoskie CLA
Modified: 2011-05-14 06:35 EDT (History)
0 users

See Also:


Attachments
proposed patch for RSE process builde (2.08 KB, patch)
2008-07-14 09:19 EDT, Chris Recoskie CLA
g.watson: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Recoskie CLA 2008-07-08 13:32:08 EDT
AbstractRemoteProcessBuilder.environment() just does remoteEnv.putAll(System.getenv());, which sets the environment to be whatever is on the local system, which is not exactly useful for the remote case.  None of the child classes override this behaviour.
Comment 1 Greg Watson CLA 2008-07-09 14:51:40 EDT
Would making this an abstract method and moving the implementation to the child classes be sufficient?
Comment 2 Chris Recoskie CLA 2008-07-10 14:56:23 EDT
(In reply to comment #1)
> Would making this an abstract method and moving the implementation to the child
> classes be sufficient?

Provided that we're going to make some sensible implementations for the child classes, yes.
Comment 3 Greg Watson CLA 2008-07-11 08:56:23 EDT
Ok, I've moved the implementations to the child classes. Any suggestions on what would make sense for the remote versions?
Comment 4 Daniel Felix Ferber CLA 2008-07-11 15:35:33 EDT
For Remote Tools, remoteEnv.putAll(System.getenv()) certainly does not make sense. 

Short term solution: Leaving the remoteEnv empty for RemoteToolsProcessBuilder. The map remoteEnv contains only variables to be added to the default remote environment. I understand that this differs from the LocalProcessBuilder and also differs from the expected behavior. But this solution is better then the current approach.

Reason for the short term solution: The current implementation always inherits the remote environment for new remote processes. Therefore, there is no need to explicitly set the default environment variables. Furthermore, having many environment variables in remoteEnv will increase significantly the length of the command line generated by RemoteProcessBuilder. I am not sure if there is a maximal for a command line handled by SSH and the shall. This might be an issue for many environment variables.

Long term solution: Add environment variables support to processes created by RemoteTools, using SSH support for environment variables. Unfortunately, at the time that RemoteTools was implemented, the underling Jsch library did not support environment variables. Therefore, RemoteTools uses the workaround that inherits environment variables instead of overriding.

Alternative solution: RemoteTools queries the default environment variables on the remote host and initializes remoteEnv with these variables. In oder to create the command line, RemoteProcessBuilder calculates the difference between remoteEnv and the original remote environment queried before. The command line uses the 'env' command to adapt the inherited default environment based on the calculated difference(s).    

Comment 5 Chris Recoskie CLA 2008-07-11 15:38:47 EDT
(In reply to comment #3)
> Ok, I've moved the implementations to the child classes. Any suggestions on what
> would make sense for the remote versions?

I'm working on a patch for the RSE provider.  It has APIs for getting the remote environment.
Comment 6 Daniel Felix Ferber CLA 2008-07-11 15:55:21 EDT
Once this environment variables issue has been fixed, we need o address other related issues described in bug #239251.
Comment 7 Chris Recoskie CLA 2008-07-14 09:19:28 EDT
Created attachment 107327 [details]
proposed patch for RSE process builde
Comment 8 Greg Watson CLA 2008-07-14 16:17:34 EDT
I've applied this patch. I guess we need a similar one for remote tools?
Comment 9 Daniel Felix Ferber CLA 2008-08-21 15:30:06 EDT
I have already commited a similar solution for remote tools.