microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
22.18k stars 6.16k forks source link

[ffmpeg] Unclear error when building in path with spaces in manifest mode #39394

Open k0zmo opened 2 weeks ago

k0zmo commented 2 weeks ago

Is your feature request related to a problem? Please describe.

The ffmpeg port currently verifies that the build tree path does not contain spaces. However, in manifest mode, it fails to check if the CURRENT_HOST_INSTALLED_DIR contains spaces. When the project is located in a path with spaces, the build fails with an unclear error message, making it difficult for users to diagnose the issue.

Proposed solution

To provide a clearer error message and prevent build failures, extend the existing path validation in portfile.cmake to also check the CURRENT_HOST_INSTALLED_DIR. This can be done by modifying the portfile.cmake as follows:

if(SOURCE_PATH MATCHES " " OR CURRENT_HOST_INSTALLED_DIR MATCHES " ")
    message(FATAL_ERROR "Error: ffmpeg will not build with spaces in the path. Please use a directory with no spaces")
endif()

Describe alternatives you've considered

No response

Additional context

-- Running vcpkg install
Detecting compiler hash for triplet x64-windows...
Compiler found: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe
The following packages will be built and installed:
    ffmpeg[avcodec,avdevice,avfilter,avformat,core,swresample,swscale]:x64-windows@6.1.1#8
Restored 0 package(s) from C:\Users\k0zmo\AppData\Local\vcpkg\archives in 87.3 us. Use --debug to see more details.
Installing 1/1 ffmpeg[avcodec,avdevice,avfilter,avformat,core,swresample,swscale]:x64-windows@6.1.1#8...
Building ffmpeg[avcodec,avdevice,avfilter,avformat,core,swresample,swscale]:x64-windows@6.1.1#8...
-- Using cached ffmpeg-ffmpeg-n6.1.1.tar.gz.
-- Cleaning sources at D:/Dev/vcpkg/buildtrees/ffmpeg/src/n6.1.1-2b415d2741.clean. Use --editable to skip cleaning for the packages you specify.
-- Extracting source D:/Dev/vcpkg/downloads/ffmpeg-ffmpeg-n6.1.1.tar.gz
-- Applying patch 0001-create-lib-libraries.patch
-- Applying patch 0002-fix-msvc-link.patch
-- Applying patch 0003-fix-windowsinclude.patch
-- Applying patch 0004-dependencies.patch
-- Applying patch 0005-fix-nasm.patch
-- Applying patch 0007-fix-lib-naming.patch
-- Applying patch 0012-Fix-ssl-110-detection.patch
-- Applying patch 0013-define-WINVER.patch
-- Applying patch 0020-fix-aarch64-libswscale.patch
-- Applying patch 0040-ffmpeg-add-av_stream_get_first_dts-for-chromium.patch
-- Applying patch 0041-add-const-for-opengl-definition.patch
-- Applying patch 0042-fix-arm64-linux.patch
-- Using source at D:/Dev/vcpkg/buildtrees/ffmpeg/src/n6.1.1-2b415d2741.clean
-- Using cached msys2-automake1.16-1.16.5-1-any.pkg.tar.zst.
-- Using cached msys2-bash-5.2.026-1-x86_64.pkg.tar.zst.
-- Using cached msys2-coreutils-8.32-5-x86_64.pkg.tar.zst.
-- Using cached msys2-file-5.45-1-x86_64.pkg.tar.zst.
-- Using cached msys2-gawk-5.3.0-1-x86_64.pkg.tar.zst.
-- Using cached msys2-grep-1~3.0-6-x86_64.pkg.tar.zst.
-- Using cached msys2-gzip-1.13-1-x86_64.pkg.tar.zst.
-- Using cached msys2-diffutils-3.10-1-x86_64.pkg.tar.zst.
-- Using cached msys2-make-4.4.1-2-x86_64.pkg.tar.zst.
-- Using cached msys2-pkgconf-2.1.1-1-x86_64.pkg.tar.zst.
-- Using cached msys2-sed-4.9-1-x86_64.pkg.tar.zst.
-- Using cached msys2-msys2-runtime-3.5.3-3-x86_64.pkg.tar.zst.
-- Using cached msys2-perl-5.38.2-2-x86_64.pkg.tar.zst.
-- Using cached msys2-libiconv-1.17-1-x86_64.pkg.tar.zst.
-- Using cached msys2-libintl-0.22.4-1-x86_64.pkg.tar.zst.
-- Using cached msys2-gmp-6.3.0-1-x86_64.pkg.tar.zst.
-- Using cached msys2-gcc-libs-13.3.0-1-x86_64.pkg.tar.zst.
-- Using cached msys2-libbz2-1.0.8-4-x86_64.pkg.tar.zst.
-- Using cached msys2-liblzma-5.6.2-1-x86_64.pkg.tar.zst.
-- Using cached msys2-libzstd-1.5.6-1-x86_64.pkg.tar.zst.
-- Using cached msys2-zlib-1.3.1-1-x86_64.pkg.tar.zst.
-- Using cached msys2-libreadline-8.2.010-1-x86_64.pkg.tar.zst.
-- Using cached msys2-mpfr-4.2.1-1-x86_64.pkg.tar.zst.
-- Using cached msys2-libpcre-8.45-4-x86_64.pkg.tar.zst.
-- Using cached msys2-libxcrypt-4.4.36-1-x86_64.pkg.tar.zst.
-- Using cached msys2-ncurses-6.5-1-x86_64.pkg.tar.zst.
-- Using msys root at D:/Dev/vcpkg/downloads/tools/msys2/0f89fce739d5829e
-- Getting CMake variables for x64-windows
-- Using cached msys2-mingw-w64-x86_64-pkgconf-1~2.2.0-1-any.pkg.tar.zst.
-- Using cached msys2-msys2-runtime-3.5.3-3-x86_64.pkg.tar.zst.
-- Using msys root at D:/Dev/vcpkg/downloads/tools/msys2/1e74ca60daa10104
-- Building Options: --toolchain=msvc --enable-pic --disable-doc --enable-debug --enable-runtime-cpudetect --disable-autodetect --pkg-config=F:/123 123/build/vcpkg_installed/x64-windows/tools/pkgconf/pkgconf.exe --target-os=win32 --enable-w32threads --enable-d3d11va --enable-dxva2 --enable-mediafoundation --disable-inline-asm --cc=cl.exe --cxx=cl.exe --windres=rc.exe --ld=link.exe --ar='ar-lib lib.exe' --ranlib=: --disable-ffmpeg --disable-ffplay --disable-ffprobe --enable-avcodec --enable-avdevice --enable-avformat --enable-avfilter --disable-postproc --enable-swresample --enable-swscale --disable-alsa --disable-amf --disable-libaom --disable-libass --disable-avisynth --disable-bzlib --disable-libdav1d --disable-libfdk-aac --disable-libfontconfig --disable-libfreetype --disable-libfribidi --disable-iconv --disable-libilbc --disable-lzma --disable-libmp3lame --disable-libmodplug --disable-cuda --disable-nvenc --disable-nvdec  --disable-cuvid --disable-ffnvcodec --disable-opencl --disable-opengl --disable-libopenh264 --disable-libopenjpeg --disable-libopenmpt --disable-openssl --enable-schannel --disable-libopus --disable-sdl2 --disable-libsnappy --disable-libsoxr --disable-libspeex --disable-libssh --disable-libtensorflow --disable-libtesseract --disable-libtheora --disable-libvorbis --disable-libvpx --disable-libwebp --disable-libx264 --disable-libx265 --disable-libxml2 --disable-zlib --disable-libsrt --disable-libmfx --enable-cross-compile --disable-static --enable-shared --extra-cflags=-DHAVE_UNISTD_H=0 --pkg-config=D:/Dev/vcpkg/downloads/tools/msys2/1e74ca60daa10104/mingw64/bin/pkg-config.exe
-- Building Release Options: --enable-optimizations --extra-ldflags=-libpath:"F:/123 123/build/vcpkg_installed/x64-windows/lib"
-- Building ffmpeg for Release
CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:112 (message):
    Command failed: D:/Dev/vcpkg/downloads/tools/msys2/0f89fce739d5829e/usr/bin/bash.exe ./build.sh
    Working Directory: D:/Dev/vcpkg/buildtrees/ffmpeg/x64-windows-rel
    Error code: 1
    See logs for more information:
      D:\Dev\vcpkg\buildtrees\ffmpeg\build-x64-windows-rel-out.log

Call Stack (most recent call first):
  ports/ffmpeg/portfile.cmake:659 (vcpkg_execute_required_process)
  scripts/ports.cmake:191 (include)

error: building ffmpeg:x64-windows failed with: BUILD_FAILED
Elapsed time to handle ffmpeg:x64-windows: 8.6 s
Please ensure you're using the latest port files with `git pull` and `vcpkg update`.
Then check for known issues at:
  https://github.com/microsoft/vcpkg/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+ffmpeg
You can submit a new issue at:
  https://github.com/microsoft/vcpkg/issues/new?title=[ffmpeg]+Build+error+on+x64-windows&body=Copy+issue+body+from+F%3A%2F123%20123%2Fbuild%2Fvcpkg_installed%2Fvcpkg%2Fissue_body.md

-- Running vcpkg install - failed
CMake Error at D:/Dev/vcpkg/scripts/buildsystems/vcpkg.cmake:899 (message):
  vcpkg install failed.  See logs for more information: F:\123
  123\build\vcpkg-manifest-install.log
Call Stack (most recent call first):
  D:/Dev/cmake/share/cmake-3.29/Modules/CMakeDetermineSystem.cmake:146 (include)
  CMakeLists.txt:2 (project)

-- Configuring incomplete, errors occurred!
cenit commented 2 weeks ago

what about binary caching? if I do the artifacts on a proper pc and reuse in one with spaces in path, your proposed solution does not intercept the problem

k0zmo commented 2 weeks ago

There's no problem with consuming the port, only with building it. You can use classic mode: vcpkg install ffmpeg and consume the port from the path with spaces just fine. The problem is only triggered when you need to build ffmpeg.