Page 1 of 1
Some files cannot be copied if output path contains spaces (and on OS without “cp”)
Posted: 20. Feb 2018, 23:52
by Socob
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
in the files “Package/SPheno/SPhenoMatching.m” and “Package/SPheno/SPheno.m” is also not cross-platform compatible.
Re: Some files cannot be copied if output path contains spaces (and on OS without “cp”)
Posted: 21. Feb 2018, 09:26
by FStaub
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
Re: Some files cannot be copied if output path contains spaces (and on OS without “cp”)
Posted: 21. Feb 2018, 12:10
by Socob
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).
Re: Some files cannot be copied if output path contains spaces (and on OS without “cp”)
Posted: 21. Feb 2018, 14:25
by FStaub
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
Re: Some files cannot be copied if output path contains spaces (and on OS without “cp”)
Posted: 21. Feb 2018, 15:36
by Socob
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]]]]];
?
Re: Some files cannot be copied if output path contains spaces (and on OS without “cp”)
Posted: 21. Feb 2018, 20:14
by FStaub
Thanks, yes, that's better. I was not aware of this command.