Skip to content

Artifact folder could not be made on Windows.  #3822

@KnutAM

Description

@KnutAM

When running Pkg.add("CairoMakie") in an empty project I'm getting this, Error: "C:\\Users\\meyer\\.julia\\artifacts\\a8244d6d23cbb895fcd39dd3eddb859a0c05d1c6" could not be made, which I seems to occur as the atomic rename fails after #3768.

However, before getting there, I hit JuliaLang/julia#34700, but that could be due to a failure related to above, but the rm is in a final block...

To "fix" the problem, I first hacked Base.rm

function Base.rm(path::String; force::Bool=false, recursive::Bool=false)
   if !(force && recursive)
       return invoke(Base.rm, Tuple{AbstractString}, path; force, recursive)
   else
       max_attempts = 3
       attempts = 0
       while attempts < max_attempts
           attempts += 1
           try
               invoke(Base.rm, Tuple{AbstractString}, path; recursive=true, force=true)
           catch err
               if isa(err, Base.IOError) && attempts < max_attempts
                   println("Trying again for \"", path, "\"")
                   attempts == (max_attempts - 1) && sleep(1.0)
                   continue
               else
                   println("Failed for \"", path, "\"")
                   rethrow(err)
               end
           end
       end
   end
end

(but this could just as well be done in create_artifact)

And modified _mv_temp_artifact_dir (which I couldn't hack since the dispatch is concrete...)

function _mv_temp_artifact_dir(temp_dir::String, new_path::String)::Nothing
    if !isdir(new_path)
        # This next step is like
        # `mv(temp_dir, new_path)`.
        # However, `mv` defaults to `cp` if `rename` returns an error.
        # `cp` is not atomic, so avoid the potential of calling it.
        err = ccall(:jl_fs_rename, Int32, (Cstring, Cstring), temp_dir, new_path)
        # Ignore rename error, but ensure `new_path` exists.
        if !isdir(new_path)
            println("Just do cp 💀")
            mv(temp_dir, new_path)
        end
        if !isdir(new_path)
            error("$(repr(new_path)) could not be made")
        end
        chmod(new_path, filemode(dirname(new_path)))
        set_readonly(new_path)
    end
    nothing
end

Just do cp 💀 is printed twice, along with a couple of Trying again for ....
In fact, it seems like the x264_jll and Pixman_jll are the ones that needs retries, not sure if by chance or anything special about these.

Strangely, trying many times, it seemed to work, but fails again if I empty the artifacts folder...

Versioninfo
Julia Version 1.10.2
Commit bd47eca2c8 (2024-03-01 10:14 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 8 × 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, tigerlake)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)
Environment:
  JULIA_EDITOR = code
  JULIA_NUM_THREADS =

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions