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

apt-get update fails in Ubuntu 16.04 #640

Closed
paladox opened this issue Jul 10, 2016 · 60 comments
Closed

apt-get update fails in Ubuntu 16.04 #640

paladox opened this issue Jul 10, 2016 · 60 comments
Labels
external Issue exists outside of WSL components

Comments

@paladox
Copy link

paladox commented Jul 10, 2016

Hi when trying

apt-get update

it fails with

Hit:1 http://archive.ubuntu.com/ubuntu xenial InRelease
Hit:2 http://archive.ubuntu.com/ubuntu xenial-updates InRelease
Hit:3 http://security.ubuntu.com/ubuntu xenial-security InRelease

** (appstreamcli:13571): CRITICAL **: Error while moving old database out of the way.
AppStream cache update failed.
Reading package lists... Done

@alexanderwhatley
Copy link

I don't believe Ubuntu 16.04 is supported by WSL right now.

@Manouchehri
Copy link
Contributor

It's still working fine here.

ubuntu@DESKTOP-3RQO5S5:/mnt/c/Users/Dave/Desktop$ sudo apt-get update
sudo: unable to resolve host DESKTOP-3RQO5S5
Hit:1 mirror://mirrors.ubuntu.com/mirrors.txt xenial InRelease
Hit:2 mirror://mirrors.ubuntu.com/mirrors.txt xenial-updates InRelease
Hit:3 mirror://mirrors.ubuntu.com/mirrors.txt xenial-backports InRelease
Hit:4 mirror://mirrors.ubuntu.com/mirrors.txt xenial-security InRelease
Reading package lists... Done
ubuntu@DESKTOP-3RQO5S5:/mnt/c/Users/Dave/Desktop$ sudo apt-get upgrade
sudo: unable to resolve host DESKTOP-3RQO5S5
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

@alexanderwhatley
Copy link

@Manouchehri do you get Ubuntu 16.04 when you run lsb_release -a?

@benhillis
Copy link
Member

@Manouchehri Unrelated, but if do "sudo rm /etc/hosts" and restart bash.exe does the sudo: unable to resolve host DESKTOP-3RQO5S5 error message go away?

@Manouchehri
Copy link
Contributor

Manouchehri commented Jul 11, 2016 via email

@Manouchehri
Copy link
Contributor

@benhillis: Yep, that fixed it as expected. Thanks.

@Manouchehri
Copy link
Contributor

@alexanderwhatley:

ubuntu@DESKTOP-3RQO5S5:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04 LTS
Release:        16.04
Codename:       xenial
ubuntu@DESKTOP-3RQO5S5:~$ uname -a
Linux DESKTOP-3RQO5S5 3.4.0+ #1 PREEMPT Thu Aug 1 17:06:05 CST 2013 x86_64 x86_64 x86_64 GNU/Linux

@TaffyMadeThat
Copy link

I'm having the same issue, this is what my konsole displays:

kubuntu@kubuntu:~$ sudo apt-get install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.
kubuntu@kubuntu:~$ sudo apt-get update
Ign:1 cdrom://Kubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1) xenial InRelease
Hit:2 cdrom://Kubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1) xenial Release
Hit:4 http://archive.ubuntu.com/ubuntu xenial InRelease                                
Get:5 http://security.ubuntu.com/ubuntu xenial-security InRelease [94.5 kB]            
Hit:6 http://archive.ubuntu.com/ubuntu xenial-updates InRelease                    
Fetched 94.5 kB in 0s (155 kB/s)                                                   

** (appstreamcli:27258): CRITICAL **: Error while moving old database out of the way.
AppStream cache update failed.
Reading package lists... Done

Could someone offer any solution?

@AskeFC
Copy link

AskeFC commented Jul 14, 2016

I did an "strace appstreamcli refresh-index" and saw a permission denied during rename of /var/cache/app-info/xapian/default.
So I did "chmod 777 /var/cache/app-info/xapian/default -R" and that fixed it for me.

@paladox
Copy link
Author

paladox commented Jul 14, 2016

@AskeFC hi, thanks that worked.

@TaffyMadeThat
Copy link

TaffyMadeThat commented Jul 14, 2016

For others who may come across this thread, you may get "You might need superuser permissions to perform this action." to which you can put "sudo" (spacebar) @AskeFC 's codes.

@Manouchehri
Copy link
Contributor

@AskeFC 777 permissions are a really bad idea. If you need to run several commands as root, just run sudo -i to get root.

@electron0zero
Copy link

@Manouchehri
how did you got Ubuntu 16.04 ?, i got WSL with anniversary update.
mine is 14.04, how do i upgrade to 16.04.

electron@DELL-PC:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.5 LTS
Release: 14.04
Codename: trusty
electron@DELL-PC:~$

@adamkruszewski
Copy link

@Manouchehri Unrelated, but if do "sudo rm /etc/hosts" and restart bash.exe does the sudo: unable to resolve host DESKTOP-3RQO5S5 error message go away?

I think it is better just to add DESKTOP-3RQO5S5 to the line that states:
127.0.0.1 localhost
just make it look like:
127.0.0.1 localhost DESKTOP-3RQO5S5
It should make it work without loosing /etc/hosts (basically we are learning apps that DESKTOP03RQO5S5 is an alias for localhost).

@jonstanley
Copy link

chmod g+w /var/cache/app-info/xapian/default -R

... appears to be the safer fix for this issue, since in WSL you are already root...

@codex-corp
Copy link

codex-corp commented Oct 8, 2016

@adamkruszewski
This file was automatically generated by WSL. To stop automatic generation of this file, remove this line.
127.0.0.1 localhost
127.0.1.1 DESKTOP-6VRROIO.localdomain DESKTOP-6VRROIO

@paladox
Copy link
Author

paladox commented Oct 9, 2016

@KubuntuUser and @Manouchehri hi, that fix is a temporarily one since a day or two after doing that the problem comes back.

@therealkenc
Copy link
Collaborator

therealkenc commented Dec 18, 2016

Just wanted to ping this one because it definitely seems to be a "WSL thing". The chmod trick @jonstanley and others have posted works, but somewhere along the way the perms get messed again. It's a tough thing to generate a test case for because I have no idea right now what is causing /var/cache/app-info/xapian/default to get changed. Probably apt-get update or apt-get upgrade themselves, since there aren't any other likely candidates. My Ubuntu VM and my WSL system are always in sync from a package update perspective, and its not a problem on native; so something must be different on the WSL side of things.

@ezzep
Copy link

ezzep commented Dec 27, 2016

Hey everyone, I had the same issue of the apt-get update failing. So I googled a bit. This was the second page that came up. The first one was http://askubuntu.com/questions/761592/unable-to-apt-get-dist-upgrade-on-a-persistent-ubuntu-16-04-usb
Anyway, I followed their instructions. Working for now. We'll see if it screws up later.

@pknsuthar
Copy link

pknsuthar commented Feb 11, 2017

Might want to give this a try.

sudo apt-get dselect-upgrade

be sure to check out the changes it will make before you commit. but was only way forward was to take a step back for me.

@tnguyen14
Copy link

Just ran into this error today:

:; sudo apt-get update
Hit:1 http://archive.ubuntu.com/ubuntu xenial InRelease
Hit:2 http://archive.ubuntu.com/ubuntu xenial-updates InRelease
Hit:3 https://apt.dockerproject.org/repo ubuntu-xenial InRelease
Hit:4 http://security.ubuntu.com/ubuntu xenial-security InRelease

** (appstreamcli:516): CRITICAL **: Error while moving old database out of the way.
AppStream cache update failed.
Reading package lists... Done

Following the step mentioned by @ezzep (sudo chmod -R a+rX,u+w /var/cache/app-info/xapian/default) I was able to get past it. Thanks for the help.

@tnguyen14
Copy link

Looks like I have to change that permission more than once. Maybe it's reset somehow.

@tgvcdr
Copy link

tgvcdr commented Jul 1, 2017

sudo mv /var/cache/app-info/xapian/default /var/cache/app-info/xapian/default_old
sudo strace appstreamcli refresh-index

Simple and secure!

Background:
Ubuntu 16.04.2 Live CD
After booting the live CD I did sudo apt-get update and sudo apt-get upgrade and it went smoothly.

I did sudo apt-get update again and got:

** (appstreamcli:32262): CRITICAL **: Error while moving old database out of the way.
AppStream cache update failed.

Running

sudo strace appstreamcli refresh-index

gave me:

rename("/var/cache/app-info/xapian/default", "/var/cache/app-info/xapian/default_old") = -1 EXDEV (Invalid corss-device link)

I fixed that by renaming the file and refreshing the index

@ghost
Copy link

ghost commented Jul 22, 2017

@AskeFC Works perfectly. Thank you!

@cr41g1w
Copy link

cr41g1w commented Aug 16, 2017

@tgvcdr this solution did not work for me. I had to apply the permissions fix by @jonstanley instead, which worked.

@cr41g1w
Copy link

cr41g1w commented Aug 17, 2017

And failed again after a reboot.

@therealkenc
Copy link
Collaborator

therealkenc commented Aug 18, 2017

Does anyone on the MSFT team understand the root cause of this problem? I get a 100% hit rate on this issue since WSL was released, across multiple clean installs of both Trusty and Xenial. Which is weird -- I would have expected that if everyone is hitting this issue to see more dupes and more "is this fixed yet?" posts here. Maybe it is because the chmod work-around is straight forward and easy to find in a Google search (the work-around sits in my bash history and is SOP for every update). Shrug.

I'll take a run at tracking and doing a min repro, but last time (~ a year ago) when I looked at it the problem wasn't straightforward. It seems to be a "sticky" issue caused by the first update (or upgrade) run that manifests in the next. So the strace, which is huge, doesn't help much because there is no actual syscall fail/misbehaviour (that I could see at the time) on the "second" run when there are new updates to pull. Running the sequence twice back-to-back in a row after chmod works, making the debug cycle problematic. I'll look some more, but don't want to expend the effort if the problem is well known but simply hard to fix.

@JOrion9999
Copy link

JOrion9999 commented Nov 3, 2017

yeah .. I guess you could write a script something like

#!/bin/bash
for filename in /var/cache/app-info/xapian/default/record.DB
do
if [ $(stat -c "%a" "$filename") == "777" ]
then
echo "The files are already writable"
else
chmod -R 777 "/var/cache/app-info/xapian/default" && echo "The files are now writable"
fi
done
apt update
apt -y upgrade

save it as apt-update
and just run sudo apt-update instead

@WinEunuuchs2Unix
Copy link

I'll throw my hat into the ring. Using VcXsrv and have installed Ubuntu-Desktop followed by Xubuntu-Desktop in order to run xfce4. Not sure which witch is which casting this spell:

$ sudo apt-get update && apt-get install --reinstall sudo
Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Get:2 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [384 kB]
Get:3 http://security.ubuntu.com/ubuntu xenial-security/main Translation-en [170 kB]
Get:4 http://security.ubuntu.com/ubuntu xenial-security/main amd64 DEP-11 Metadata [60.2 kB]
Get:5 http://security.ubuntu.com/ubuntu xenial-security/main DEP-11 64x64 Icons [62.6 kB]
Get:6 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [179 kB]
Hit:7 http://archive.ubuntu.com/ubuntu xenial InRelease
Get:8 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:9 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 DEP-11 Metadata [51.3 kB]
Get:10 http://security.ubuntu.com/ubuntu xenial-security/universe DEP-11 64x64 Icons [79.9 kB]
Get:11 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
Get:12 http://security.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages [3,212 B]
Get:13 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [657 kB]
Get:14 http://archive.ubuntu.com/ubuntu xenial-updates/main Translation-en [275 kB]
Get:15 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 DEP-11 Metadata [307 kB]
Get:16 http://archive.ubuntu.com/ubuntu xenial-updates/main DEP-11 64x64 Icons [216 kB]
Get:17 http://archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 Packages [8,072 B]
Get:18 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [550 kB]
Get:19 http://archive.ubuntu.com/ubuntu xenial-updates/universe Translation-en [224 kB]
Get:20 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 DEP-11 Metadata [185 kB]
Get:21 http://archive.ubuntu.com/ubuntu xenial-updates/universe DEP-11 64x64 Icons [261 kB]
Get:22 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 Packages [16.2 kB]
Get:23 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 DEP-11 Metadata [5,892 B]
Get:24 http://archive.ubuntu.com/ubuntu xenial-backports/main amd64 Packages [4,860 B]
Get:25 http://archive.ubuntu.com/ubuntu xenial-backports/main amd64 DEP-11 Metadata [3,324 B]
Get:26 http://archive.ubuntu.com/ubuntu xenial-backports/universe amd64 DEP-11 Metadata [4,588 B]
Fetched 4,015 kB in 14s (271 kB/s)

** (appstreamcli:474): CRITICAL **: Error while moving old database out of the way.
AppStream cache update failed.
Reading package lists... Done
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

Hopefully someone can summarize all the above messages into a single plan for WSL newbies like me.

@therealkenc
Copy link
Collaborator

therealkenc commented Jan 25, 2018

So, at extreme risk of jinxing the hell out of myself, I haven't been getting "Error while moving old database out of the way" for a couple of updates. This is on apt 1.2.24, but of course none of us (including myself) had the foresight to post our apt version up-thread. Usage on my end (installing the ubuntu-desktop meta package early) hasn't changed. Methinks maybe Debian or Canonical "fixed" it on their end by avoiding whatever pattern was problematic (deliberately or by chance). But there are a lot of moving parts here, and I haven't confirmed that for certain by looking at the diffs or release notes for apt.

If others are having the same experience ("it works now"), maybe we can close this out or dupe it into one of the "NTFS supporting posix-style rename" issues. Might just be a false positive on my end for reasons.

@DarkIlluminatus
Copy link

DarkIlluminatus commented Jan 27, 2018

@therealkenc As awesome as that would be...I believe I may have this issue myself. However, I am currently in the process of apt-get upgrade, so this status may change. Will edit this post accordingly upon completion.

It works now. Using your suggestion to chmod 755 and then doing dist-upgrade worked out perfectly. Thank you!

@YashDidwania125
Copy link

hi
when i am executing the command sudo apt-get update
it fails with
Ign:1 http://in.archive.ubuntu.com/ubuntu yakkety-updates InRelease
Hit:2 http://old-releases.ubuntu.com/ubuntu yakkety InRelease
Ign:3 http://in.archive.ubuntu.com/ubuntu yakkety-updates Release
Hit:4 http://old-releases.ubuntu.com/ubuntu yakkety-updates InRelease
Ign:5 http://in.archive.ubuntu.com/ubuntu yakkety-updates/universe i386 Packages
Hit:6 http://old-releases.ubuntu.com/ubuntu yakkety-backports InRelease
Ign:7 http://in.archive.ubuntu.com/ubuntu yakkety-updates/universe all Packages
Hit:8 http://old-releases.ubuntu.com/ubuntu yakkety-security InRelease
Ign:9 http://in.archive.ubuntu.com/ubuntu yakkety-updates/universe amd64 Packages
Ign:10 http://in.archive.ubuntu.com/ubuntu yakkety-updates/universe Translation-en
Ign:11 http://in.archive.ubuntu.com/ubuntu yakkety-updates/universe Translation-en_IN
Ign:12 http://in.archive.ubuntu.com/ubuntu yakkety-updates/universe amd64 DEP-11 Metadata
Ign:13 http://in.archive.ubuntu.com/ubuntu yakkety-updates/universe all DEP-11 Metadata
Ign:14 http://in.archive.ubuntu.com/ubuntu yakkety-updates/universe DEP-11 64x64 Icons

and it goes on....
what should i do now?

@therealkenc
Copy link
Collaborator

what should i do now?

A few options:

(1) Go back to the supported release (Ubuntu Xenial from the Store)
(2) Ask in the community where you got the Yakkety installer, assuming you didn't upgrade from Xenial by standard means inside WSL with apt
(3) Ask in the Ubuntu forums if you upgraded it by standard apt means, and open a new issue once you've identified a diverge from Real Linux behaviour following CONTRIBUTING.md (this one likely won't be necessary)

This issue is for tracking CRITICAL **: Error while moving old database out of the way, which has been suspiciously absent lately. Wish I knew why.

@cacsar
Copy link

cacsar commented Apr 13, 2018

I've been continuing to get it on Xenial installed from the store on apt 1.2.26 (amd64). chmod does solve it temporarily. I'm hoping it'll go away with this impending feature update.

@JOrion9999
Copy link

I have since deleted Ubuntu from my system, removed the linux stuff you had to add in programs and features.. rebooted .. installed linux stuff again and went to the Windows Store and downloaded Ubuntu there .. With the version from the store (which seems to be the exact same thing but located in a different place on the drive) I don't seem to have this issue anymore

@therealkenc
Copy link
Collaborator

I'm hoping it'll go away with this impending feature update.

Unfortunately if you are still seeing it, not so much. #1529 is alive and well. Still wonder why I am not seeing it recently, since I haven't changed my process. But the problem is going to be entirely dependent on your package set; which differs for everyone. apt can basically do "anything", by virtue of calling scripts. So I have a lucky package set, and you do not.

@akatangus
Copy link

https://administratosphere.wordpress.com/2016/12/25/appstream-error-in-ubuntu-16-04-xenial/

Verified this as a fix, (at least in win 10 WSL)
4.4.0-43-Microsoft #1-Microsoft Wed Dec 31 14:42:53 PST 2014 x86_64 x86_64 x86_64 GNU/Linux
Distributor ID: Ubuntu
Description: Ubuntu 16.04.4 LTS
Release: 16.04
Codename: xenial
Looks like for some silly reason the xenial backports and appstream aren't in the package updates yet.... sigh

@tara-raj
Copy link

Ubuntu 16.04 is now supported in the Microsoft Store. For additional issues with app packages please file a separate issue. Thanks

@therealkenc therealkenc reopened this May 30, 2018
@therealkenc
Copy link
Collaborator

That Ubuntu 16.04 is available in the Store is unrelated to the perennially unaddressed issue of:

** (appstreamcli:13571): CRITICAL **: Error while moving old database out of the way.
AppStream cache update failed.

Which is almost certainly dupe #1529 as suggested by Ben's post, but we don't have enough specificity to actually mark it as such.

@JOrion9999
Copy link

JOrion9999 commented May 30, 2018

actually it sort of is an answer ... if you bother to look up to my comment made April 13... if you delete Ubuntu completely from your system and remove the windows subsystem for Linux, reboot .. then install the Linux subsystem again reboot once more and go to the store to install Ubuntu ... it works without this issue.

If you want it fixed .. then just delete it and install it from the Windows store as suggested and its fixed .. most likely the reason you are still seeing it is because the original was actually 14.04 ... the 14.04 was probably updated to 16.04 but was not designed to or some leftover stuff from 14.04 is causing issues with 16.04 ... deleting the old "broken" version and reinstalling it with the now "official" version from the Windows store will solve this issue in this thread

@cacsar
Copy link

cacsar commented May 30, 2018

And if you look one above that comment you'll see my assertion that I installed 16.04 from the store (around Christmas 2017 on a brand new Surface Book 2) rather than upgrading. Now if there's been some fix since then that involves doing a reinstall that's something else.

I don't have this problem on 18.04 installed from the store, but that doesn't indicate the underlying issue may not still exist on new installs of 16.04 or 18.04 since the underlying issue may not be 100% reliable repro.

I'm now on the April(?) 2018 update of Win 10/ 10.0.17134.

@JOrion9999
Copy link

well if you were seeing it with the store version and never installed the original borked version ... then it has to be something with your install or hardware ... or maybe I have been lucky with my two versions of hardware since I reinstalled it and since I upgraded my PC .. once I got rid of the original version that wasn't from the store and reinstalled linux subsystem and then installed the 16.04 from the store ... I have never had the issue again since.

@akatangus
Copy link

akatangus commented May 30, 2018

appstreamcli —version
AppStream CLI tool version: 0.10.1

If you don't see this, its borked, If they fixed the package with the "new" version fine, but simply updating Appstream fixes the issue. My comment prior to tara-raj has the whole process on the third party blog.

@therealkenc
Copy link
Collaborator

therealkenc commented May 30, 2018

actually it sort of is an answer ...

Agreed. Alright we'll call this tag external. It isn't, really, because Real Linux does not manifest the error reported by paladox in 2016, and nothing has changed in WSL since then with respect to the error. If someone has a link to the PR that addressed the problem with AppStream that would be instructive.

The error cited in the blog is:

AppStream cache update completed, but some metadata was ignored due to errors.

If the PR fixes our Error while moving old database out of the way woes then party hat 🎉 and I won't look a gift horse in the mouth. I haven't seen the problem lately either, so I can't confirm one way or the other.

@jiceorange
Copy link

The above discussion was helpful for me. I upgraded appstreamcli and I think that the permissions issue has gone away (at version 0.10.6).

I am also having a problem where do-release-upgrade (trying to go from 16.04 to 18.04) is failing wihtout an error. I hoped that this fix would help, but it has not.

See #3489 for a discussion.

@trusktr
Copy link

trusktr commented Feb 17, 2019

What are the correct safe permissions for /var/cache/app-info/xapian/default?

(Or, in other words, if we blindly ran sudo chmod 777 /var/cache/app-info/xapian/default -R, what permissions should we change it (and subfiles) back to? 😆)

My guess is sudo chmod o-w /var/cache/app-info/xapian/default -R. EDIT: Nope, sudo chmod o-w /var/cache/app-info/xapian/default -R resulted in the same Error while moving old database out of the way happening again.

Changing it to 777 fixes it again. 🤔

Obviously if changing it to 777 then applying o-w doesn't work, then it seems that the above sudo chmod g+w /var/cache/app-info/xapian/default -R won't work either, because 777 followed by o-w implies g has w.

@jiceorange
Copy link

Has anyone succeeded in an update from 16.04 to 18.04? Maybe best to start over with a fresh install. Seems that I may be able to copy my files / settings from Windows so that I can restore them on the fresh install, right?

@IGR2014
Copy link

IGR2014 commented Oct 19, 2021

Was unable to upgrade from 20.04 to 20.10 (WSL2, with WSLg, Windows 11 (22000.194)).
Had to do this to upgrade normaly: #3489 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external Issue exists outside of WSL components
Projects
None yet
Development

No branches or pull requests