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

handle git cli errors as pkgerrors #3538

Merged
merged 11 commits into from
Jul 17, 2023

Conversation

IanButterworth
Copy link
Sponsor Member

@IanButterworth IanButterworth commented Jul 4, 2023

Without this if you're offline and using the git cli

(Pkg) pkg> up
┌ Warning: could not download https://pkg.julialang.org/registries
│   exception = RequestError: Could not resolve host: pkg.julialang.org while requesting https://pkg.julialang.org/registries
└ @ Pkg.Registry ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.11/Pkg/src/Registry/Registry.jl:69
    Updating registry at `~/.julia/registries/HolyLabRegistry`
    Updating git-repo `[email protected]:HolyLab/HolyLabRegistry`
ssh: connect to host github.com port 22: Undefined error: 0
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
ERROR: failed process: Process(`git fetch -q [email protected]:HolyLab/HolyLabRegistry +refs/heads/master:refs/remotes/origin/master`, ProcessExited(128)) [128]

Stacktrace:
  [1] pipeline_error(proc::Base.Process)
    @ Base ./process.jl:565 [inlined]
  [2] run(::Base.CmdRedirect; wait::Bool)
    @ Base ./process.jl:480
  [3] run(::Base.CmdRedirect)
    @ Base ./process.jl:477 [inlined]
  [4] (::Pkg.GitTools.var"#6#8"{Vector{String}, SubString{String}})()
    @ Pkg.GitTools ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.11/Pkg/src/GitTools.jl:164
  [5] cd(f::Pkg.GitTools.var"#6#8"{Vector{String}, SubString{String}}, dir::String)
    @ Base.Filesystem ./file.jl:112
  [6] fetch(io::Base.TTY, repo::LibGit2.GitRepo, remoteurl::Nothing; header::Nothing, credentials::Nothing, refspecs::Vector{String}, kwargs::@Kwargs{})
    @ Pkg.GitTools ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.11/Pkg/src/GitTools.jl:163
  [7] kwcall(::NamedTuple, ::typeof(Pkg.GitTools.fetch), io::IO, repo::LibGit2.GitRepo) (repeats 2 times)
    @ Pkg.GitTools ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.11/Pkg/src/GitTools.jl:135 [inlined]
  [8] (::Pkg.Registry.var"#77#82"{Pkg.Registry.RegistryInstance, Vector{Tuple{String, String}}, String, Base.TTY, Dict{String, Any}})(repo::LibGit2.GitRepo)
    @ Pkg.Registry ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.11/Pkg/src/Registry/Registry.jl:464
  [9] with(f::Pkg.Registry.var"#77#82"{Pkg.Registry.RegistryInstance, Vector{Tuple{String, String}}, String, Base.TTY, Dict{String, Any}}, obj::LibGit2.GitRepo)
    @ LibGit2 ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.11/LibGit2/src/types.jl:1160
 [10] (::Pkg.Registry.var"#73#78"{Base.TTY, Dates.Day, Dict{String, Any}, String, Vector{Pkg.Registry.RegistryInstance}})()
    @ Pkg.Registry ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.11/Pkg/src/Registry/Registry.jl:449
 [11] mkpidlock(f::Pkg.Registry.var"#73#78"{Base.TTY, Dates.Day, Dict{…}, String, Vector{…}}, at::String, pid::Int32; kwopts::@Kwargs{stale_age::Int64})
    @ FileWatching.Pidfile ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.11/FileWatching/src/pidfile.jl:92
 [12] mkpidlock(f::Pkg.Registry.var"#73#78"{Base.TTY, Dates.Day, Dict{String, Any}, String}, at::String; kwopts::@Kwargs{stale_age::Int64})
    @ FileWatching.Pidfile ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.11/FileWatching/src/pidfile.jl:87 [inlined]
 [13] mkpidlock
    @ FileWatching.Pidfile ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.11/FileWatching/src/pidfile.jl:87 [inlined]
 [14] update(regs::Vector{Pkg.Registry.RegistrySpec}; io::Base.TTY, force::Bool, depots::Vector{String}, update_cooldown::Dates.Day)
    @ Pkg.Registry ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.11/Pkg/src/Registry/Registry.jl:379
 [15] update_registries(ctx::Pkg.Types.Context; force::Bool, kwargs::@Kwargs{update_cooldown::Dates.Day})
    @ Pkg.Operations ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.11/Pkg/src/Operations.jl:1266
 [16] add(ctx::Pkg.Types.Context, pkgs::Vector{…}; preserve::Pkg.Types.PreserveLevel, platform::Base.BinaryPlatforms.Platform, kwargs::@Kwargs{…})
    @ Pkg.API ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.11/Pkg/src/API.jl:262
 [17] add(pkgs::Vector{Pkg.Types.PackageSpec}; io::Base.TTY, kwargs::@Kwargs{})
    @ Pkg.API ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.11/Pkg/src/API.jl:159
 [18] add(pkgs::Vector{Pkg.Types.PackageSpec})
    @ Pkg.API ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.11/Pkg/src/API.jl:148
 [19] add(pkgs::Vector{String}; kwargs::@Kwargs{})
    @ Pkg.API ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.11/Pkg/src/API.jl:147 [inlined]
 [20] add
    @ Pkg.API ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.11/Pkg/src/API.jl:147 [inlined]
 [21] try_prompt_pkg_add(pkgs::Vector{Symbol})
    @ Pkg.REPLMode ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.11/Pkg/src/REPLMode/REPLMode.jl:729
 [22] invokelatest(f::Any, args::Vector{Symbol}; kwargs::@Kwargs{})
    @ Base ./essentials.jl:867 [inlined]
 [23] invokelatest(f::Any, args::Vector{Symbol})
    @ Base ./essentials.jl:864 [inlined]
 [24] check_for_missing_packages_and_run_hooks(ast::Any)
    @ REPL ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:174
 [25] eval_user_input(ast::Any, backend::REPL.REPLBackend, mod::Module)
    @ REPL ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:145
 [26] repl_backend_loop(backend::REPL.REPLBackend, get_module::Function)
    @ REPL ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:246
 [27] start_repl_backend(backend::REPL.REPLBackend, consumer::Any; get_module::Function)
    @ REPL ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:231
 [28] run_repl(repl::REPL.AbstractREPL, consumer::Any; backend_on_current_task::Bool, backend::Any)
    @ REPL ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:376
 [29] run_repl(repl::REPL.AbstractREPL, consumer::Any)
    @ REPL ~/Documents/GitHub/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:362
 [30] (::Base.var"#1010#1012"{Bool, Bool, Bool})(REPL::Module)
    @ Base ./client.jl:432
 [31] invokelatest(::typeof(Base.CoreLogging.handle_message), ::Base.CoreLogging.AbstractLogger, ::Base.CoreLogging.LogLevel, ::String, ::Module, ::Symbol, ::Symbol, ::String, ::Int64; kwargs::@Kwargs{})
    @ Base ./essentials.jl:867 [inlined]
 [32] invokelatest(f::Base.var"#1010#1012"{Bool, Bool, Bool}, args::Module)
    @ Base ./essentials.jl:864 [inlined]
 [33] run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_file::Bool, color_set::Bool)
    @ Base ./client.jl:416
 [34] exec_options(opts::Base.JLOptions)
    @ Base ./client.jl:333
 [35] _start()
    @ Base ./client.jl:552
Some type information was truncated. Use `show(err)` to see complete types.

(Pkg) pkg> 

With this PR

(Pkg) pkg> up
┌ Warning: could not download https://pkg.julialang.org/registries
│   exception = RequestError: Could not resolve host: pkg.julialang.org while requesting https://pkg.julialang.org/registries
└ @ Pkg.Registry ~/Documents/GitHub/Pkg.jl/src/Registry/Registry.jl:69
    Updating registry at `~/.julia/registries/HolyLabRegistry`
    Updating git-repo `[email protected]:HolyLab/HolyLabRegistry`
ssh: connect to host github.com port 22: Undefined error: 0
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
    Updating registry at `~/.julia/registries/General.toml`
┌ Error: Some registries failed to update:
│     — /Users/ian/.julia/registries/HolyLabRegistry — failed to fetch from repo: Git cli failed to fetch repository at '[email protected]:HolyLab/HolyLabRegistry'
│ error: ProcessFailedException(Base.Process[Process(`git fetch -q [email protected]:HolyLab/HolyLabRegistry +refs/heads/master:refs/remotes/origin/master`, ProcessExited(128))])
└ @ Pkg.Registry ~/Documents/GitHub/Pkg.jl/src/Registry/Registry.jl:510
  No Changes to `~/Documents/GitHub/Pkg.jl/Project.toml`
  No Changes to `~/Documents/GitHub/Pkg.jl/Manifest.toml`

(Pkg) pkg> 

The

ssh: connect to host github.com port 22: Undefined error: 0
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

is a little untidy but I thought it best to not capture stderr in case the git cli is asking the user for user credentials etc.

src/GitTools.jl Outdated Show resolved Hide resolved
@IanButterworth IanButterworth added the merge me Merge when tests pass label Jul 8, 2023
@IanButterworth
Copy link
Sponsor Member Author

Any idea why this broke windows? Seems like it's waiting on input or something now

Revert "debug - run CI with logs on"

This reverts commit a8f8125.

Update test.yml
@IanButterworth IanButterworth requested a review from a team as a code owner July 10, 2023 14:44
@DilumAluthge DilumAluthge removed the request for review from a team July 10, 2023 17:28
@IanButterworth IanButterworth removed the merge me Merge when tests pass label Jul 10, 2023
@@ -61,7 +61,7 @@ jobs:
- run: julia --project --color=yes --check-bounds=yes -e 'import Pkg; Pkg.build(); Pkg.test(; coverage=true)'
env:
JULIA_PKG_SERVER: ${{ matrix.pkg-server }}
JULIA_PKG_TEST_QUIET: "true" # "true" is the default. i.e. tests are quiet when this env var isn't set
JULIA_PKG_TEST_QUIET: "false" # "true" is the default. i.e. tests are quiet when this env var isn't set
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be reverted for the merge?

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. Converted to draft

@IanButterworth IanButterworth marked this pull request as draft July 10, 2023 21:01
@IanButterworth
Copy link
Sponsor Member Author

It seems like the git cli on the Windows CI machines is interactively requesting creds or something from the user for a simple Pkg.add(url="https://github.com/JuliaLang/Example.jl"), and that seems to have not been tested prior to this PR.

Anyone know how to fix it?

@IanButterworth
Copy link
Sponsor Member Author

Ok. I've just avoided extending the tests to Windows, with TODOs

@IanButterworth IanButterworth marked this pull request as ready for review July 17, 2023 11:55
@IanButterworth IanButterworth merged commit b612bfd into JuliaLang:master Jul 17, 2023
13 checks passed
@IanButterworth IanButterworth deleted the ib/git_cli_err_handle branch August 16, 2023 20:53
IanButterworth added a commit that referenced this pull request Aug 18, 2023
IanButterworth added a commit that referenced this pull request Aug 18, 2023
@IanButterworth IanButterworth mentioned this pull request Aug 18, 2023
10 tasks
IanButterworth added a commit that referenced this pull request Aug 18, 2023
@IanButterworth IanButterworth mentioned this pull request Aug 18, 2023
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants