Cd() directory out of C:\\ or D:\\

According to
I’d like to

julia> cd("/home/amend")
ERROR: IOError: chdir /home/amend: no such file or directory (ENOENT)

julia> cd("D:\\Julia") #working
**Is it a must to start from C:\\ or D:\\ (in Window10)? What if I want to cd directory out of them?

In linux filesystem:
/home/amend #this branch
/mnt/d/ #rather than starting from D:\\ here

The tricks as below fails as well.

julia> cd(D:\\..\\..\\home\\amend")
ERROR: syntax: "\" is not a unary operator
julia> cd("~")
ERROR: IOError: chdir ~: no such file or directory (ENOENT)

Use raw"D:\\Julia", as otherwise \\ is interpreted as an escape for a single backslash. Oh, silly me, you want a single backslash here. I can never keep Windows path conventions straight.

You were missing the opening quote. Use cd(raw"D:\..\..\home\Amend")

xkcd 1638


LOL This is why I always use joinpath instead of backslashes. :rofl:

1 Like

Xp. But this seems not to work TAT
julia> cd(raw"D:\…")
julia> cd(raw"D:\…\…")
julia> pwd()

julia> cd(raw"D:\…\…\home")
ERROR: IOError: chdir D:\…\…\home: no such file or directory (ENOENT)

julia> cd(raw"D:\…\…\home\amend")
ERROR: IOError: chdir D:\…\…\home\amend: no such file or directory (ENOENT)

Happy to know more option:)

julia> joinpath("home/amend/ngsJulia/ngsPool", "functions.jl")

julia> pwd()

but it seems not to set home directory or open a file. I guess I didn’t get

  1. what joinpath() should be used for (except termininologies like nodes)
  2. whether it cannot allow path out of mnt as well, if looking at its documentary:

" Join path components into a full path. If some argument is an absolute path or (on Windows) has a drive specification that doesn’t match the drive computed for the join of the preceding paths, then prior components are dropped."

joinpath just correctly creates the path string. You should pass it to cd


Do you mean .. and not ...?

Since D:\ is a root path, why would D:\.. exist?

joinpath creates a path out of components, e.g. joinpath("D:", "home") makes D:\home

The double \ doesn’t show rightly in the post.

Thanks I get it~
but is there any chance to set /home/amend instead of /mnt/d/anyfile as home directory in julia? This would be helpful to work between linux and julia.

if Sys.iswindows()

Thanks but

julia> cd("/home/amend")
ERROR: IOError: chdir /home/amend: no such file or directory (ENOENT)

help?> iswindows

Couldn't find iswindows

Sorry I didn’t remember Sys.iswindows. See here

1 Like

How does joinpath work when you want to construct the full path? Here is returns C:Users and not C:\\Users.

julia> joinpath("C:", "Users")

julia> joinpath("C", "Users")

1 Like

This is discussed in ?joinpath.

1 Like

Thank you.

And the missing backslash joinpath("C:\A","c:b") in the help page for joinpath has already been fixed in the new docs.