4

After downloading the Ubuntu app from the Windows store, I tried to run gcc --version and it showed command gcc not found same was the case for g++.

I tried to install using sudo apt install gcc and it kept showing me errors like

Err:1 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 binutils-common amd64 2.30-21ubuntu1~18.04.1 404 Not Found

and at the end it gave me this

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

What I already tried:-

  1. I came across this Bash (on Windows 10) doesn't locate any package I did what was said there and then I ran the update command and then the sudo apt install gcc command. It did install gcc which I checked by using gcc --version. But then when I ran the 'sudo apt install g++` it gave me errors

The following packages have unmet dependencies: g++ : Depends: g++-4.8 (>= 4.8.2-5~) but it is not going to be installed E: Unable to correct problems, you have held broken packages.

  1. My question was identified as a possible duplicate of Unable to correct problems, you have held broken packages , but it turns out it was of no help. When I ran the command dpkg --get-selections | grep hold to find out the list of the held packages I got nothing. I tried again using sudo aptitude install g++ it gave this as an output.
   The following actions will resolve these dependencies:
      Remove the following packages:
1)      bind9-host
2)      cloud-init
3)      dnsutils
4)      initramfs-tools-core
5)      landscape-common
6)      libbind9-160
7)      libcom-err2
8)      libcurl4
9)      libdns1100
10)     libext2fs2
11)     libirs160
12)     libisccfg160
13)     python3-cryptography
14)     python3-oauthlib
15)     python3-openssl
16)     python3-service-identity
17)     python3-twisted
18)     ureadahead
      Install the following packages:
19)     e2fslibs [1.42.9-3ubuntu1.3 (trusty-updates)]
20)     insserv [1.14.0-5ubuntu2 (trusty)]
21)     knot-dnsutils [1.4.2-1 (trusty)]
22)     libck-connector0 [0.4.5-3.1ubuntu2 (trusty)]
23)     libcomerr2 [1.42.9-3ubuntu1.3 (trusty-updates)]
24)     libcurl3 [7.35.0-1ubuntu2.20 (trusty-security, trusty-updates)]
25)     libgcrypt11 [1.5.3-2ubuntu4.6 (trusty-security, trusty-updates)]
26)     libgnutls26 [2.12.23-12ubuntu2.8 (trusty-security, trusty-updates)]
27)     librtmp0 [2.4+20121230.gitdf6c518-1ubuntu0.1 (trusty-security, trusty-updates)]
28)     module-init-tools [15-0ubuntu7 (trusty-security, trusty-updates)]
29)     sysv-rc [2.88dsf-41ubuntu6.3 (trusty-updates)]
      Keep the following packages at their current version:
30)     g++ [Not Installed]
31)     g++-4.8 [Not Installed]
32)     libc-dev-bin [Not Installed]
33)     libc6-dev [Not Installed]
34)     libstdc++-4.8-dev [Not Installed]
      Downgrade the following packages:
35)     curl [7.58.0-2ubuntu3.6 (now) -> 7.35.0-1ubuntu2.20 (trusty-security, trusty-updates)]
36)     e2fsprogs [1.44.1-1ubuntu1.1 (now) -> 1.42.9-3ubuntu1.3 (trusty-updates)]
37)     git [1:2.17.1-1ubuntu0.4 (now) -> 1:1.9.1-1ubuntu0.10 (trusty-security, trusty-updates)]
38)     git-man [1:2.17.1-1ubuntu0.4 (now) -> 1:1.9.1-1ubuntu0.10 (trusty-security, trusty-updates)]
39)     initramfs-tools [0.130ubuntu3.7 (now) -> 0.103ubuntu4.11 (trusty-updates)]
40)     initramfs-tools-bin [0.130ubuntu3.7 (now) -> 0.103ubuntu4.11 (trusty-updates)]
41)     libcurl3-gnutls [7.58.0-2ubuntu3.6 (now) -> 7.35.0-1ubuntu2.20 (trusty-security, trusty-updates)
42)     libgssapi-krb5-2 [1.16-2ubuntu0.1 (now) -> 1.12+dfsg-2ubuntu5.4 (trusty-security, trusty-updates
43)     libk5crypto3 [1.16-2ubuntu0.1 (now) -> 1.12+dfsg-2ubuntu5.4 (trusty-security, trusty-updates)]
44)     libkrb5-3 [1.16-2ubuntu0.1 (now) -> 1.12+dfsg-2ubuntu5.4 (trusty-security, trusty-updates)]
45)     libkrb5support0 [1.16-2ubuntu0.1 (now) -> 1.12+dfsg-2ubuntu5.4 (trusty-security, trusty-updates)
46)     libss2 [1.44.1-1ubuntu1.1 (now) -> 1.42.9-3ubuntu1.2 (trusty-security)]
47)     manpages [4.15-1 (now) -> 3.54-1ubuntu1 (trusty)]
48)     openssh-client [1:7.6p1-4ubuntu0.3 (now) -> 1:6.6p1-2ubuntu2.13 (trusty-security, trusty-updates
49)     openssh-server [1:7.6p1-4ubuntu0.3 (now) -> 1:6.6p1-2ubuntu2.13 (trusty-security, trusty-updates
50)     openssh-sftp-server [1:7.6p1-4ubuntu0.3 (now) -> 1:6.6p1-2ubuntu2.13 (trusty-security, trusty-up
      Leave the following dependencies unresolved:
51)     python3-incremental recommends python3-twisted
52)     python3-jwt recommends python3-cryptography
53)     ubuntu-standard recommends ureadahead

I pressed Y and then

E: The method driver /usr/lib/apt/methods/http could not be found.
E: The method driver /usr/lib/apt/methods/http could not be found.
E: Internal error: couldn't generate list of packages to download
  1. I started fresh by resetting the app and then ran the command sudo apt update and it showed this
Reading package lists... Done
E: Release file for http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease is not valid yet (invalid for another 4h 13min 23s). Updates for this repository will not be applied.
E: Release file for http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease is not valid yet (invalid for another 4h 12min 44s). Updates for this repository will not be applied.
E: Release file for http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease is not valid yet (invalid for another 4h 14min 2s). Updates for this repository will not be applied.

I would also like to mention that I am a beginner to this linux environment so if you can explain your answers a bit it would be really helpful

Arnab_Sen
  • 91
  • 1
  • 6
  • 3
    "I did what was said there" if you followed that answer without changing trusty to bionic that's not going to work (and may explain why it's looking for g++-4.8 whereas the current version for bionic is 7.4.0) – steeldriver Aug 11 '19 at 11:09
  • Related (but with different releases): Ubuntu 19.04 incorrect sources.list – Melebius Aug 11 '19 at 11:18
  • I guess you would need apt-transport-http. I'm not sure if WSL supports it. – Mukesh Sai Kumar Aug 11 '19 at 11:26
  • Probably all that you needed to do originally was run sudo apt update - now (by changing your sources list to include trusty repositories) you have unfortunately dug yourself into a much deeper hole – steeldriver Aug 11 '19 at 11:44
  • @steeldriver I did reset the app to start fresh and ran the update command and the output is mentioned in the answer but even after that, running the sudo apt install g++ gives the same error that I mentioned. Like this Err:1 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 binutils-common amd64 2.30-21ubuntu1~18.04.1 404 Not Found – Arnab_Sen Aug 11 '19 at 11:55
  • Based on your latest update, it looks like the fundamental issue is that the clock and/or timezone information is incorrect - either inside WSL or on the host Windows system. That's preventing the software catalog from updating successfully. – steeldriver Aug 11 '19 at 12:29
  • @steeldriver I am embarrassed to say this, but yeah the Problem was due to my CMOS battery, I didn't notice that my time was lagging by 4 hours. And it works smoothly. Thank you very much for your spontaneous support. – Arnab_Sen Aug 11 '19 at 13:22

1 Answers1

5

The problem was (as mentioned by @steeldriver) my system time was not synced. Perhaps my CMOS battery died out resulting a 4 hour lag. And so whenever I tried to update it showed me error. So, after syncing my time and then running the

sudo apt update
sudo apt install g++
sudo apt install gcc

it installed g++ and gcc successfully.

Arnab_Sen
  • 91
  • 1
  • 6