Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 315720

Summary: Default working directory path separator wrong
Product: [Tools] PTP Reporter: Roland Schulz <roland>
Component: RMAssignee: Project Inbox <ptp-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: arossi, g.watson, roland
Version: 4.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows All   
Whiteboard:

Description Roland Schulz CLA 2010-06-04 02:29:39 EDT
0) Run Eclipse on Windows
1) Creating a new parallel run configuration
2) Select a remote RM on a Linux host
3) Under Arguments, deactivate "Use default working directory"
4) Click Browse

The shown directory is with \ (backslash) and not with / (forward slash). As soon as one selects a folder it is correct. But the default directory has the wrong path separator.
Comment 1 Roland Schulz CLA 2010-06-04 02:31:47 EDT
Just to clarify: this is not PBS specific. (Tested with PBS and SLURM)
Comment 2 Roland Schulz CLA 2010-06-04 21:28:57 EDT
The problem is that toOSString() returns the path with the separator correct on the local machine. But toOSString is used in many places where the path can be remote and thus the local separator different than the remote separator. 

Am I missing something or is every call to toOSString for remote paths (there are a lot) a bug? And how is it supposed to be done correctly? 

The two locations which are important specific for this bug
org.eclipse.ptp.remote.ui.dialogs.RemoteResourceBrowser:231
org.eclipse.ptp.rm.pbs.ui.data.PBSBatchScriptTemplate:514
Comment 3 Albert L. Rossi CLA 2010-06-04 21:37:24 EDT
The PBSBatchTemplate code you point to was borrowed from elsewhere, actually.  I assumed that method did what it was supposed to.&#13;&#10;&#13;&#10;The problem of defining the remote separators is foreseen (but not solved) by the org.eclipse.ptp.rm.pbs.ui.utils.ConfigUtils static methods:&#13;&#10;&#13;&#10;&#9;/*&#13;&#10;&#9; * TODO we need some way of determining this dynamically, though I would&#13;&#10;&#9; * imagine in the vast majority of cases PBS will be running on a UNIX-type&#13;&#10;&#9; * system, so it will be "\n".&#13;&#10;&#9; * &#13;&#10;&#9; * @param rEMOTE_LINE_SEP&#13;&#10;&#9; */&#13;&#10;&#9;public static void setREMOTE_LINE_SEP(String rEMOTE_LINE_SEP) {&#13;&#10;&#9;&#9;REMOTE_LINE_SEP = rEMOTE_LINE_SEP;&#13;&#10;&#9;}&#13;&#10;&#13;&#10;&#9;/*&#13;&#10;&#9; * TODO we need some way of determining this dynamically, though I would&#13;&#10;&#9; * imagine in the vast majority of cases PBS will be running on a UNIX-type&#13;&#10;&#9; * system, so it will be "/".&#13;&#10;&#9; * &#13;&#10;&#9; * @param rEMOTE_PATH_SEP&#13;&#10;&#9; */&#13;&#10;&#9;public static void setREMOTE_PATH_SEP(String rEMOTE_PATH_SEP) {&#13;&#10;&#9;&#9;REMOTE_PATH_SEP = rEMOTE_PATH_SEP;&#13;&#10;&#9;}&#13;&#10;&#13;&#10;Certainly these have to be set in a different way.  The code I placed here was simply a placeholder/reminder.&#13;&#10;&#13;&#10;I agree with Roland that this is a bug of "platform-dependent" means "local platform".
Comment 4 Albert L. Rossi CLA 2010-06-04 21:38:37 EDT
I'm sorry about the garbled mess of the last message.  My browser keeps reverting to MacRoman.
Comment 5 Roland Schulz CLA 2010-06-04 22:48:00 EDT
(In reply to comment #3)

The problem is Windows on the client. This should work. And currently doesn't. toOSString returns "\" (backslash) if the *client* is Windows. Thus under the normal case, unix on the server, it breaks. One way to do it, would be to replace all calls to toOSString by calls to toString in remote code. This way the normal case (unix on server) works. But it wouldn't work for cases where the remote code can also be executed locally. Because then it would break for Windows.

I guess the correct way would be to have a toString call which takes the current File manager as argument and calls org.eclipse.ptp.remote.core.IRemoteFileManager.getDirectorySeparator()
to get the correct separator.

What should we do? It is something which should be fixed but it affects a lot of places. Greg?
Comment 6 Albert L. Rossi CLA 2010-06-04 23:09:57 EDT
I agree with Roland that this should be connected to the FileManager for the target resource, whether remote or local.
Comment 7 Greg Watson CLA 2010-06-05 00:00:58 EDT
Sigh. The whole path thing is a pain. IPath is not designed for dealing with local/remote paths so causes all sorts of problems. I think what we need is an IRemotePath that provides toLocalString() and toRemoteString() along with all the other IPath methods. Annoyingly neither IPath nor Path can be extended, however.

We should probably add the interface, but anything else would require fairly extensive changes. Too risky at this stage.

I suggest you just replace toOSString in your code to make it work.
Comment 8 Albert L. Rossi CLA 2010-06-05 00:25:35 EDT
What if we went through a URL or URI?  That is, we take the toOSString(), turn it into a URI-path (with '/'), with the understanding that the proxy on the other end will consider this a URI path, prepend "file:" to it, then create the correct path by doing new File( new URI(wdir) ).getAbsolutePath()?
Comment 9 Albert L. Rossi CLA 2010-06-05 01:01:15 EDT
This would also mean a slight change to our attribute handling.&#13;&#10;&#13;&#10;1.  cd $workingdir  would not get replaced by the client.&#13;&#10;2.  The client sends the workingdir path as a separate attribute&#13;&#10;3.  the proxy does this single replacement on the script after it has converted the path to the local file-system representation.
Comment 10 Albert L. Rossi CLA 2010-06-05 01:03:00 EDT
Let me try that again.

This would also mean a slight change to our attribute
handling.

1.  cd $workingdir  would not get replaced by the client.

2.  The client sends the workingdir path as a separate attribute

3.  the proxy does this single replacement on the script after it has converted the path to the local file-system representation.
Comment 11 Roland Schulz CLA 2010-06-05 01:09:23 EDT
(In reply to comment #10)
> Let me try that again.
> 
> This would also mean a slight change to our attribute
> handling.
> 
> 1.  cd $workingdir  would not get replaced by the client.
> 
> 2.  The client sends the workingdir path as a separate attribute
> 
> 3.  the proxy does this single replacement on the script after it has converted
> the path to the local file-system representation.

Let's not change it again where the attributes get substituted. Let's just replace toOSString by toString. And then when the IRemotePath is in place we use that.
Comment 12 Albert L. Rossi CLA 2010-06-05 01:15:47 EDT
OK, I'm fine with that. We can certainly change the PBSBatchTemplate method.  Shall we also change the RemoteBrowser?
Comment 13 Roland Schulz CLA 2010-06-05 19:25:15 EDT
(In reply to comment #12)
> OK, I'm fine with that. We can certainly change the PBSBatchTemplate method. 
> Shall we also change the RemoteBrowser?

I just committed the change from toOSString to toString for PBS and RemoteBrowser. I leave it open so we can address it fully (with IRemotePath) after the release.
Comment 14 Greg Watson CLA 2011-06-08 17:02:31 EDT
Reducing severity to normal.
Comment 15 Greg Watson CLA 2014-05-29 11:13:20 EDT
Superseded by target configurations.