overall, I think run would actually run the string you provide to it; otoh if you look at, for example, how mkdir works: https://github.com/JuliaLang/julia/blob/9a1dbc038587c6072ac99699e416cbc8908054ed/base/file.jl#L171
you will see that it calls different clib on windows. (that’s how Julia makes File works cross-platform so you don’t have to write ugly code yourself, by manipulating /\ strings etc.)
So in your case, ~ is simply ‘not a thing’ on Windows.
When working with paths, it is generally easier to use the functions in Base.FileSystem for these kinds of things, i.e. use homedir() for ~ along with readdir() and mkdir().
This makes it easier to run code across platforms.
Also, for the mkdir example, try:
julia> run(`mkdir "~\\tmp"`)
It should make a folder named ~/tmp starting from the current working directory. Probably not the intended effect.
EDIT: So the mkdir example worked on one computer, but it failed on a different computer (both Win10). That’s probably because one computer had some build tools installed which over-ride some of the default windows commands (mkdir example worked on this one).
This function gets the same parameter installDir, but this function does interpret “~” as %userprofile% on windows.
In that function, the following code is executed:
if !isdir(cobraToolboxDir)
cmd = "git clone git@github.com:opencobra/cobratoolbox.git $cobraToolboxDir"
@info cmd
run(`sh -c $cmd`)
end
In conclusion, I am still not sure when the julia interpret tilde as %userprofile%.
However, I think I can manage to this problem based on the above suggestions.
I think Julia is just passing the tilde without interpreting it.
The git and sh -c commands are interpreting it.
Though on my system, neither version interprets ~ as home directory—both of them create a ~/tmp folder starting from pwd.
EDIT: Tried it on the second computer, and the sh -c version works properly there (again an issue with different build tools). The specific sh command is bundled with git, and it interprets ~ as the home directory. This can be verified by running where sh and sh -c "~" in cmd.