Some files cannot be copied if output path contains spaces (and on OS without “cp”)

Questions concerning the different calculations performed by SARAH and the output of the information into other formats
Post Reply
Socob
Posts: 30
Joined: 7. Dec 2017, 16:18

Some files cannot be copied if output path contains spaces (and on OS without “cp”)

Post by Socob » 20. Feb 2018, 23:52

In the file “Package/SPheno/SPhenoPreSARAH.m”, I’ve found the following in line 1708:

Code: Select all

Run["cp "<>listfilesOperators[[i]]<>" "<>$sarahCurrentFlavorKitDirWrapper];
This method of copying files doesn’t work if the directory “$sarahCurrentFlavorKitDirWrapper” contains spaces, as it does in my case (even using a symbolic link without spaces pointing to a directory containing the SARAH files doesn’t work if the target directory does contain spaces). If the SARAH files are in a directory “/path with spaces/SARAH/”, running “MakeSPheno[]” prints the following message to the console error stream many times:
cp: target 'spaces/SARAH/Output/model/EWSB/FlavorKit/Wrappers/' is not a directory
More than that, though, this doesn’t work on any operating system which does not have a “cp” program (such as Windows).

While I’m on the issue of using “Run[]” to call external programs, the line

Code: Select all

Run["rm SARAH-Intermediate.m"];
in the files “Package/SPheno/SPhenoMatching.m” and “Package/SPheno/SPheno.m” is also not cross-platform compatible.

FStaub
Site Admin
Posts: 822
Joined: 13. Apr 2016, 14:05

Re: Some files cannot be copied if output path contains spaces (and on OS without “cp”)

Post by FStaub » 21. Feb 2018, 09:26

Hi,

I moved the thread because I don't consider this as a bug: (i) there is no claim that recent SARAH is compatible with Windows. (The last version where this has been the case was 2.X). Since that I never tested it again with Windows, i.e. I can't recommend to use it under that OS. (ii) if SARAH is located in the default and recommended location (Mathematica Applications directory in the home directory) there shouldn't be any problem because user names with whitespace are very uncommon and not supported by most Linux distributions.

I might think of removing the Run commands by something else, but this is a very low priority on my to-do list I must say.

Sorry,
Florian

Socob
Posts: 30
Joined: 7. Dec 2017, 16:18

Re: Some files cannot be copied if output path contains spaces (and on OS without “cp”)

Post by Socob » 21. Feb 2018, 12:10

I completely understand that this is not a priority issue – I mainly wanted to put this somewhere in case anyone else runs into this.

I’m not using Windows myself, so this is not an issue for me, I just assumed that SARAH would more or less automatically be cross-platform compatible because it is a Mathematica package.

In my case, the problem is the method through which SARAH determines its location on the file system. In SARAH.m:

Code: Select all

$sarahDir=SetDirectory[DirectoryName[System`Private`FindFile[$Input]]]
I do have SARAH at “~/.Mathematica/Applications/SARAH”, but that path is in fact a symbolic link pointing somewhere else on my file system. By using SetDirectory[], symbolic links are resolved to their canonical locations, so $sarahDir does not contain “/home/user/.Mathematica/Applications/SARAH/”, but “/path with spaces/SARAH-4.12.3/”, which is where the files are “actually” located. Resolving symbolic links like this is very surprising behavior in my opinion (and I’m not sure why it’s done – there is “ResetDirectory[]” immediately afterwards in SARAH.m).

FStaub
Site Admin
Posts: 822
Joined: 13. Apr 2016, 14:05

Re: Some files cannot be copied if output path contains spaces (and on OS without “cp”)

Post by FStaub » 21. Feb 2018, 14:25

Hi,

yes, SARAH is Mathematica and shall run under Windows. But I have some doubts that all the related codes (SPheno, Calchep, WHIZARD, MG,...) are working with Windows. Thus, I don't put any efforts in being compatible with Windows in any output for third-party codes.

Can you try if it works for you, when you replace

Code: Select all

Run["cp "<>listfilesOperators[[i]]<>" "<>$sarahCurrentFlavorKitDirWrapper];
by

Code: Select all

CopyFile[listfilesOperators[[i]],$sarahCurrentFlavorKitDirWrapper<>StringSplit[listfilesOperators[[i]], "/"][[-1]]];
Cheers,
Florian

Socob
Posts: 30
Joined: 7. Dec 2017, 16:18

Re: Some files cannot be copied if output path contains spaces (and on OS without “cp”)

Post by Socob » 21. Feb 2018, 15:36

FStaub wrote:

Code: Select all

CopyFile[listfilesOperators[[i]],$sarahCurrentFlavorKitDirWrapper<>StringSplit[listfilesOperators[[i]], "/"][[-1]]];
Yes, that works, but again assumes that “/” is the separator character. Wouldn’t it be easier to use

Code: Select all

CopyFile[listfilesOperators[[i]],ToFileName[$sarahCurrentFlavorKitDirWrapper,FileNameTake[listfilesOperators[[i]]]]];
?

FStaub
Site Admin
Posts: 822
Joined: 13. Apr 2016, 14:05

Re: Some files cannot be copied if output path contains spaces (and on OS without “cp”)

Post by FStaub » 21. Feb 2018, 20:14

Thanks, yes, that's better. I was not aware of this command.

Post Reply