Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Julia and windows user names with ligature letters #14357

Closed
hustf opened this issue Dec 10, 2015 · 33 comments
Closed

Julia and windows user names with ligature letters #14357

hustf opened this issue Dec 10, 2015 · 33 comments
Labels
system:windows Affects only Windows

Comments

@hustf
Copy link

hustf commented Dec 10, 2015

I have not seen this issue mentioned anywhere, although it has probably been around for all Julia versions.

Letters like æ, ø, å commonly appear in names. In my name, for one, they appear every single time. This means I can't easily use Julia professionally, as I can't just establish a new user name at work. On personal computers, I have established 'Julia only' user names. There may be other workarounds, but those would not be apparent to other new Julia users.

               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.4.2 (2015-12-06 21:47 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  x86_64-w64-mingw32

ERROR: SystemError: opening file C:\USERS\FRO\;\.julia_history: No such file or directory
 in open at iostream.jl:90
 in setup_interface at REPL.jl:746
 in run_frontend at REPL.jl:858
 in run_repl at REPL.jl:167
 in _start at client.jl:420

INFO: Disabling history file for this session.
julia>

If this is fixed within Julia, it may still be an issue when using Python packages?

@ViralBShah ViralBShah added the system:windows Affects only Windows label Dec 10, 2015
@stevengj
Copy link
Member

@hustf, what does homedir() return? What are ENV["HOME"], ENV["HOMEDRIVE"], and ENV["HOMEPATH"]?

@stevengj
Copy link
Member

Maybe we should be using SHGetFolderPath on Windows.

@ScottPJones
Copy link
Contributor

Wouldn't you want the non deprecated function though?

@hustf
Copy link
Author

hustf commented Dec 10, 2015

julia> homedir()
"C:\\USERS\\FRO\\;"

@hustf
Copy link
Author

hustf commented Dec 10, 2015

Is this actually a Windows issue? Os x does not permit such letters in the username. With windows, the local user name as used in the folder structure is not chosen by the user, but is generated automatically based on, for example, the Microsoft account name. The full directory name to user files is hidden with the common usage patterns.

@hustf
Copy link
Author

hustf commented Dec 10, 2015

Oh, I missed these @stevengj

julia> ENV["HOME"]
"C:\USERS\FRO;"

julia> ENV["HOMEDRIVE"]
"C:"

julia> ENV["HOMEPATH"]
"\Users\FrøRestofFirstName"

@stevengj
Copy link
Member

So, it seems like we would be okay if we ignored ENV["HOME"], but it still seems like it would be better to call an API function for this. See also #11331.

@stevengj
Copy link
Member

Please try:

immutable GUID
    data1::UInt32
    data2::UInt16
    data3::UInt16
    data4_0::UInt8
    data4_1::UInt8
    data4_2::UInt8
    data4_3::UInt8
    data4_4::UInt8
    data4_5::UInt8
    data4_6::UInt8
    data4_7::UInt8
end
const FOLDERID_Profile = GUID(0x5e6c858f, 0x0e22, 0x4760,
                               0x9a, 0xfe, 0xea, 0x33, 0x17, 0xb6, 0x71, 0x73)
function whomedir()
    p = Ref{Ptr{Cwchar_t}}()
    ok = ccall((:SHGetKnownFolderPath,"shell32"), stdcall, UInt32, (Ref{GUID},UInt32,Ptr{Void},Ref{Ptr{Cwchar_t}}),
               FOLDERID_Profile, 0, C_NULL, p)
    ok != 0 && error("failure $ok calling SHGetKnownFolderPath")
    s = wstring(p[])
    ccall((:CoTaskMemFree,"ole32"), stdcall, Void, (Ptr{Cwchar_t},), p[])
    return bytestring(s)
end

whomedir()

This works on a Windows machine I tried, and lets us get the home directory without using ENV.

@vtjnash
Copy link
Member

vtjnash commented Dec 10, 2015

libuv also has that functionality in the next version http://docs.libuv.org/en/v1.x/misc.html#c.uv_os_homedir

why do you have a HOME variable defined? that is likely to confuse posix-based programs like git and cygwin.

@hustf
Copy link
Author

hustf commented Dec 10, 2015

stevengj, confirmed:

| | || | | | (| | | Version 0.4.2 (2015-12-06 21:47 UTC)
/ |__'|||'_| | Official http://julialang.org/ release
|
/ | x86_64-w64-mingw32

ERROR: SystemError: opening file C:\USERS\FRO;.julia_history: No such file or directory
in open at iostream.jl:90
in setup_interface at REPL.jl:746
in run_frontend at REPL.jl:858
in run_repl at REPL.jl:167
in _start at client.jl:420

INFO: Disabling history file for this session.
julia> immutable GUID
data1::UInt32
data2::UInt16
data3::UInt16
data4_0::UInt8
data4_1::UInt8
data4_2::UInt8
data4_3::UInt8
data4_4::UInt8
data4_5::UInt8
data4_6::UInt8
data4_7::UInt8
end

julia> const FOLDERID_Profile = GUID(0x5e6c858f, 0x0e22, 0x4760,
julia> const FOLDERID_Profile = GUID(0x5e6c858f, 0x0e22, 0x4760,
0x9a, 0xfe, 0xea, 0x33, 0x17, 0xb6, 0x71, 0x73)
GUID(0x5e6c858f,0x0e22,0x4760,0x9a,0xfe,0xea,0x33,0x17,0xb6,0x71,0x73)

julia> function whomedir()
julia> function whomedir()
julia> function whomedir()
julia> function whomedir()
julia> function whomedir()
julia> function whomedir()
julia> function whomedir()
julia> function whomedir()
julia> function whomedir()
julia> function whomedir()
julia> function whomedir()
julia> function whomedir()
julia> function whomedir()
julia> function whomedir()
julia> function whomedir()
julia> function whomedir()
julia> function whomedir()
julia> function whomedir()
julia> function whomedir()
julia> function whomedir()
julia> function whomedir()
julia> function whomedir()
julia> function whomedir()
julia> function whomedir()
julia> function whomedir()
julia> function whomedir()
julia> function whomedir()
julia> function whomedir()
julia> function whomedir()
julia> function whomedir()
julia> function whomedir()
julia> function whomedir()
p = Ref{Ptr{Cwchar_t}}()
ok = ccall((:SHGetKnownFolderPath,"shell32"), stdcall, UInt32, (Ref{GUID},UInt32,Ptr{Void},Ref{Ptr{Cwchar_t}}),
FOLDERID_Profile, 0, C_NULL, p)
ok != 0 && error("failure $ok calling SHGetKnownFolderPath")
s = wstring(p[])
ccall((:CoTaskMemFree,"ole32"), stdcall, Void, (Ptr{Cwchar_t},), p[])
return bytestring(s)
end
whomedir (generic function with 1 method)

julia>

julia> whomedir()
"C:\Users\FrøRestOfFirstName"

julia>

@stevengj
Copy link
Member

@vtjnash, uv_os_homedir seems like the way to go if we are switching to the new libuv before long.

@hustf
Copy link
Author

hustf commented Dec 10, 2015

vtjnash, I have defined a PATH variable because I want to start Julia from the github command line. I may have a HOME variable because some other licensed software I'm using requires it. I don't know.

@tkelman
Copy link
Contributor

tkelman commented Dec 11, 2015

@hustf can you try adding pop!(ENV, "HOME") to your etc/julia/juliarc.jl? Would have to check what order that gets loaded vs the REPL history file.

@hustf
Copy link
Author

hustf commented Dec 11, 2015

@tkelman - Julia starts with no error messages. And the history file is present on a second start-up.

I run into this problem:

Pkg.add("IJulia")
(cloning cache, installing BinDeps to Zlib)
ERROR: LoadError: KeyError: HOME not found
 [inlined code] from env.jl:37
 in getindex at env.jl:79
 in pop! at env.jl:82
 in include at boot.jl:261
 in include_from_node1 at loading.jl:304
 in load_juliarc at client.jl:310
 in process_options at client.jl:234
 in _start at client.jl:378
while loading C:\Users\FrøRestOfUserName\AppData\Local\Julia-0.4.2\etc\julia\juliarc.jl, in expression starting on line 8
ERROR: Build process failed.
 in build! at pkg/entry.jl:701
 in build at pkg/entry.jl:720
 in resolve at pkg/entry.jl:426
 in edit at pkg/entry.jl:26
 in anonymous at task.jl:447
 in sync_end at task.jl:413
 [inlined code] from task.jl:422
 in add at pkg/entry.jl:46
 in add at pkg/entry.jl:73
 in anonymous at pkg/dir.jl:31
 in cd at file.jl:32
 in cd at pkg/dir.jl:31
 in add at pkg.jl:23

So this is the current contents of .juliarc:

ENV["PATH"] = JULIA_HOME*";"*joinpath(JULIA_HOME,"..","Git","bin")*";"*ENV["PATH"]
pop!(ENV,"HOME")

Jumping to MS-DOS, it turns out that the environment variable HOME is pretty unusable anyway:

C:\Users\FrøRestOfUserName>echo %HOME%
C:\USERS\FRO\;
C:\Users>cd %HOME%
Systemet finner ikke angitt bane.

I do not know which program defined the HOME environment variable. Perhaps Anaconda did? I try to delete it.

[pao: code block format fixes]

@hustf
Copy link
Author

hustf commented Dec 11, 2015

Deleting this malformed HOME environment variable seems to solve everything. So this issue can be closed I guess.

The HOME variable is not normally defined in Windows as far as I know, but it is defined by logon scripts at for example my workplace, where it is used by licensing software and for document checkouts. Perhaps using it on Windows system is not the most robust way for Julia.

@stevengj
Copy link
Member

Arguably, we should close this issue by not preferentially looking at HOME on Windows. This would be fixed by calling uv_os_homedir, it sounds like, or by adopting a similar algorithm.

@hustf
Copy link
Author

hustf commented Dec 11, 2015

Ok. The following is not a Julia issue, I guess, but I can't build IJulia;
The error messages are quite extensive and I suppose this is not the place for it.

===============================[ ERROR: IJulia ]================================
LoadError: UnicodeError: invalid character index
while loading C:\Users\FrøRestOfUserName.julia\v0.4\IJulia\deps\build.jl, in expression starting on line 129

@stevengj
Copy link
Member

@hustf, please file an IJulia issue. In general, we like to keep issues focused on a single bug at a time.

@hustf
Copy link
Author

hustf commented Dec 13, 2015

stevengj, the 'IJulia issue' will be fixed when BinDeps is tagged. As per now, many or all Windows users must checkout BinDeps to make it and dependent packages work.

JuliaPackaging/BinDeps.jl#191
JuliaPackaging/BinDeps.jl@a4841d9

This calls for further improvements and may be the reason why the BinDeps fix is not tagged:
#14314

@tkelman
Copy link
Contributor

tkelman commented Dec 13, 2015

I'll tag BinDeps anyway. There are some fixes still needed but it shouldn't hurt to tag more often.

@vtjnash
Copy link
Member

vtjnash commented Jun 29, 2016

seems there's no bug here

@vtjnash vtjnash closed this as completed Jun 29, 2016
@stevengj
Copy link
Member

stevengj commented Jun 29, 2016

@vtjnash, I don't think the original issue has been fixed. The problem is that ENV["HOMEPATH"] is correct but ENV["HOME"] is truncated. (The IJulia business was somewhat separate.) See also #11331.

(Are we using a version of libuv that supplies uv_os_homedir yet?)

@stevengj stevengj reopened this Jun 29, 2016
@tkelman
Copy link
Contributor

tkelman commented Jun 29, 2016

Are we using a version of libuv

Yes, pretty sure we are now.

@stevengj
Copy link
Member

Yup, we are using julia-uv1.9.0 and this function I think appeared in libuv 1.6.

@hustf
Copy link
Author

hustf commented Jun 29, 2016

How should I test this, now? Which version?

@tkelman
Copy link
Contributor

tkelman commented Jun 29, 2016

If you can try to reproduce the issue with the latest 0.5-dev nightly that would be useful, thanks!

@hustf
Copy link
Author

hustf commented Jun 29, 2016

Ok, will have to download it first. Any special PATH settings?

@stevengj
Copy link
Member

@hustf, although even if we are linking a libuv with uv_os_homedir, we aren't calling it yet, so I don't think the issue will be fixed.

@stevengj
Copy link
Member

In particular, our homedir() function on Windows still preferentially uses the HOME environment variable.

@hustf
Copy link
Author

hustf commented Jun 29, 2016

  | | |_| | | | (_| |  |  Version 0.5.0-dev+4990 (2016-06-29 01:07 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit 05f2e31* (0 days old master)
|__/                   |  x86_64-w64-mingw32

julia> ENV["HOME"]
"C:\\Users\\Æøå"

julia> homedir()
"C:\\Users\\Æøå"

I created a new user with administrative rights to do this. The HOME variable is set to %USERPROFILE%. Which is the reasonable value.

Users without administrative rights can not have their own set of environment variables, but inherits system level environment variables. When setting the system level HOME to %USERPROFILE%, Windows in this case does not parse this variable correctly. Julia will then also create an error similar to that in the first post.

@vtjnash
Copy link
Member

vtjnash commented Sep 12, 2017

now uses uv_os_homedir

@vtjnash vtjnash closed this as completed Sep 12, 2017
@tkelman
Copy link
Contributor

tkelman commented Sep 12, 2017

originally reported issue should be tested for

@tkelman tkelman added the needs tests Unit tests are required for this change label Sep 12, 2017
@vtjnash
Copy link
Member

vtjnash commented Sep 12, 2017

Original issue was a user configuration error

@vtjnash vtjnash removed the needs tests Unit tests are required for this change label Sep 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
system:windows Affects only Windows
Projects
None yet
Development

No branches or pull requests

6 participants