Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packages are not taken into account until you wipe out the cache #1420

Closed
SirLynix opened this issue May 20, 2021 · 8 comments
Closed

Packages are not taken into account until you wipe out the cache #1420

SirLynix opened this issue May 20, 2021 · 8 comments
Milestone

Comments

@SirLynix
Copy link
Member

SirLynix commented May 20, 2021

Describe the bug

When you make a project, build it with xmake and then adds some package, xmake won't ask you to install it until you wipe out the cache.

How to reproduce:

Have this xmake.lua:

target("test_packagecache")
    set_kind("binary")
    add_files("src/main.cpp")

src/main.cpp:

#include <iostream>

int main()
{
    std::cout << "Hello world!" << std::endl;
}

Build it and run it:

PS C:\Projets\Tests\xmake-build\test_packagecache> xmake -v
checking for vswhere.exe ... C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe
checking for cl.exe ... C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64\cl.exe
checking for Microsoft Visual Studio (x64) version ... 2019
checking for dmd ... no
checking for ldc2 ... no
checking for gdc ... no
checking for zig ... no
checking for zig ... no
checking for link.exe ... C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64\link.exe
checking for the linker (ld) ... link.exe
checking for cl.exe ... C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64\cl.exe
checking for the c++ compiler (cxx) ... cl.exe
checking for ccache ... no
[ 25%]: compiling.release src\main.cpp
"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.28.29910\\bin\\HostX64\\x64\\cl.exe" -c /EHsc -nologo -Fobuild\.objs\test_packagecache\windows\x64\release\src\main.cpp.obj src\main.cpp
checking for C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64\cl.exe ... ok
checking for flags (cl_sourceDependencies) ... ok
[ 50%]: linking.release test_packagecache.exe
"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.28.29910\\bin\\HostX64\\x64\\link.exe" -nologo -dynamicbase -nxcompat -machine:x64 -out:build\windows\x64\release\test_packagecache.exe build\.objs\test_packagecache\windows\x64\release\src\main.cpp.obj
[100%]: build ok!
PS C:\Projets\Tests\xmake-build\test_packagecache> xmake run
Hello world!

So far so good.

Now edit the xmake.lua:

add_requires("fmt")

target("test_packagecache")
    set_kind("binary")
    add_files("src/main.cpp")
    add_packages("fmt")

(Not required) edit main.cpp:

#include <fmt/core.h>

int main()
{
  fmt::print("Hello, world!\n");
}

Build again:

PS C:\Projets\Tests\xmake-build\test_packagecache> xmake -v
checking for link.exe ... C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64\link.exe
checking for the linker (ld) ... link.exe
checking for cl.exe ... C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64\cl.exe
checking for the c++ compiler (cxx) ... cl.exe
checking for ccache ... no
[ 25%]: compiling.release src\main.cpp
"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.28.29910\\bin\\HostX64\\x64\\cl.exe" -c /EHsc -nologo -Fobuild\.objs\test_packagecache\windows\x64\release\src\main.cpp.obj src\main.cpp
checking for C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64\cl.exe ... ok
checking for flags (cl_sourceDependencies) ... ok
error: main.cpp
src\main.cpp(1): fatal error C1083: Impossible d'ouvrir le fichier include : 'fmt/core.h' : No such file or directory

xmake didn't ask me to install fmt lib.

If I delete the .xmake folder and try again:

PS C:\Projets\Tests\xmake-build\test_packagecache> xmake
checking for platform ... windows
checking for architecture ... x64
checking for Microsoft Visual Studio (x64) version ... 2019
note: try installing these packages (pass -y to skip confirm)?
in xmake-repo:
  -> fmt 7.1.3 [vs_runtime:MT]
please input: y (y/n)

Also

I think this is related, if you input "n" and try again, xmake won't ask you to install package again:

PS C:\Projets\Tests\xmake-build\test_packagecache> xmake -v
checking for vswhere.exe ... C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe
checking for cl.exe ... C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64\cl.exe
checking for Microsoft Visual Studio (x64) version ... 2019
checking for dmd ... no
checking for ldc2 ... no
checking for gdc ... no
checking for zig ... no
checking for zig ... no
checking for unzip ... no
checking for 7z ... C:\Program Files\xmake\winenv\bin\7z
checking for git ... ok
checking for gzip ... no
checking for ping ... ok
pinging for the host(gitlab.com) ... 65535 ms
pinging for the host(github.com) ... 38 ms
pinging for the host(gitee.com) ... 65535 ms
checking for cmake ... C:\Program Files\CMake\bin\cmake
checking for xmake::fmt ... no
checking for vcpkg ... no
checking for pkg-config ... no
checking for fmt ... no
checking for cmake ... C:\Program Files\CMake\bin\cmake
note: try installing these packages (pass -y to skip confirm)?
in test-repo:
  -> fmt 7.1.3 [vs_runtime:MT]
please input: y (y/n)
n
error: packages(fmt): must be installed!
PS C:\Projets\Tests\xmake-build\test_packagecache> xmake -v
checking for link.exe ... C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64\link.exe
checking for the linker (ld) ... link.exe
checking for cl.exe ... C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64\cl.exe
checking for the c++ compiler (cxx) ... cl.exe
checking for ccache ... no
[ 25%]: compiling.release src\main.cpp
"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.28.29910\\bin\\HostX64\\x64\\cl.exe" -c /EHsc -nologo -Fobuild\.objs\test_packagecache\windows\x64\release\src\main.cpp.obj src\main.cpp
checking for C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64\cl.exe ... ok
checking for flags (cl_sourceDependencies) ... ok
error: main.cpp
src\main.cpp(1): fatal error C1083: Impossible d'ouvrir le fichier include : 'fmt/core.h' : No such file or directory

I couldn't reproduce it everytime, sometimes it works well and sometimes it has this bug, but it happens fairly often

Expected behavior

That xmake always ask to install mandatory packages if not installed and take them into account.

Related Environment

Please provide compiling and running environment information:

  • xmake version: xmake v2.5.4
  • os: Windows 10
  • target platform: Windows 10
@waruqi
Copy link
Member

waruqi commented May 22, 2021

I have fixed it on dev, you can try it again.

@waruqi waruqi added this to the v2.5.5 milestone May 22, 2021
@SirLynix
Copy link
Member Author

SirLynix commented May 22, 2021

I managed to reproduce it on the first try right after updating

lynix@SirLynixVanDesktop:/mnt/c/Projets/Tests/xmake-build/test_packagecache$ xmake.exe
checking for platform ... windows
checking for architecture ... x64
checking for Microsoft Visual Studio (x64) version ... 2019
[ 25%]: compiling.release src\main.cpp
[ 50%]: linking.release test_packagecache.exe
[100%]: build ok!

** Add fmt to xmake.lua and update main.cpp **

lynix@SirLynixVanDesktop:/mnt/c/Projets/Tests/xmake-build/test_packagecache$ xmake.exe
[ 25%]: compiling.release src\main.cpp
error: main.cpp
src\main.cpp(1): fatal error C1083: Impossible d'ouvrir le fichier include : 'fmt/core.h' : No such file or directory

lynix@SirLynixVanDesktop:/mnt/c/Projets/Tests/xmake-build/test_packagecache$ xmake.exe -vD
[ 25%]: compiling.release src\main.cpp
"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.28.29910\\bin\\HostX64\\x64\\cl.
exe" -c /EHsc -nologo -Fobuild\.objs\test_packagecache\windows\x64\release\src\main.cpp.obj src\main.cpp
error: @programdir\modules\private\async\runjobs.lua:225: @programdir\modules\private\action\build\object.lua:78: @progr
amdir\modules\core\tools\cl.lua:447: main.cpp
src\main.cpp(1): fatal error C1083: Impossible d'ouvrir le fichier include : 'fmt/core.h' : No such file or directory

stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:800]: in function 'raise'
    [@programdir\modules\core\tools\cl.lua:447]: in function 'catch'
    [@programdir\core\sandbox\modules\try.lua:127]: in function 'try'
    [@programdir\modules\core\tools\cl.lua:401]:
    [C]: in function 'compile'
    [@programdir\modules\private\action\build\object.lua:78]: in function 'script'
    [@programdir\modules\private\action\build\object.lua:91]: in function '_build_object'
    [@programdir\modules\private\action\build\object.lua:116]: in function 'jobfunc'
    [@programdir\modules\private\async\runjobs.lua:201]:
    [C]: in function 'trycall'
    [@programdir\core\sandbox\modules\try.lua:121]: in function 'try'
    [@programdir\modules\private\async\runjobs.lua:194]: in function 'cotask'
    [@programdir\core\base\scheduler.lua:365]:

stack traceback:
        [C]: in function 'error'
        @programdir\core\base\os.lua:800: in function 'raise'
        @programdir\modules\private\async\runjobs.lua:225: in function 'catch'
        @programdir\core\sandbox\modules\try.lua:127: in function 'try'
        @programdir\modules\private\async\runjobs.lua:194: in function 'cotask'
        @programdir\core\base\scheduler.lua:365: in function <@programdir\core\base\scheduler.lua:362>

@SirLynix
Copy link
Member Author

SirLynix commented May 22, 2021

Could this be related to WSL? I tried to reproduce it with powershell without success.
It would be weird since there should be no difference between calling xmake from powershell and calling it from WSL.

@waruqi
Copy link
Member

waruqi commented May 22, 2021

I managed to reproduce it on the first try right after updating

you need run xmake f -c to clean config cache first after updating

@SirLynix
Copy link
Member Author

I deleted the .xmake folder after updating, I guess that does the trick too.

@SirLynix
Copy link
Member Author

I managed to reproduce it with Powershell as well, same output as earlier.

To be clear, what I'm doing is having the project without fmt (with a simple C++ hello world), compile it using xmake, then I add fmt to xmake.lua and change main.cpp to use fmt, xmake again and get an error.

@waruqi
Copy link
Member

waruqi commented May 23, 2021

I have improved it. you can try it again.

@SirLynix
Copy link
Member Author

It looks right, I couldn't reproduce it, thanks!

@waruqi waruqi closed this as completed May 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants