Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

E: Unable to locate package apache2 #15

Open
f97-backup opened this issue Oct 4, 2021 · 9 comments
Open

E: Unable to locate package apache2 #15

f97-backup opened this issue Oct 4, 2021 · 9 comments

Comments

@f97-backup
Copy link

I get this bug when installing, does anyone know why? Thanks :)))

image

@luizbills
Copy link
Owner

Try to install again. I did a test now and it worked fine for me.

@mrchrisadams
Copy link

Hi there,

I'm getting this error too, and I think you can reproduce the issue by trying to spin up an environment at the link below

https://gitpod.io/#https://github.com/thegreenwebfoundation/wp-green-checker/compare/ca-gitpod-2

I see two issues - one is minor (which I can make a PR for), and the other is more involved and related to apache2 being missing. At least that's what this line suggests to me:

E: Unable to locate package apache2

The full logs are below:

Connecting to workspace logs...
building base image

initializing base image context
running base image build
Step 1/11 : FROM gitpod/workspace-mysql
latest: Pulling from gitpod/workspace-mysql
Digest: sha256:672678bd97bd843c810fdbf04f0786483a8742d5a7716985fa7c3e74fe6d1479
Status: Image is up to date for gitpod/workspace-mysql:latest
 ---> d8aa3079547c
Step 2/11 : ENV PHP_VERSION="7.4"
 ---> Using cache
 ---> 9c30775c3857
Step 3/11 : ENV APACHE_DOCROOT="public_html"
 ---> Using cache
 ---> ec1b0be6a5b2
Step 4/11 : USER gitpod
 ---> Using cache
 ---> d23bba622706
Step 5/11 : ADD https://api.wordpress.org/secret-key/1.1/salt?rnd=152634 /dev/null


 ---> d3e3f62d07b5
Step 6/11 : RUN git clone https://github.com/luizbills/gitpod-wordpress $HOME/gitpod-wordpress &&     cat $HOME/gitpod-wordpress/conf/.bashrc.sh >> $HOME/.bashrc &&     . $HOME/.bashrc &&     bash -c ". .nvm/nvm.sh && nvm install --lts"
 ---> Running in 601d0b880447
Cloning into '/home/gitpod/gitpod-wordpress'...
Installing latest LTS version.
Downloading and installing node v14.18.1...
Downloading https://nodejs.org/dist/v14.18.1/node-v14.18.1-linux-x64.tar.xz...
######################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v14.18.1 (npm v6.14.15)
 ---> 321734f4b228
Step 7/11 : USER root
 ---> Running in f7624f1c0c62
 ---> 124f82e3f533
Step 8/11 : ARG DEBIAN_FRONTEND=noninteractive
 ---> Running in b6c74cd09d7b
 ---> e63aceba09fe
Step 9/11 : RUN go get github.com/mailhog/MailHog &&     go get github.com/mailhog/mhsendmail &&     cp $GOPATH/bin/MailHog /usr/local/bin/mailhog &&     cp $GOPATH/bin/mhsendmail /usr/local/bin/mhsendmail &&     ln $GOPATH/bin/mhsendmail /usr/sbin/sendmail &&     ln $GOPATH/bin/mhsendmail /usr/bin/mail &&    apt-get -y install apache2 &&     chown -R gitpod:gitpod /var/run/apache2 /var/lock/apache2 /var/log/apache2 &&     echo "include $HOME/gitpod-wordpress/conf/apache.conf" > /etc/apache2/apache2.conf &&     echo ". $HOME/gitpod-wordpress/conf/apache.env.sh" > /etc/apache2/envvars &&     apt-get -qy purge php* &&     add-apt-repository ppa:ondrej/php &&     apt-get update &&     apt-get -qy install         libapache2-mod-php         php${PHP_VERSION}         php${PHP_VERSION}-common         php${PHP_VERSION}-cli         php${PHP_VERSION}-mbstring         php${PHP_VERSION}-curl         php${PHP_VERSION}-gd         php${PHP_VERSION}-intl         php${PHP_VERSION}-mysql         php${PHP_VERSION}-xml         php${PHP_VERSION}-json         php${PHP_VERSION}-zip         php${PHP_VERSION}-soap         php${PHP_VERSION}-bcmath         php${PHP_VERSION}-opcache         php-xdebug &&     apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* &&     update-alternatives --set php /usr/bin/php${PHP_VERSION} &&     cat /home/gitpod/gitpod-wordpress/conf/php.ini >> /etc/php/${PHP_VERSION}/apache2/php.ini &&     a2dismod php* &&     a2dismod mpm_* &&     a2enmod mpm_prefork &&     a2enmod php${PHP_VERSION} &&     wget -q https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O $HOME/wp-cli.phar &&     chmod +x $HOME/wp-cli.phar &&     mv $HOME/wp-cli.phar /usr/local/bin/wp &&     chown gitpod:gitpod /usr/local/bin/wp
 ---> Running in 6aabf1fbbf6f
go: downloading github.com/mailhog/MailHog v1.0.1
go: downloading github.com/mailhog/MailHog-Server v1.0.1
go: downloading github.com/gorilla/pat v1.0.1
go: downloading github.com/mailhog/MailHog-UI v1.0.1
go: downloading github.com/ian-kent/envconf v0.0.0-20141026121121-c19809918c02
go: downloading github.com/ian-kent/go-log v0.0.0-20160113211217-5731446c36ab
go: downloading github.com/mailhog/http v1.0.1
go: downloading github.com/mailhog/mhsendmail v0.2.0
go: downloading golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
go: downloading github.com/mailhog/data v1.0.1
go: downloading github.com/mailhog/smtp v1.0.1
go: downloading github.com/gorilla/context v1.1.1
go: downloading github.com/mailhog/storage v1.0.1
go: downloading github.com/ian-kent/linkio v0.0.0-20170807205755-97566b872887
go: downloading github.com/ian-kent/goose v0.0.0-20141221090059-c3541ea826ad
go: downloading github.com/ogier/pflag v0.0.1
go: downloading github.com/t-k/fluent-logger-golang v1.0.0
go: downloading github.com/gorilla/mux v1.8.0
go: downloading github.com/gorilla/websocket v1.4.2
go: downloading github.com/tinylib/msgp v1.1.6
go: downloading gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
go: downloading github.com/philhofer/fwd v1.1.1
go get: installing executables with 'go get' in module mode is deprecated.
        Use 'go install pkg@version' instead.
        For more information, see https://golang.org/doc/go-get-install-deprecation
        or run 'go help get' or 'go help install'.
go get: installing executables with 'go get' in module mode is deprecated.
        Use 'go install pkg@version' instead.
        For more information, see https://golang.org/doc/go-get-install-deprecation
        or run 'go help get' or 'go help install'.
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package apache2


Error: build failed: cannot build base image: The command '/bin/sh -c go get github.com/mailhog/MailHog &&     go get github.com/mailhog/mhsendmail &&     cp $GOPATH/bin/MailHog /usr/local/bin/mailhog &&     cp $GOPATH/bin/mhsendmail /usr/local/bin/mhsendmail &&     ln $GOPATH/bin/mhsendmail /usr/sbin/sendmail &&     ln $GOPATH/bin/mhsendmail /usr/bin/mail &&    apt-get -y install apache2 &&     chown -R gitpod:gitpod /var/run/apache2 /var/lock/apache2 /var/log/apache2 &&     echo "include $HOME/gitpod-wordpress/conf/apache.conf" > /etc/apache2/apache2.conf &&     echo ". $HOME/gitpod-wordpress/conf/apache.env.sh" > /etc/apache2/envvars &&     apt-get -qy purge php* &&     add-apt-repository ppa:ondrej/php &&     apt-get update &&     apt-get -qy install         libapache2-mod-php         php${PHP_VERSION}         php${PHP_VERSION}-common         php${PHP_VERSION}-cli         php${PHP_VERSION}-mbstring         php${PHP_VERSION}-curl         php${PHP_VERSION}-gd         php${PHP_VERSION}-intl         php${PHP_VERSION}-mysql         php${PHP_VERSION}-xml         php${PHP_VERSION}-json         php${PHP_VERSION}-zip         php${PHP_VERSION}-soap         php${PHP_VERSION}-bcmath         php${PHP_VERSION}-opcache         php-xdebug &&     apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* &&     update-alternatives --set php /usr/bin/php${PHP_VERSION} &&     cat /home/gitpod/gitpod-wordpress/conf/php.ini >> /etc/php/${PHP_VERSION}/apache2/php.ini &&     a2dismod php* &&     a2dismod mpm_* &&     a2enmod mpm_prefork &&     a2enmod php${PHP_VERSION} &&     wget -q https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O $HOME/wp-cli.phar &&     chmod +x $HOME/wp-cli.phar &&     mv $HOME/wp-cli.phar /usr/local/bin/wp &&     chown gitpod:gitpod /usr/local/bin/wp' returned a non-zero code: 100

Clues for a fix

I'm not sure but this might be related to changes upstream - if I clone the repo to my laptop locally and tru buiding from the docker file, I'm unable to install apache to there as well.

I can try buliding it locally like so:

docker build --no-cache -t debugging-local-image  -f ./.gitpod.dockerfile . 

And then when I run the tagged image like so:

docker run -it debugging-local-image /bin/bash

Attempts to install apache2 fail:

gitpod ~ $ apt install apache2
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
gitpod ~ $ sudo apt install apache2
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package apache2
gitpod ~ $

I can run an sudo apt update which lets me start installing apache2, but then there's another problem:

gitpod ~ $ sudo apt update
Get:1 http://ppa.launchpad.net/git-core/ppa/ubuntu focal InRelease [23.8 kB]
Get:2 https://download.docker.com/linux/ubuntu focal InRelease [57.7 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]
Get:4 https://apt.llvm.org/focal llvm-toolchain-focal InRelease [5,526 B]
Get:5 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:6 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:7 http://archive.ubuntu.com/ubuntu focal-backports InRelease [101 kB]
Get:8 http://ppa.launchpad.net/git-core/ppa/ubuntu focal/main amd64 Packages [3,165 B]
Get:9 https://download.docker.com/linux/ubuntu focal/stable amd64 Packages [12.5 kB]
Get:10 https://apt.llvm.org/focal llvm-toolchain-focal/main amd64 Packages [11.9 kB]
Get:11 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages [11.3 MB]
Get:12 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [796 kB]
Get:13 http://archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages [177 kB]
Get:14 http://archive.ubuntu.com/ubuntu focal/restricted amd64 Packages [33.4 kB]
Get:15 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages [1,275 kB]
Get:16 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [1,084 kB]
Get:17 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [1,587 kB]
Get:18 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [583 kB]
Get:19 http://archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [637 kB]
Get:20 http://archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 Packages [33.4 kB]
Get:21 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages [6,310 B]
Get:22 http://archive.ubuntu.com/ubuntu focal-backports/main amd64 Packages [2,668 B]
Get:23 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [1,137 kB]
Get:24 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages [30.1 kB]
Fetched 19.4 MB in 4s (4,529 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
119 packages can be upgraded. Run 'apt list --upgradable' to see them.
gitpod ~ $ DEBIAN_FRONTEND=noninteractive sudo apt install apache2 -yqq
The following additional packages will be installed:
  apache2-bin apache2-data apache2-utils libaprutil1-dbd-sqlite3 libaprutil1-ldap libjansson4 liblua5.2-0
Suggested packages:
  apache2-doc apache2-suexec-pristine | apache2-suexec-custom ufw
The following NEW packages will be installed:
  apache2 apache2-bin apache2-data apache2-utils libaprutil1-dbd-sqlite3 libaprutil1-ldap libjansson4 liblua5.2-0
0 upgraded, 8 newly installed, 0 to remove and 119 not upgraded.
Need to get 1,673 kB of archives.
After this operation, 7,456 kB of additional disk space will be used.
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libaprutil1-dbd-sqlite3:amd64.
(Reading database ... 33670 files and directories currently installed.)
Preparing to unpack .../0-libaprutil1-dbd-sqlite3_1.6.1-4ubuntu2_amd64.deb ...
Unpacking libaprutil1-dbd-sqlite3:amd64 (1.6.1-4ubuntu2) ...
Selecting previously unselected package libaprutil1-ldap:amd64.
Preparing to unpack .../1-libaprutil1-ldap_1.6.1-4ubuntu2_amd64.deb ...
Unpacking libaprutil1-ldap:amd64 (1.6.1-4ubuntu2) ...
Selecting previously unselected package libjansson4:amd64.
Preparing to unpack .../2-libjansson4_2.12-1build1_amd64.deb ...
Unpacking libjansson4:amd64 (2.12-1build1) ...
Selecting previously unselected package liblua5.2-0:amd64.
Preparing to unpack .../3-liblua5.2-0_5.2.4-1.1build3_amd64.deb ...
Unpacking liblua5.2-0:amd64 (5.2.4-1.1build3) ...
Selecting previously unselected package apache2-bin.
Preparing to unpack .../4-apache2-bin_2.4.41-4ubuntu3.7_amd64.deb ...
Unpacking apache2-bin (2.4.41-4ubuntu3.7) ...
Selecting previously unselected package apache2-data.
Preparing to unpack .../5-apache2-data_2.4.41-4ubuntu3.7_all.deb ...
Unpacking apache2-data (2.4.41-4ubuntu3.7) ...
Selecting previously unselected package apache2-utils.
Preparing to unpack .../6-apache2-utils_2.4.41-4ubuntu3.7_amd64.deb ...
Unpacking apache2-utils (2.4.41-4ubuntu3.7) ...
Selecting previously unselected package apache2.
Preparing to unpack .../7-apache2_2.4.41-4ubuntu3.7_amd64.deb ...
Unpacking apache2 (2.4.41-4ubuntu3.7) ...
Setting up libaprutil1-ldap:amd64 (1.6.1-4ubuntu2) ...
Setting up libaprutil1-dbd-sqlite3:amd64 (1.6.1-4ubuntu2) ...
Setting up libjansson4:amd64 (2.12-1build1) ...
Setting up liblua5.2-0:amd64 (5.2.4-1.1build3) ...
Setting up apache2-data (2.4.41-4ubuntu3.7) ...
Setting up apache2-utils (2.4.41-4ubuntu3.7) ...
Setting up apache2-bin (2.4.41-4ubuntu3.7) ...
Setting up apache2 (2.4.41-4ubuntu3.7) ...

Configuration file '/etc/apache2/apache2.conf'
 ==> File on system created by you or by a script.
 ==> File also in package provided by package maintainer.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** apache2.conf (Y/I/N/O/D/Z) [default=N] ?

Configuration file '/etc/apache2/envvars'
 ==> File on system created by you or by a script.
 ==> File also in package provided by package maintainer.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** envvars (Y/I/N/O/D/Z) [default=N] ?

sh: 1: /etc/apache2/envvars: gp: not found
ERROR: Module mpm_prefork is enabled - cannot proceed due to conflicts. It needs to be disabled first!
dpkg: error processing package apache2 (--configure):
 installed apache2 package post-installation script subprocess returned error exit status 1
Processing triggers for systemd (245.4-4ubuntu3.4) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
Errors were encountered while processing:
 apache2
E: Sub-process /usr/bin/dpkg returned an error code (1)
gitpod ~ $ exit

I'm not sure how to get around the prompts there, but this post makes me wonder if a change in the workspace image has impacted this repo.

https://community.gitpod.io/t/is-there-an-easy-way-to-create-wordpress-sites-from-gitpod/1072/6

@ulinaaron
Copy link

I've been having issues with this too. If I spin up this repo directly in GitPod (https://gitpod.io/#https://github.com/luizbills/gitpod-wordpress) it will install correctly without issue.

However if I try to copy the dockerfile or .gitpod.yml file into a theme or plugin I run into the apache2 cannot be installed issues.

@luizbills
Copy link
Owner

hey guys, I'm very busy at moment. As soon as possible I will try to work on a fix.

@f97-2308
Copy link

f97-2308 commented Dec 22, 2021

@ulinaaron, @mrchrisadams Sorry, I found a solution to this problem but I forgot this issue, If you used docker mysql tag is branch-pr-264, everything will okay.

# Gitpod docker image for WordPress | https://github.com/luizbills/gitpod-wordpress
# License: MIT (c) 2020 Luiz Paulo "Bills"
# Version: 0.8

FROM gitpod/workspace-mysql:branch-pr-264

I don't know what the problem is here, and hope luizbills will fix it soon.

@TeoTsiok
Copy link

Try again by using this command:
apt-get upgrade -y

@mrchrisadams
Copy link

mrchrisadams commented Jun 5, 2022

For anyone following along, this issue here helps shed light on why this was happening, and points to a fix.

Basically workspace-mysql which I think this image was based on was originally based on workspace-full, which did include apache2, but a change was made to have workspace-mysql be based on workspace-base which did not have apache2 installed.

gitpod-io/workspace-images#675

This merged PR seems to suggest that it's resolved upstream now, and the workspace-mysql image once again includes apache2 because it's derived from workspace-full once more.

gitpod-io/workspace-images#677

I can try testing this out again later this week, but if anyone else would be up for testing before I get to it, I'd be grateful.

@luizbills
Copy link
Owner

I'm working in a rework using only the gitpod/workspace-base and changing mysql to mariadb.

@luizbills
Copy link
Owner

luizbills commented Jun 6, 2022

@devwax devwax mentioned this issue Jun 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants