1

This question already has an answer here:

When we run apt-get update and if it fails, a non zero error code should be returned, but in my case its still 0. See below:

root@ubuntu-base:/home/user# apt-get update
Err http://security.ubuntu.com trusty-security InRelease

Err http://packages.siawai.com:8085 trusty InRelease

Err http://ppa.launchpad.net trusty InRelease

Err http://ppa.launchpad.net trusty Release.gpg
  Could not resolve 'ppa.launchpad.net'
Err http://security.ubuntu.com trusty-security Release.gpg
  Could not resolve 'security.ubuntu.com'
Err http://packages.siawai.com:8085 trusty Release.gpg
  Could not resolve 'packages.siawai.com'
Err http://in.archive.ubuntu.com trusty InRelease

Err http://in.archive.ubuntu.com trusty-updates InRelease

Err http://in.archive.ubuntu.com trusty-backports InRelease

Err http://in.archive.ubuntu.com trusty Release.gpg
  Could not resolve 'in.archive.ubuntu.com'
Err http://in.archive.ubuntu.com trusty-updates Release.gpg
  Could not resolve 'in.archive.ubuntu.com'
Err http://in.archive.ubuntu.com trusty-backports Release.gpg
  Could not resolve 'in.archive.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://in.archive.ubuntu.com/ubuntu/dists/trusty/InRelease  

W: Failed to fetch http://in.archive.ubuntu.com/ubuntu/dists/trusty-updates/InRelease  

W: Failed to fetch http://in.archive.ubuntu.com/ubuntu/dists/trusty-backports/InRelease  

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/trusty-security/InRelease  

W: Failed to fetch http://ppa.launchpad.net/ondrej/php/ubuntu/dists/trusty/InRelease  

W: Failed to fetch http://packages.siawai.com:8085/repos/dists/trusty/InRelease  

W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/trusty-security/Release.gpg  Could not resolve 'security.ubuntu.com'

W: Failed to fetch http://packages.siawai.com:8085/repos/dists/trusty/Release.gpg  Could not resolve 'packages.siawai.com'

W: Failed to fetch http://ppa.launchpad.net/ondrej/php/ubuntu/dists/trusty/Release.gpg  Could not resolve 'ppa.launchpad.net'

W: Failed to fetch http://in.archive.ubuntu.com/ubuntu/dists/trusty/Release.gpg  Could not resolve 'in.archive.ubuntu.com'

W: Failed to fetch http://in.archive.ubuntu.com/ubuntu/dists/trusty-updates/Release.gpg  Could not resolve 'in.archive.ubuntu.com'

W: Failed to fetch http://in.archive.ubuntu.com/ubuntu/dists/trusty-backports/Release.gpg  Could not resolve 'in.archive.ubuntu.com'

W: Some index files failed to download. They have been ignored, or old ones used instead.
root@ubuntu-base:/home/user# echo $?
0

What could be the issue? I am running ubuntu 14.04.

marked as duplicate by Stephen Kitt, Kusalananda, roaima, Isaac, Timothy Martin Feb 9 '18 at 17:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    "Could not resolve ..." suggests a problem with DNS – Raman Sailopal Feb 8 '18 at 11:50
  • 1
    Yes, its a network failure created on purpose. The issue is with the return code. Why is it not non zero – Vijay47 Feb 8 '18 at 11:57
  • "When we run apt-get update and if it fails, a non zero error code should be returned". Is that "should" as in "the documentation tells me so" or as in "I expect it to do so"? – roaima Feb 8 '18 at 22:00
0

This is intentional; see #778357:

The results are meaningful. 0 indicates success or transient error, whereas other values indicate a persistent error.

  • Thanks for the answer. Transient errors? What causes it? Or how can it be fixed? Here I just removed internet access from a VM and run apt-get update. It returns non zero error code on other ubuntu VMs, but this one is returning 0. – Vijay47 Feb 8 '18 at 13:17
  • I am mostly concerned why its returning 0 in this VM only. – Vijay47 Feb 8 '18 at 13:21
  • A transient error refers to an error which will fix itself at some point, in all likelihood — basically, apt-get update returns non-zero only if human intervention is needed. If you’re seeing varying behaviour from one VM to another, you should mention that in your question. – Stephen Kitt Feb 8 '18 at 13:23
  • By default it returns non zero, thats why it was not mentioned in the question – Vijay47 Feb 8 '18 at 13:24
  • I also noticed Reading package lists... Done. Meaning something successful has happened. May be thats why it returned 0. What causes Reading package lists... Done? – Vijay47 Feb 8 '18 at 13:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.