nabijaczleweli / cargo-update

A cargo subcommand for checking and applying updates to installed executables
MIT License
1.22k stars 42 forks source link

Failed to update index repository when using WSL (v1 or v2) #148

Closed iliekturtles closed 3 years ago

iliekturtles commented 3 years ago

When attempting to use cargo-update in a WSL bash shell (WSL 1 or WSL 2) the update registry step fails with the error message shown below.

$ cargo install-update -i ripgrep
    Updating registry 'https://github.com/rust-lang/crates.io-index'
Failed to update index repository: failed to resolve address for github.com: Temporary failure in name resolution.

Using cargo install in the same shell works.

$ cargo install ripgrep
    Updating crates.io index
  Downloaded ripgrep v12.1.1
  Downloaded 1 crate (256.5 KB) in 0.80s
  Installing ripgrep v12.1.1
  ...

Using cargo-update in a git bash (MINGW64) shell also works.

$ cargo install-update -i ripgrep
    Updating registry 'https://github.com/rust-lang/crates.io-index'

Package  Installed  Latest   Needs update
ripgrep  v12.1.1    v12.1.1  No

No packages need updating.
Overall updated 0 packages.

What additional information would be useful to diagnose the issue?

nabijaczleweli commented 3 years ago

What's your /etc/resolv.conf and ldd on cargo and cargo-install-update? A bit of a shot in the dark, but if one somehow uses a different resolver/libgit2 from the other this might me what results.

iliekturtles commented 3 years ago

I closed the shell after submitting the issue and after re-opening to get the requested information cargo-update is now working! I'll close the issue and keep and eye on things. For anyone from the future I had recently re-installed WSL on a couple different computers and both experienced the same issue. I had even closed+reopened the shell a couple times on both. Not sure what was different about the last restart.

/ect/resolv.conf and ldd information included below for completeness. The one thing I notice is that cargo-update links libssl which cargo doesn't.

$ cat /etc/resolv.conf
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 192.168.1.1
$ ldd $(which cargo)
    linux-vdso.so.1 (0x00007fffd5759000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f30c6d60000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f30c6d50000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f30c6d2d000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f30c6d10000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f30c6b10000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f30c69c1000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f30c790b000)
$ ldd ~/.local/share/cargo/bin/cargo-install-update
    linux-vdso.so.1 (0x00007fffd2728000)
    libssl.so.1.1 => /lib/x86_64-linux-gnu/libssl.so.1.1 (0x00007ff4726d0000)
    libcrypto.so.1.1 => /lib/x86_64-linux-gnu/libcrypto.so.1.1 (0x00007ff4723f0000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ff4723e0000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ff4723bd000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007ff4723a0000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff4721a0000)
    /lib64/ld-linux-x86-64.so.2 (0x00007ff472baf000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ff472041000)
$ diff <(ldd $(which cargo)|cut -f1 -d"("|sort) <(ldd ~/.local/share/cargo/bin/cargo-install-update|cut -f1 -d"("|sort)
1a2
>   libcrypto.so.1.1 => /lib/x86_64-linux-gnu/libcrypto.so.1.1
7c8
<   librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1
---
>   libssl.so.1.1 => /lib/x86_64-linux-gnu/libssl.so.1.1
nabijaczleweli commented 3 years ago

Weird! Indeed, I don't see any good reason for the resolver to be angry in one case but not the other. Glad it works, either way!