1

The error I'm facing is on Gitpod with PHP version, so the question is, how can I delete PHP completely from the workspace or replace it? Basically, I want to downgrade it.

I want to replace PHP with an older version. Unfortunately, I’m not able to get rid of the default PHP version 7.4 of the MySQL workspace.

I tried nearly every style of removing it in my .gitpod.Dockerfile file.

I activated the Feature Preview to have sudo support and I uninstalled every PHP version via gitpod dockerfile and ran

sudo apt-get purge ‘php*’

in the command line. It just says that no PHP is installed, but

whereis php

still gives me the output.

php -v

always gives me PHP v7.4

To install another php version is possible (e.g. with brew) but without removing the old one, I don’t know how I could use the new one.

Could someone please tell me, how can I downgrade this PHP version in "GITPOD" by replacing it or some other way?

Edit: this was the code I was trying to run:

FROM gitpod/workspace-mysql

USER root RUN sudo add-apt-repository ppa:ondrej/php RUN sudo apt-get -y update RUN sudo apt-get -y install php7.2 RUN sudo update-alternatives --set php /usr/bin/php7.2 RUN sudo a2dismod php7.4 RUN sudo systemctl restart apache2

USER gitpod

Thanks in advance.

Best Regards

Pranav
  • 31
  • 6
  • 2
    What's the reason you don't want to use 7.4 and instead downgrade to a less secure less feature rich 7.1? Is there some code which requires 7.1, and if that's the case let's fix it if possible. – hppycoder Mar 29 '21 at 23:18
  • If this is a docker-based solution then you should simply switch to an image with 7.1/7.2. Trying to reinstall PHP inside of a container makes no sense. The better alternative is, as always, to make your code work with the current versions of PHP rather than bending over backwards to keep running EOL versions. – Sammitch Mar 29 '21 at 23:34
  • Can you share more details, like the connection to [tag:composer-php]? – Nico Haase Mar 30 '21 at 06:02
  • That was my initial thought, but due to a lot of dependencies, I have to stick to v7.2. @NicoHaase what do you mean by connection to composer-php? – Pranav Mar 30 '21 at 17:53
  • I tried the following: FROM gitpod/workspace-mysql USER root RUN sudo add-apt-repository ppa:ondrej/php RUN sudo apt-get -y update RUN sudo apt-get -y install php7.2 RUN sudo update-alternatives --set php /usr/bin/php7.2 RUN sudo a2dismod php7.4 RUN sudo systemctl restart apache2 USER gitpod and I get following error: Error: build failed: cannot build base image: The command '/bin/sh -c sudo apt-get -y install php7.2' returned a non-zero code: 100 – Pranav Mar 30 '21 at 17:59

1 Answers1

1

The problem is the install command. because of the script that runs in the background.

So the solution is running the following command instead of running apt-get install

install-packages php7.2

details of the answer could be found in the following thread:

Downgrade default PHP v7.4.3 to 7.1.3 or 7.2

Pranav
  • 31
  • 6