alire-project / alire

Command-line tool from the Alire project and supporting library
GNU General Public License v3.0
278 stars 49 forks source link

database file for <dependency> does not exist ... could not find database #747

Open pyjarrett opened 3 years ago

pyjarrett commented 3 years ago

Windows 10 Pro, running as a standard user. Running Stock Alire: 1.0.0

PS D:\dev\ada\open_source> alr get libadalang
o Solving dependencies...... Looking for external crate: libgmp... warning: database file for 'ucrt64' does not exist (use '-Sy' to download)
warning: database file for 'clang64' does not exist (use '-Sy' to download)
O Solving dependencies...... Looking for external crate: libiconv... warning: database file for 'ucrt64' does not exist (use '-Sy' to download)
warning: database file for 'clang64' does not exist (use '-Sy' to download)
##################################################################################################################################################################### 100.0%##################################################################################################################################################################### 100.0%
The system package 'mingw-w64-x86_64-gmp' is about to be installed.
This action might require admin privileges and impact your system installation.
Do you want Alire to install this system package?
[Y] Yes  [N] No  [A] Always  (default is Yes)
Using default: Yes
warning: database file for 'ucrt64' does not exist (use '-Sy' to download)
warning: database file for 'clang64' does not exist (use '-Sy' to download)
error: failed to prepare transaction (could not find database)
ERROR: Command ["pacman", "--needed", "--noconfirm", "-S", "mingw-w64-x86_64-gmp"] exited with code 1

I fixed this directly via mingw but Alire should probably handle this itself:

Paul@dragon MINGW32 ~
$ pacman --needed --noconfirm -Sy mingw-w64-x86_64-gmp
:: Synchronizing package databases...
 mingw32                                 1186.1 KiB   884 KiB/s 00:01 [#####################################] 100%
 mingw32.sig                              566.0   B  0.00   B/s 00:00 [#####################################] 100%
 mingw64                                 1192.2 KiB  2017 KiB/s 00:01 [#####################################] 100%
 mingw64.sig                              566.0   B  0.00   B/s 00:00 [#####################################] 100%
 ucrt64                                  1447.1 KiB  1204 KiB/s 00:01 [#####################################] 100%
 ucrt64.sig                               566.0   B  0.00   B/s 00:00 [#####################################] 100%
 clang64                                 1046.1 KiB  1746 KiB/s 00:01 [#####################################] 100%
 clang64.sig                              566.0   B  0.00   B/s 00:00 [#####################################] 100%
 msys                                     362.3 KiB   610 KiB/s 00:01 [#####################################] 100%
 msys.sig                                 566.0   B  0.00   B/s 00:00 [#####################################] 100%
resolving dependencies...
looking for conflicting packages...

Packages (1) mingw-w64-x86_64-gmp-6.2.1-2

Total Download Size:   0.49 MiB
Total Installed Size:  2.21 MiB

:: Proceed with installation? [Y/n]
:: Retrieving packages...
 mingw-w64-x86_64-gmp-6.2.1-2-any         501.1 KiB  1121 KiB/s 00:00 [#####################################] 100%
(1/1) checking keys in keyring                                        [#####################################] 100%
(1/1) checking package integrity                                      [#####################################] 100%
(1/1) loading package files                                           [#####################################] 100%
(1/1) checking for file conflicts                                     [#####################################] 100%
(1/1) checking available disk space                                   [#####################################] 100%
:: Processing package changes...
(1/1) installing mingw-w64-x86_64-gmp                                 [#####################################] 100%
Fabien-Chouteau commented 3 years ago

Hello @pyjarrett,

That's an interesting issue. Do you think that Alire should do pacman -Sy before trying to install stuff?

mosteo commented 3 years ago

Might it be a matter of adding the y here?: https://github.com/alire-project/alire/blob/63552b250f08b627b39470fe44141c7375b5d1f2/src/alire/alire-origins-deployers-system-pacman.adb#L115

Fabien-Chouteau commented 3 years ago

Might it be a matter of adding the y here?:

Indeed.

pyjarrett commented 3 years ago

I'm not super familiar with pacman which is why I figured I'd post what I saw and not give a specific recommendation. Reading up on it now, it sounds like using -Sy with a specific package may lead to later breakages and the "right" way to handle this is through a system-wide update with pacman -Syu.

The failure case should definitely be communicated better. The question is really, "Should Alire be updating all of msys2?" and how that's integrated into Alire and communicated to the user. If it was my system, I'm not sure I would want Alire to be doing automated upgrades without at least some sort of confirmation.

mosteo commented 3 years ago

I don't think either that we should be making system-wide upgrades. My comment was under the assumption that -Sy would be equivalent to apt update && apt install <pkg>. The latter is understood to be safe in my experience.

I have been a user of Arch only many years ago so I lost my familiarity with it. Indeed I read now that partial upgrades (-Sy) are unsupported: https://wiki.archlinux.org/title/System_maintenance#Partial_upgrades_are_unsupported . Not very encouraging that this is recommended by the tool itself however, as seen in your log.

I guess we have to better inform the user that he needs to manually run a system upgrade if pacman fails.

Fabien-Chouteau commented 3 years ago

@pmderodat maybe you have an opinion on this.

pmderodat commented 3 years ago

Hello! I’m a very basic user of pacman, so I don’t understand in the first place how it is possible to get the original error (database file for 'X' does not exist). I knew that partial upgrades were unsafe, and I definitely agree that Alire shouldn’t try to do system upgrades, at least on its own… Maybe worth discussing with pacman developers?