valet-linux icon indicating copy to clipboard operation
valet-linux copied to clipboard

Bug: Can't install on Arch Linux

Open andrewbernard opened this issue 2 years ago • 10 comments

Basic info

Distro (Name and version) PHP Version Valet version
EndeavourOS_Artemis_nova_22_9 8.1.3 2.2.37

Unable to install. EndeavourOS is plain Arch Linux. Installer demands php8.1-fpm but Arch only has php-fpm. Install fails.

andrewbernard avatar Dec 09 '22 04:12 andrewbernard

I have the same problem, has anyone been able to solve it?

OS: Arch Linux - 6.0.12-arch1-1 PHP: 8.1.13 Compooser: 2.4.4

josefo727 avatar Dec 14 '22 12:12 josefo727

If it helps anyone, i solved it using 81 instead of 8.1, like this:

valet use 81

josefo727 avatar Dec 14 '22 12:12 josefo727

It was not really resolved.

2022-12-14_10-01

josefo727 avatar Dec 14 '22 15:12 josefo727

if you don't use multiple php version. you can just return your php version directly on getPhpVersion in ~/.config/composer/vendor/cpriego/valet-linux/cli/Valet/PhpFpm.php it works for me. using endeavour os. in my case adding code return 72; working fine.

nhawa avatar Jan 06 '23 17:01 nhawa

On Arch Linux, you only have the packages php-fpm and php7-fpm. So assuming that php81-fpm exists or specifying any version with valet use will not work since you would have to pass an empty string to the use command in order to use php-fpm.

plorenz-etes avatar Jan 19 '23 13:01 plorenz-etes

Could you test this PR? https://github.com/cpriego/valet-linux/pull/378

I am using Arch/Manjaro and have the same issue. The PR above will also support AUR packages like php81 and php-fpm81

codepuncher avatar Jan 30 '23 21:01 codepuncher

Faced same issue. I am using Manjaro.

$ valet install 
Nginx was already enabled
Stopping nginx...
[php8.2-fpm] is not installed, installing it now via Pacman... 🍻
error: target not found: php8.2-fpm

I have installed php-fpm already.

$ php --version                                                                                                                             
PHP 8.2.2 (cli) (built: Feb  1 2023 08:33:04) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.2, Copyright (c) Zend Technologies

axel-verse avatar Feb 12 '23 10:02 axel-verse

As a workaround, I've changed ~/.config/composer/vendor/cpriego/valet-linux/cli/Valet/PhpFpm.php at line 393:

return 'php-fpm'; // from return "php{$version}-fpm

also at line 48

       if (!$this->pm->installed("php-fpm")) {         // instead of installed("php{$this->getPhpVersion}-fpm")
            $this->pm->ensureInstalled("php-fpm"); // instead of ensureInstalled("php{$this->getPhpVersion}-fpm")
            $this->sm->enable($this->fpmServiceName());
        }

axel-verse avatar Feb 12 '23 11:02 axel-verse

For temporary fixing, what I did was Changing the install function of this file: cli/Valet/PhpFpm.php

To:

public function install()
{
    if (!$this->pm->installed("php-fpm")) {
        $this->pm->ensureInstalled("php-fpm");
        $this->sm->enable($this->fpmServiceName());
    }
    output('<info>PHP Logs');
    $this->files->ensureDirExists('/var/log', user());

    output('<info>Installing php config');
    $this->installConfiguration();

    output('<info>Restarting php-fpm');
    $this->restart();

    $this->symlinkPrimaryValetSock();

}

i.e., I just removed {$this->getPhpVersion()} from that function that worked for me temporary.

Still waiting for permanent solution

@andrewbernard

abbasmashaddy72 avatar Sep 10 '23 21:09 abbasmashaddy72

I've managed to manually fix this whilst maintaining the php switching feature.

First I've added a new Arch AUR repository to provide php packages named with a similar scheme phpxx-fpm. The only difference is the missing dot in the php version scheme. Plus it supports more php versions thant the default repo.

So I ended up changing the normalizePhpVersion() in ~/.config/composer/vendor/cpriego/valet-linux/cli/Valet/PhpFpm.php line 84 to return a php version without the dot like so :

public static function normalizePhpVersion($version)
{
    return substr(preg_replace('/(?:php@?)?([0-9+])(?:.)?([0-9+])/i', '$1$2', (string)$version), 0, 2);
}

All in all it's a pretty minor change in the code base. Works fine for the time being. Will report back if I end up facing issues with it in the future, but for now I was able to successfully install Valet and ping a .test address

JoelAlphonso avatar Oct 26 '23 14:10 JoelAlphonso