Problem of precompiling GMT.jl on windows machine

Hello, I am a new GMT.jl user and I am trying to add GMT.jl package on my windows machine. However, it keeps failing and I don’t know what’s the problem.
Here is my command:
julia> Pkg.add(“GMT”)
julia> using GMT
[ Info: Precompiling GMT [5752ebe1-31b9-557e-87aa-f909b540aa54]
gmtwrite [ERROR]: Cannot open file C:\Users\username\AppData\Local\Temp\lixo.dat
[Session GMT (1)]: Error returned from GMT API: GMT_ERROR_ON_FOPEN (15)
[Session GMT (1)]: Error returned from GMT API: GMT_ERROR_ON_FOPEN (15)
[Session GMT (1)]: Error returned from GMT API: GMT_ERROR_ON_FOPEN (15)
ERROR: LoadError: Something went wrong when calling the module. GMT error number = 15
[1] error(s::String)
@ Base .\error.jl:35
[2] gmt(cmd::String, args::Matrix{Float64})
@ GMT C:\Users\username.julia\packages\GMT\OueOM\src\gmt_main.jl:163
[3] gmtwrite(fname::String, data::Matrix{Float64}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ GMT C:\Users\username.julia\packages\GMT\OueOM\src\gmtreadwrite.jl:457
[4] gmtwrite(fname::String, data::Matrix{Float64})
@ GMT C:\Users\username.julia\packages\GMT\OueOM\src\gmtreadwrite.jl:382
[5] macro expansion
@ C:\Users\username.julia\packages\GMT\OueOM\src\GMT.jl:327 [inlined]
[6] top-level scope
@ C:\Users\username.julia\packages\PrecompileTools\kmH5L\src\workloads.jl:140
[7] include
@ .\Base.jl:457 [inlined]
[8] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::Nothing)
@ Base .\loading.jl:2049
[9] top-level scope
@ stdin:3
in expression starting at C:\Users\username.julia\packages\GMT\OueOM\src\GMT.jl:1
in expression starting at stdin:3
ERROR: Failed to precompile GMT [5752ebe1-31b9-557e-87aa-f909b540aa54] to “C:\Users\username\.julia\compiled\v1.9\GMT\jl_35BE.tmp”.
[1] error(s::String)
@ Base .\error.jl:35
[2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, keep_loaded_modules::Bool)
@ Base .\loading.jl:2294
[3] compilecache
@ .\loading.jl:2167 [inlined]
[4] _require(pkg::Base.PkgId, env::String)
@ Base .\loading.jl:1805
[5] _require_prelocked(uuidkey::Base.PkgId, env::String)
@ Base .\loading.jl:1660
[6] macro expansion
@ .\loading.jl:1648 [inlined]
[7] macro expansion
@ .\lock.jl:267 [inlined]
[8] require(into::Module, mod::Symbol)
@ Base .\loading.jl:1611

Is it because of the windows system(22H2)?can someone help me with this error?


That is a very strange error. Specially on Windows. It means that you don’t have permissions to create the lixo.dat file in the system’s temporary directory. The only explanation that occurs to me is that you already had a
file that is not closed. Windows does not let overwrite (or delete) files that are not closed.

Can you reproduce this in the Julia REPL?

julia> t = joinpath(tempdir(), "lixo.dat")

julia> write(t, "BlaBla");

julia> read(t, String)

And note that to install GMT.jl the simplest is to do
] add GMT

I tried what you said, and that part worked. However the GMT.jl still cannot be precompiled:
gmtread: cannot open file C:\Users\username\AppData\Local\Temp\lixo.dat

Hmm, it’s bit different now. Before it was gmtwrite, now is gmtread.

Did you have GMT installed before installing GMT.jl? What does it print, the Windows cmd

gmt --version
gmt --show-date

I just found the reason. It’s because my username file is not English characters. I changed the name and the problem was solved.

Good that you have solved it, but still strange. Both Windows and Julia support unicode so others than the western alphabet should be supported too. And the lines where it errored are not using the user’s name. That is indeed used in creating file names and was a necessity for situations of multi-users linux machines where files in the /tmp had permissions on a per user basis, so I had to create unique names and adding the user name seemed the good solution.