asdf-community / asdf-php

PHP plugin for the asdf version manager
https://github.com/asdf-vm/asdf
Apache License 2.0
215 stars 100 forks source link

asdf-php plugin is not working at all #176

Open miko-codes-a-lot opened 2 weeks ago

miko-codes-a-lot commented 2 weeks ago

Provide environment information

OS:
Linux miko-ThinkPad-E16-Gen-2 6.8.0-41-generic #41-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug  2 20:41:06 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

SHELL:
GNU bash, version 5.2.21(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

BASH VERSION:
5.2.21(1)-release

ASDF VERSION:
v0.14.0-ccdd47d

ASDF INTERNAL VARIABLES:
ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=.tool-versions
ASDF_DATA_DIR=/home/miko/.asdf
ASDF_DIR=/home/miko/.asdf
ASDF_CONFIG_FILE=/home/miko/.asdfrc

ASDF INSTALLED PLUGINS:
awscli                       https://github.com/MetricMike/asdf-awscli.git main ac99537
eksctl                       https://github.com/elementalvoid/asdf-eksctl.git master 6c2266d
java                         https://github.com/halcyon/asdf-java.git master 15288ab
kubectl                      https://github.com/asdf-community/asdf-kubectl.git master cbe6df4
nodejs                       https://github.com/asdf-vm/asdf-nodejs.git master c36e6f0

To Reproduce

Run the command after installing the plugin:

asdf list all php

Describe the Bug

Plugin php's list-all callback script failed with output: awk: line 1: regular expression compile failed (bad interval expression) ({})

Expected Behaviour

To be able to list all of PHP versions so I can start my download and installation

RobLoach commented 2 weeks ago

This'll fix that https://github.com/asdf-community/asdf-php/pull/172

mfandrade commented 1 week ago

The output of git ls-remote --tags https://github.com/php/php-src.git | grep 'php-' is:

(...)
80c0a4323d487cad9cb954f0ae476ee069b6f271    refs/tags/php-8.4.0beta4^{}
73f9f842dde0f44a730eb8ea1df29e7e2961dcf9    refs/tags/php4
05309823902ed618a60123ac14d1c0d3297d84e5    refs/tags/php4^{}

The line 13 of list-all script tries to filter those lines using awk but the curly braces {} are not escaped. So the correct version of this script should change that line:

diff --git a/bin/list-all b/bin/list-all
index 3c5c3e0..0270e12 100755
--- a/bin/list-all
+++ b/bin/list-all
@@ -10,7 +10,7 @@ sort_versions() {
 versions=$(
   git ls-remote --tags https://github.com/php/php-src.git |
     grep 'php-' |
-    awk '!/({})/ {print $2}' |
+    awk '!/\{.*\}/ {print $2}' |
     sed 's/refs\/tags\/php-//' |
     sort_versions |
     xargs