xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
9.85k stars 774 forks source link

语义版本识别错误 #5503

Closed q962 closed 3 weeks ago

q962 commented 4 weeks ago

Xmake 版本

xmake v2.9.4+HEAD.e85b001f1

操作系统版本和架构

MINGW64_NT-10.0-19045

描述问题

语义版本识别错误

期待的结果

-

工程配置

add_requires("sqlite3 >= 3.46", "luajit >= 2.1", "MagickWand >= 7.1.1")

附加信息和错误日志

$ pkg-config --modversion luajit
2.1.1720049189

$ pkg-config --modversion MagickWand
7.1.1
.xmake\cache\packages\2408\s\sqlite3\3.46.0+0\package.lock
.xmake\cache\packages\2408\l\luajit\>= 2.1\package.lock
.xmake\cache\packages\2408\m\magickwand\>= 7.1.1\package.lock
error: cannot create filelock for package(magickwand)!
Issues-translate-bot commented 4 weeks ago

Bot detected the issue body's language is not English, translate it automatically.


Title: Semantic version recognition error

Xmake version

xmake v2.9.4+HEAD.e85b001f1

Operating system version and architecture

MINGW64_NT-10.0-19045

Describe the problem

Semantic version recognition error

Expected results

-

Project configuration

add_requires("sqlite3 >= 3.46", "luajit >= 2.1", "MagickWand >= 7.1.1")

Additional information and error logs

$ pkg-config --modversion luajit
2.1.1720049189

$ pkg-config --modversion MagickWand
7.1.1
.xmake\cache\packages\2408\s\sqlite3\3.46.0+0\package.lock
.xmake\cache\packages\2408\l\luajit\>= 2.1\package.lock
.xmake\cache\packages\2408\m\magickwand\>= 7.1.1\package.lock
error: cannot create filelock for package(magickwand)!
waruqi commented 4 weeks ago

>= 3.46 里面的空格去掉

Issues-translate-bot commented 4 weeks ago

Bot detected the issue body's language is not English, translate it automatically.


>= 3.46 Remove the spaces inside

q962 commented 3 weeks ago

不可以,或许你并没有仔细看日志。

sqlite3 的语义版本识别是没有问题,我特意贴出来做对比的。

我进行了去除空格的尝试。结果就是,将整个字符串作为了包名

2408\m\magickwand>=7.1.1\latest\package.lock
Issues-translate-bot commented 3 weeks ago

Bot detected the issue body's language is not English, translate it automatically.


No, maybe you didn't read the log carefully.

There is no problem with the semantic version recognition of sqlite3. I posted it specifically for comparison.

I tried removing spaces. The result is that the entire string is used as the package name

2408\m\magickwand>=7.1.1\latest\package.lock
waruqi commented 3 weeks ago

.xmake\cache\packages\2408\s\sqlite3\3.46.0+0\package.lock

sqlite3 正常

.xmake\cache\packages\2408\l\luajit>= 2.1\package.lock

这个是由于里面 add_versions("2.1.0-beta3") 的版本配置不对,得改成 2.1.0+beta3 ,才能正常匹配 >=2.1,如果匹配不到,只能尝试走原始设置的 >=2.1 字符串作为版本。

https://github.com/xmake-io/xmake-repo/blob/02309f96a8d8b59e08db99c074bf56c555595093/packages/l/luajit/xmake.lua#L11

所以你要提 pr 改这个包,使用 2.1.0+beta3 就行了,但是这个包年久失修,还要额外改不少东西才能通过编译。。

  1. tar url 源已经失效,得去掉
  2. 最新的 v2.1 分支编译不过了,得改里面的 xmake.lua port

.xmake\cache\packages\2408\m\magickwand>= 7.1.1\package.lock

xmake-repo 里面压根没这个包

只有一个 imagemagick

https://github.com/xmake-io/xmake-repo/blob/dev/packages/i/imagemagick/xmake.lua

另外,这里面也没有 7.1.1 版本,肯定匹配不到,而且里面的两个版本格式也不对,得改成 7.0.11+13

所以这个包,也得提 pr 过来改进下。

Issues-translate-bot commented 3 weeks ago

Bot detected the issue body's language is not English, translate it automatically.


.xmake\cache\packages\2408\s\sqlite3\3.46.0+0\package.lock

sqlite3 normal

.xmake\cache\packages\2408\l\luajit>= 2.1\package.lock

This is because the version configuration of add_versions("2.1.0-beta3") is incorrect. It must be changed to 2.1.0+beta3 to match >=2.1 normally. If it cannot be matched, you can only try to go The original set's >=2.1 string as version.

https://github.com/xmake-io/xmake-repo/blob/02309f96a8d8b59e08db99c074bf56c555595093/packages/l/luajit/xmake.lua#L11

So you need to submit a PR to change this package, just use 2.1.0+beta3, but this package is in disrepair, and you need to change a lot of additional things before it can be compiled. .

  1. The tar url source has expired and needs to be removed.
  2. The latest v2.1 branch cannot be compiled, so the xmake.lua port in it must be changed.

.xmake\cache\packages\2408\m\magickwand>= 7.1.1\package.lock

There is no such package in xmake-repo at all

There is only one imagemagick

https://github.com/xmake-io/xmake-repo/blob/dev/packages/i/imagemagick/xmake.lua

In addition, there is no version 7.1.1 here, so it will definitely not match, and the format of the two versions inside is not correct, so it must be changed to 7.0.11+13

Therefore, this package needs to be improved through PR.

q962 commented 3 weeks ago

那应该如何做?

只因 xrepo 中存在这个包,但是没有这个版本。就断定失败?

不允许将其他寻找方式作为来源?

是否需要改进错误提示?

Issues-translate-bot commented 3 weeks ago

Bot detected the issue body's language is not English, translate it automatically.


So what should be done?

Just because this package exists in xrepo, but this version does not exist. Just conclude it failed?

Not allowing other search methods as sources?

Do you need to improve error messages?

waruqi commented 3 weeks ago

那应该如何做?

上面我不是说的很明了了么。提 pr 修复 add_versions 中的版本。

只因 xrepo 中存在这个包,但是没有这个版本。就断定失败?

不知道你在说啥,指哪个包?

luajit? 哪没这个版本了?都说了是版本号格式不对,得修包 MagickWand? xmake-repo 压根没这个包。更谈不上没这个版本。

不允许将其他寻找方式作为来源?

我不知道你说的啥方式。。系统库,其他包仓库的包源 原本就能支持,具体看文档。更多查找方式可以自己提 pr 改进包的 add_extsources 或者 on_fetch ,去定制化系统库查找。

是否需要改进错误提示?

你也没完整给 -vD 的错误,我也没法评估是否提示信息不够。但是紧靠你先给的一行 error line ,我也看个大概。

另外,就算提示在完善,最终多半还是会开 issues ,没啥区别。

Issues-translate-bot commented 3 weeks ago

Bot detected the issue body's language is not English, translate it automatically.


What should be done?

Didn’t I make it very clear above? Raise pr to fix versions in add_versions.

Just because this package exists in xrepo, but this version does not exist. Just conclude it failed?

I don’t know what you are talking about, which bag are you referring to?

luajit? Where is this version no longer available? I’ve been told that the format of the version number is wrong and the package needs to be repaired. MagickWand? xmake-repo does not have this package at all. Not to mention the lack of this version.

Not allowing other search methods as sources?

I don't know what way you mean it. . System libraries and package sources from other package warehouses are originally supported. Please refer to the documentation for details. For more search methods, you can provide add_extsources or on_fetch of the PR improvement package yourself to customize the system library search.

Do the error prompts need to be improved?

You didn't give a complete error message for -vD, and I can't evaluate whether the prompt information is insufficient. But next to the error line you gave me first, I can have a rough idea.

In addition, even if the prompts are improving, issues will most likely still be opened in the end, there is no difference.

q962 commented 3 weeks ago

好的,明白了。这涉及两个不同的问题。 先跳过luajit 的错误。

完成的错误日志

...
checking for sqlite3 ... pkgconfig::sqlite3 3.46.0
C:\Users\User\AppData\Roaming\.xmake\cache\packages\2408\m\magickwand\>= 7.1.1\package.lock
error: @programdir\core\main.lua:329: @programdir\core\sandbox\modules\import\core\base\task.lua:65: @programdir\modules\async\runjobs.lua:325: @programdir\core\package\package.lua:719: cannot create filelock for package(MagickWand)!
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:973]:
    [@programdir\core\package\package.lua:719]: in function 'filelock'
    [@programdir\core\package\package.lua:728]: in function 'lock'
    [...modules\private\action\require\impl\install_packages.lua:334]: in function 'jobfunc'
    [@programdir\modules\async\runjobs.lua:241]:

stack traceback:
        [C]: in function 'error'
        @programdir\core\base\os.lua:973: in function 'os.raiselevel'
        (...tail calls...)
        @programdir\core\main.lua:329: in upvalue 'cotask'
        @programdir\core\base\scheduler.lua:406: in function <@programdir\core\base\scheduler.lua:399>

xmake-repo 里没有 MagickWand 这个包,但是 pkgconfig 有这个包。

log::C:\Users\User\AppData\Roaming\.xmake\cache\packages\2408\s\sqlite3\3.46.0+0\package.lock
finding sqlite3 from xmake ..
checking for xmake::sqlite3 ... no
finding sqlite3 from vcpkg ..
finding sqlite3 from conan ..
finding sqlite3 from pkgconfig ..
checking for sqlite3 ... pkgconfig::sqlite3 3.46.0

通过观察日志,可以得知 xmake 会寻找多种来源。最终从pkgconfig获得了sqlite3

但是为什么 MagickWand 就不可以走完这个流程?

通过 print 调试得出 (core/package/package.lua:786)

log::   1.10.6
log::   1.10.6
log::   3.46.0+0
log::   3.46.0+0
log::   latest
log::   latest
log::   >= 7.1.1
log::   >= 7.1.1

并没有移除 >=

所以当我移除 add_requires 中的 >= 时,错误消失了

C:\Users\User\AppData\Roaming\.xmake\cache\packages\2408\m\magickwand\7.1.1\package.lock
finding MagickWand from xmake ..
checking for xmake::MagickWand ... no
finding MagickWand from vcpkg ..
finding MagickWand from conan ..
finding MagickWand from pkgconfig ..
checking for MagickWand ... pkgconfig::MagickWand 7.1.1
waruqi commented 3 weeks ago

通过观察日志,可以得知 xmake 会寻找多种来源。最终从pkgconfig获得了sqlite3 但是为什么 MagickWand 就不可以走完这个流程?

找系统库,通常前提都得先有个 xxx package 在 xmake-repo 的定义,然后里面通过 add_extsources + on_fetch 去改进系统库查找。

如果包缺失,尽管也会默认尝试走系统库查找。但这种 fallback 情况,且不可靠。。不推荐这么做。我这也很少维护处理这种情况。

既然没这个包,那就应该显式走系统包源。。add_requires("pkgconfig::xxxx") 或者其他的包源。。

xq114 commented 3 weeks ago

既然没这个包,那就应该显式走系统包源。。add_requires("pkgconfig::xxxx") 或者其他的包源。。

他说的是给pkgconfig包指定版本的问题, add_requires("pkgconfig::MagickWand >=7.1") 这样,现在从pkgconfig fetch应该还没加上version 信息

Issues-translate-bot commented 3 weeks ago

Bot detected the issue body's language is not English, translate it automatically.


By looking at the logs, you can see that xmake looks for a variety of sources. Finally got sqlite3 from pkgconfig But why can’t MagickWand complete this process?

To find system libraries, usually the prerequisite is to have xxx package defined in xmake-repo, and then use add_extsources + on_fetch to improve system library search.

If the package is missing, although it will also try to search through the system library by default. But this fallback situation is unreliable. . This is not recommended. I rarely maintain or handle this situation.

Since there is no such package, you should explicitly go to the system package source. . add_requires("pkgconfig::xxxx") or other package sources. .

waruqi commented 3 weeks ago

既然没这个包,那就应该显式走系统包源。。add_requires("pkgconfig::xxxx") 或者其他的包源。。

他说的是给pkgconfig包指定版本的问题, add_requires("pkgconfig::MagickWand >=7.1") 这样,现在从pkgconfig fetch应该还没加上version 信息

加了的,除非这个包的 pc file 里本身没提供版本信息。

https://github.com/xmake-io/xmake/blob/ce3d162f72ae7e2f65a7ad85c0e52e195302a14b/xmake/modules/package/manager/pkgconfig/find_package.lua#L68

https://github.com/xmake-io/xmake/blob/ce3d162f72ae7e2f65a7ad85c0e52e195302a14b/xmake/modules/lib/detect/pkgconfig.lua#L207

waruqi commented 3 weeks ago

error: cannot create filelock for package(magickwand)!

这个错误主要由两个原因共同导致:

  1. MagickWand 不存在 xmake-repo 的配置定义,也没有对应的 add_versions,所以 >= 7.1 匹配不到对应的实际版本,那么 package 只能拿 >= 7.1 直接作为版本号,但是 win 下的路径不能带有 > 字符,否则就是无效路径,所以会导致创建文件失败
  2. fallback 到 pkgconfig 查找,但是 fetch 操作之前,也需要执行 package:lock() ,也就同样会触发 > 无效字符路径问题

但是,xmake 内部对第三方包管理,已经系统包,是有对 > 无效字符处理的。

https://github.com/xmake-io/xmake/blob/ce3d162f72ae7e2f65a7ad85c0e52e195302a14b/xmake/core/package/package.lua#L786-L789

也就是说,如果规规矩矩用 add_requires("pkgconfig::MagickWand >=7.1") 去找系统包,反而是没有问题的。。

仅仅到 add_requires("xxx") 这种原本只用于集成 xmake-repo 包,却去加一个没有配置的 package 导致 fallback 到系统 fetch 的情况,就会出现这个问题,毕竟这种边缘 case 基本很少会有人这么搞,测试的最少。。也不推荐这么做

这个 > 无效问题,我可以继续改进修下,但是用 add_requires("xxx") 这种不带三方包域的包,按理应该必须有 package 配置才行。。

不行我就干脆严格约束算了,不去 fallback 了。

waruqi commented 3 weeks ago

无效路径问题,可以等这个 patch https://github.com/xmake-io/xmake/pull/5511

Issues-translate-bot commented 3 weeks ago

Bot detected the issue body's language is not English, translate it automatically.


Since there is no such package, you should explicitly go to the system package source. . add_requires("pkgconfig::xxxx") or other package sources. .

What he is talking about is the problem of specifying the version of the pkgconfig package. add_requires("pkgconfig::MagickWand >=7.1") In this way, the version information should not be added from pkgconfig fetch now.

Added, unless the version information is not provided in the pc file of this package.

https://github.com/xmake-io/xmake/blob/ce3d162f72ae7e2f65a7ad85c0e52e195302a14b/xmake/modules/package/manager/pkgconfig/find_package.lua#L68

https://github.com/xmake-io/xmake/blob/ce3d162f72ae7e2f65a7ad85c0e52e195302a14b/xmake/modules/lib/detect/pkgconfig.lua#L207

q962 commented 3 weeks ago

目前我放弃使用 >= 这种写法。改用 libsv 支持的 ~^x 的方式

既然 > 不是有效的路径符号,在不用改动其他逻辑的情况下,只需要对路径进行编码就解决了文件创建的问题。

Issues-translate-bot commented 3 weeks ago

Bot detected the issue body's language is not English, translate it automatically.


For now I give up using >=. Use the ~^x method supported by libsv instead

Since > is not a valid path symbol, you only need to encode the path to solve the file creation problem without changing other logic.

waruqi commented 3 weeks ago

> 的无效路径问题,用 dev 版本应该就可以了

Issues-translate-bot commented 3 weeks ago

Bot detected the issue body's language is not English, translate it automatically.


> invalid path problem, it should be ok to use the dev version