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

Better error messages if artifact rename fails #3827

Merged
merged 7 commits into from
Aug 18, 2024

Conversation

nhz2
Copy link
Contributor

@nhz2 nhz2 commented Mar 5, 2024

This PR should improve error messages if an anti-virus prevents the temporary directory the artifact is unpacked into from being renamed or deleted. Ref #3822

The issue is that an error that occurs in a finally after a try and catch hides any error that occurred in the try.

The following is the message @xlxs4 got when testing this PR

julia> Pkg.pkg"add Plots"
   Resolving package versions...
   Installed Statistics ─ v1.11.1
┌ Error: your anti-virus may be interfering with artifact installation
│ See https://github.com/JuliaLang/Pkg.jl/issues/3822
└ @ Main.Pkg.Artifacts C:\Users\ores.ousoultzoglou\GitHub\Pkg.jl\src\Artifacts.jl:81
┌ Warning: Failed to clean up temporary directory "C:\\Users\\ores.ousoultzoglou\\.julia\\artifacts\\jl_fukAt4"
│   exception = IOError: rm("C:\\Users\\ores.ousoultzoglou\\.julia\\artifacts\\jl_fukAt4\\bin"): directory not empty (ENOTEMPTY)
└ @ Main.Pkg.Artifacts C:\Users\ores.ousoultzoglou\GitHub\Pkg.jl\src\Artifacts.jl:386
┌ Error: your anti-virus may be interfering with artifact installation
│ See https://github.com/JuliaLang/Pkg.jl/issues/3822
└ @ Main.Pkg.Artifacts C:\Users\ores.ousoultzoglou\GitHub\Pkg.jl\src\Artifacts.jl:81
┌ Warning: Failed to clean up temporary directory "C:\\Users\\ores.ousoultzoglou\\.julia\\artifacts\\jl_nEUv5J"
│   exception = IOError: rm("C:\\Users\\ores.ousoultzoglou\\.julia\\artifacts\\jl_nEUv5J\\bin"): directory not empty (ENOTEMPTY)
└ @ Main.Pkg.Artifacts C:\Users\ores.ousoultzoglou\GitHub\Pkg.jl\src\Artifacts.jl:386
ERROR: Unable to automatically download/install artifact 'fzf' from sources listed in 'C:\Users\ores.ousoultzoglou\.julia\packages\fzf_jll\okrgy\Artifacts.toml'.
Sources attempted:
- https://pkg.julialang.org/artifact/8043c72c48288c74e7f13c0c4aecbd239ef872bb
    Error: IOError: rename of "C:\\Users\\ores.ousoultzoglou\\.julia\\artifacts\\jl_fukAt4" to "C:\\Users\\ores.ousoultzoglou\\.julia\\artifacts\\8043c72c48288c74e7f13c0c4aecbd239ef872bb": permission denied (EACCES)
- https://github.com/JuliaBinaryWrappers/fzf_jll.jl/releases/download/fzf-v0.43.0+0/fzf.v0.43.0.x86_64-w64-mingw32.tar.gz
    Error: IOError: rename of "C:\\Users\\ores.ousoultzoglou\\.julia\\artifacts\\jl_nEUv5J" to "C:\\Users\\ores.ousoultzoglou\\.julia\\artifacts\\8043c72c48288c74e7f13c0c4aecbd239ef872bb": permission denied (EACCES)

Stacktrace:
  [1] error(s::String)
    @ Base .\error.jl:35
  [2] ensure_artifact_installed(name::String, meta::Dict{…}, artifacts_toml::String; platform::Base.BinaryPlatforms.Platform, verbose::Bool, quiet_download::Bool, io::Main.Pkg.UnstableIO)
    @ Main.Pkg.Artifacts C:\Users\ores.ousoultzoglou\GitHub\Pkg.jl\src\Artifacts.jl:478
  [3]
    @ Main.Pkg.Operations C:\Users\ores.ousoultzoglou\GitHub\Pkg.jl\src\Operations.jl:770
  [4] add(ctx::Main.Pkg.Types.Context, pkgs::Vector{…}, new_git::Set{…}; preserve::Main.Pkg.Types.PreserveLevel, platform::Base.BinaryPlatforms.Platform, target::Symbol)
    @ Main.Pkg.Operations C:\Users\ores.ousoultzoglou\GitHub\Pkg.jl\src\Operations.jl:1433
  [5] add
    @ C:\Users\ores.ousoultzoglou\GitHub\Pkg.jl\src\Operations.jl:1399 [inlined]
  [6] add(ctx::Main.Pkg.Types.Context, pkgs::Vector{…}; preserve::Main.Pkg.Types.PreserveLevel, platform::Base.BinaryPlatforms.Platform, target::Symbol, kwargs::@Kwargs{})
    @ Main.Pkg.API C:\Users\ores.ousoultzoglou\GitHub\Pkg.jl\src\API.jl:307
  [7] add(pkgs::Vector{Main.Pkg.Types.PackageSpec}; io::Main.Pkg.UnstableIO, kwargs::@Kwargs{})
    @ Main.Pkg.API C:\Users\ores.ousoultzoglou\GitHub\Pkg.jl\src\API.jl:160
  [8] add(pkgs::Vector{Main.Pkg.Types.PackageSpec})
    @ Main.Pkg.API C:\Users\ores.ousoultzoglou\GitHub\Pkg.jl\src\API.jl:149
  [9] do_cmd(command::Main.Pkg.REPLMode.Command, io::Main.Pkg.UnstableIO)
    @ Main.Pkg.REPLMode C:\Users\ores.ousoultzoglou\GitHub\Pkg.jl\src\REPLMode\REPLMode.jl:407
 [10] do_cmds(commands::Vector{Main.Pkg.REPLMode.Command}, io::Main.Pkg.UnstableIO)
    @ Main.Pkg.REPLMode C:\Users\ores.ousoultzoglou\GitHub\Pkg.jl\src\REPLMode\REPLMode.jl:393
 [11] do_cmds(input::String, io::Main.Pkg.UnstableIO)
    @ Main.Pkg.REPLMode C:\Users\ores.ousoultzoglou\GitHub\Pkg.jl\src\REPLMode\REPLMode.jl:383
 [12] pkgstr(str::String)
    @ Main.Pkg.REPLMode C:\Users\ores.ousoultzoglou\GitHub\Pkg.jl\src\REPLMode\REPLMode.jl:450
 [13] top-level scope
    @ REPL[4]:1
Some type information was truncated. Use `show(err)` to see complete types.

Here is what this kind of error would look like before this PR (from https://discourse.julialang.org/t/installation-of-nodejs-fails-directory-not-empty/111117)

(tmp) pkg> add NodeJS
   Resolving package versions...
  Downloaded artifact: nodejs_app
ERROR: IOError: rm("C:\\Users\\michele.zaffalon\\.julia\\artifacts\\jl_Y9gBTl"): directory not empty (ENOTEMPTY)
Stacktrace:
  [1] uv_error
    @ .\libuv.jl:100 [inlined]
  [2] rm(path::String; force::Bool, recursive::Bool)
    @ Base.Filesystem .\file.jl:307
  [3] rm
    @ .\file.jl:273 [inlined]
  [4] download_artifact(tree_hash::Base.SHA1, tarball_url::String, tarball_hash::Nothing; verbose::Bool, quiet_download::Bool, io::Base.TTY)
\src\Artifacts.jl:376
  [5] download_artifact (repeats 2 times)
    @ C:\Users\michele.zaffalon\.julia\juliaup\julia-1.10.2+0.x64.w64.mingw32\share\julia\stdlib\v1.10\Pkg\src\Artifacts.jl:297 [inlined]
  [6] #22
    @ C:\Users\michele.zaffalon\.julia\juliaup\julia-1.10.2+0.x64.w64.mingw32\share\julia\stdlib\v1.10\Pkg\src\Artifacts.jl:423 [inlined]
  [7] with_show_download_info(f::Pkg.Artifacts.var"#22#24"{Bool, Bool, Base.TTY, Base.SHA1, String}, io::Base.TTY, name::String, quiet_download::Bool)
    @ Pkg.Artifacts C:\Users\michele.zaffalon\.julia\juliaup\julia-1.10.2+0.x64.w64.mingw32\share\julia\stdlib\v1.10\Pkg\src\Artifacts.jl:480
  [8] ensure_artifact_installed(name::String, meta::Dict{String, Any}, artifacts_toml::String; platform::Base.BinaryPlatforms.Platform, verbose::Bool, quiet_download::Bool, io::Base.TTY)
    @ Pkg.Artifacts C:\Users\michele.zaffalon\.julia\juliaup\julia-1.10.2+0.x64.w64.mingw32\share\julia\stdlib\v1.10\Pkg\src\Artifacts.jl:422
  [9] download_artifacts(env::Pkg.Types.EnvCache; platform::Base.BinaryPlatforms.Platform, julia_version::VersionNumber, verbose::Bool, io::Base.TTY)
    @ Pkg.Operations C:\Users\michele.zaffalon\.julia\juliaup\julia-1.10.2+0.x64.w64.mingw32\share\julia\stdlib\v1.10\Pkg\src\Operations.jl:755
 [10] add(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}, new_git::Set{Base.UUID}; preserve::Pkg.Types.PreserveLevel, platform::Base.BinaryPlatforms.Platform)
    @ Pkg.Operations C:\Users\michele.zaffalon\.julia\juliaup\julia-1.10.2+0.x64.w64.mingw32\share\julia\stdlib\v1.10\Pkg\src\Operations.jl:1394
 [11] add
    @ C:\Users\michele.zaffalon\.julia\juliaup\julia-1.10.2+0.x64.w64.mingw32\share\julia\stdlib\v1.10\Pkg\src\Operations.jl:1376 [inlined]
 [12] add(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; preserve::Pkg.Types.PreserveLevel, platform::Base.BinaryPlatforms.Platform, kwargs::@Kwargs{io::Base.TTY})
    @ Pkg.API C:\Users\michele.zaffalon\.julia\juliaup\julia-1.10.2+0.x64.w64.mingw32\share\julia\stdlib\v1.10\Pkg\src\API.jl:278
 [13] add(pkgs::Vector{Pkg.Types.PackageSpec}; io::Base.TTY, kwargs::@Kwargs{})
    @ Pkg.API C:\Users\michele.zaffalon\.julia\juliaup\julia-1.10.2+0.x64.w64.mingw32\share\julia\stdlib\v1.10\Pkg\src\API.jl:159
 [14] add(pkgs::Vector{Pkg.Types.PackageSpec})
    @ Pkg.API C:\Users\michele.zaffalon\.julia\juliaup\julia-1.10.2+0.x64.w64.mingw32\share\julia\stdlib\v1.10\Pkg\src\API.jl:148
 [15] do_cmd!(command::Pkg.REPLMode.Command, repl::REPL.LineEditREPL)
    @ Pkg.REPLMode C:\Users\michele.zaffalon\.julia\juliaup\julia-1.10.2+0.x64.w64.mingw32\share\julia\stdlib\v1.10\Pkg\src\REPLMode\REPLMode.jl:412
 [16] do_cmd(repl::REPL.LineEditREPL, input::String; do_rethrow::Bool)
    @ Pkg.REPLMode C:\Users\michele.zaffalon\.julia\juliaup\julia-1.10.2+0.x64.w64.mingw32\share\julia\stdlib\v1.10\Pkg\src\REPLMode\REPLMode.jl:390
 [17] do_cmd
    @ C:\Users\michele.zaffalon\.julia\juliaup\julia-1.10.2+0.x64.w64.mingw32\share\julia\stdlib\v1.10\Pkg\src\REPLMode\REPLMode.jl:380 [inlined]
 [18] (::Pkg.REPLMode.var"#24#27"{REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::IOBuffer, ok::Bool)
    @ Pkg.REPLMode C:\Users\michele.zaffalon\.julia\juliaup\julia-1.10.2+0.x64.w64.mingw32\share\julia\stdlib\v1.10\Pkg\src\REPLMode\REPLMode.jl:557
 [19] #invokelatest#2
    @ .\essentials.jl:892 [inlined]
 [20] invokelatest
    @ .\essentials.jl:889 [inlined]
 [21] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit C:\Users\michele.zaffalon\.julia\juliaup\julia-1.10.2+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\LineEdit.jl:2656
 [22] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL C:\Users\michele.zaffalon\.julia\juliaup\julia-1.10.2+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:1312
 [23] (::REPL.var"#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL C:\Users\michele.zaffalon\.julia\juliaup\julia-1.10.2+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:386

@nhz2 nhz2 marked this pull request as ready for review March 5, 2024 16:32
src/Artifacts.jl Outdated Show resolved Hide resolved
@xlxs4
Copy link

xlxs4 commented Jul 29, 2024

IMO if you're going to include the "your antivirus might be interfering" error, it'd be nice if it printed only once.

Manually renaming the artifact folder to the hash is another fix for anyone getting hit by this (e.g. mv .\jl_1vF2ic\ 8043c72c48288c74e7f13c0c4aecbd239ef872bb\)

@nhz2
Copy link
Contributor Author

nhz2 commented Jul 29, 2024

I think I'm going to remove that warning, as it seems redundant with the:

ERROR: Unable to automatically download/install artifact 'fzf'
... permission denied (EACCES)

message.

@staticfloat staticfloat merged commit 8b2c0f3 into JuliaLang:master Aug 18, 2024
7 checks passed
@nhz2 nhz2 deleted the nz/better-errors branch August 18, 2024 23:01
visr pushed a commit to visr/Pkg.jl that referenced this pull request Nov 28, 2024
* try rm to get better error messages

* simplify changes

* fix comment typo

* rethrow InterruptException

* Update error message

* remove redundant error logging

(cherry picked from commit 8b2c0f3)
KristofferC pushed a commit that referenced this pull request Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants