-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Canonicalize fs::current_path before use. #13144
Conversation
This change fixes a bug report over Discord wherein a user using PowerShell 5.x called Set-Location, using a path which is incorrect. They entered "C:\tools\vcpkg" but the actual directory is "C:\Tools\vcpkg". Note Tools should be capitalized. PowerShell 5.x allows the current directory to be set this way even though it is "wrong". This causes subsequent parts that look for exact path names, like pkgconfig, to not correct get the right bits. Before: ``` PS C:\> set-location c:\dev\vcpkg PS C:\dev\vcpkg> .\bootstrap-vcpkg.bat Building vcpkg.exe ... [...] Building vcpkg.exe... done. [...] PS C:\dev\vcpkg> .\vcpkg.exe install curl Computing installation plan... The following packages will be built and installed: curl[core,non-http,ssl,sspi,winssl]:x86-windows * zlib[core]:x86-windows Additional packages (*) will be modified to complete this operation. Detecting compiler hash for triplet x86-windows... A suitable version of powershell-core was not found (required v6.2.1). Downloading portable powershell-core v6.2.1... https://github.com/PowerShell/PowerShell/releases/download/v6.2.1/PowerShell-6.2.1-win-x86.zip -> C:\dev\vcpkg\downloaExtracting powershell-core... A suitable version of 7zip was not found (required v18.1.0). Downloading portable 7zip v18.1.0... Downloading 7zip... https://www.nuget.org/api/v2/package/7-Zip.CommandLine/18.1.0 -> C:\dev\vcpkg\downloads\7-zip.commandline.18.1.0.nupkg Extracting 7zip... A suitable version of nuget was not found (required v5.5.1). Downloading portable nuget v5.5.1... Downloading nuget... https://dist.nuget.org/win-x86-commandline/v5.5.1/nuget.exe -> C:\dev\vcpkg\downloads\22ea847d-nuget.exe Starting package 1/2: zlib:x86-windows Building package zlib[core]:x86-windows... Could not locate cached archive: C:\Users\billy\AppData\Local\vcpkg/archives\94\94f460cfa764bc5cd3f76cf2807a516feb681074.zip -- Downloading http://www.zlib.net/zlib-1.2.11.tar.gz... -- Extracting source C:/dev/vcpkg/downloads/zlib1211.tar.gz -- Applying patch cmake_dont_build_more_than_needed.patch -- Applying patch 0001-Prevent-invalid-inclusions-when-HAVE_-is-set-to-0.patch -- Applying patch add_debug_postfix_on_mingw.patch -- Using source at C:/dev/vcpkg/buildtrees/zlib/src/1.2.11-63309e48e5.clean -- Configuring x86-windows -- Building x86-windows-dbg -- Building x86-windows-rel -- Downloading https://repo.msys2.org/mingw/i686/mingw-w64-i686-pkg-config-0.29.2-1-any.pkg.tar.xz... -- Downloading https://repo.msys2.org/mingw/i686/mingw-w64-i686-libwinpthread-git-8.0.0.5906.c9a21571-1-any.pkg.tar.zst... -- Fixing pkgconfig file: C:/dev/vcpkg/packages/zlib_x86-windows/lib/pkgconfig/zlib.pc -- Fixing pkgconfig file: C:/dev/vcpkg/packages/zlib_x86-windows/debug/lib/pkgconfig/zlib.pc -- CHECK_LIB_zlibd_DEBUG:CHECK_LIB_zlibd_DEBUG-NOTFOUND CMake Error at scripts/cmake/vcpkg_fixup_pkgconfig.cmake:232 (message): Library "zlibd" was not found! If it is a system library use the SYSTEM_LIBRARIES parameter for the vcpkg_fixup_pkgconfig call! Otherwise, correct the *.pc file Call Stack (most recent call first): scripts/cmake/vcpkg_fixup_pkgconfig.cmake:329 (vcpkg_fixup_pkgconfig_check_files) ports/zlib/portfile.cmake:48 (vcpkg_fixup_pkgconfig) scripts/ports.cmake:79 (include) Error: Building package zlib:x86-windows failed with: BUILD_FAILED Please ensure you're using the latest portfiles with `.\vcpkg update`, then submit an issue at https://github.com/Microsoft/vcpkg/issues including: Package: zlib:x86-windows Vcpkg version: 2020.06.15-nohash Additionally, attach any relevant sections from the log files above. PS C:\dev\vcpkg> ``` After (note difference in case between the PS> prompt and the tool output): ``` PS C:\dev\vcpkg> .\vcpkg.exe x-set-installed All requested packages are currently installed. Total elapsed time: 5.9 us PS C:\dev\vcpkg> .\vcpkg.exe install curl Computing installation plan... The following packages will be built and installed: curl[core,non-http,ssl,sspi,winssl]:x86-windows * zlib[core]:x86-windows Additional packages (*) will be modified to complete this operation. Detecting compiler hash for triplet x86-windows... Starting package 1/2: zlib:x86-windows Building package zlib[core]:x86-windows... Could not locate cached archive: C:\Users\billy\AppData\Local\vcpkg/archives\94\94f460cfa764bc5cd3f76cf2807a516feb681074.zip -- Using cached C:/Dev/vcpkg/downloads/zlib1211.tar.gz -- Cleaning sources at C:/Dev/vcpkg/buildtrees/zlib/src/1.2.11-63309e48e5.clean. Use --editable to skip cleaning for the packages you specify. -- Extracting source C:/Dev/vcpkg/downloads/zlib1211.tar.gz -- Applying patch cmake_dont_build_more_than_needed.patch -- Applying patch 0001-Prevent-invalid-inclusions-when-HAVE_-is-set-to-0.patch -- Applying patch add_debug_postfix_on_mingw.patch -- Using source at C:/Dev/vcpkg/buildtrees/zlib/src/1.2.11-63309e48e5.clean -- Configuring x86-windows -- Building x86-windows-dbg -- Building x86-windows-rel -- Fixing pkgconfig file: C:/Dev/vcpkg/packages/zlib_x86-windows/lib/pkgconfig/zlib.pc -- Fixing pkgconfig file: C:/Dev/vcpkg/packages/zlib_x86-windows/debug/lib/pkgconfig/zlib.pc -- Installing: C:/Dev/vcpkg/packages/zlib_x86-windows/share/zlib/copyright -- Performing post-build validation -- Performing post-build validation done Stored binary cache: C:\Users\billy\AppData\Local\vcpkg/archives\94\94f460cfa764bc5cd3f76cf2807a516feb681074.zip Building package zlib[core]:x86-windows... done Installing package zlib[core]:x86-windows... Installing package zlib[core]:x86-windows... done Elapsed time for package zlib:x86-windows: 3.693 s Starting package 2/2: curl:x86-windows Building package curl[core,non-http,ssl,sspi,winssl]:x86-windows... Could not locate cached archive: C:\Users\billy\AppData\Local\vcpkg/archives\a4\a49e1cd6bac769230fcfd89b7b912a1aa081fd3a.zip -- Downloading https://github.com/curl/curl/archive/5a1fc8d33808d7b22f57bdf9403cda7ff07b0670.tar.gz... -- Extracting source C:/Dev/vcpkg/downloads/curl-curl-5a1fc8d33808d7b22f57bdf9403cda7ff07b0670.tar.gz -- Applying patch 0002_fix_uwp.patch -- Applying patch 0004_nghttp2_staticlib.patch -- Applying patch 0005_remove_imp_suffix.patch -- Applying patch 0006_fix_tool_depends.patch -- Applying patch 0007_disable_tool_export_curl_target.patch -- Applying patch 0009_fix_openssl_config.patch -- Applying patch 0010_fix_othertests_cmake.patch -- Applying patch 0011_fix_static_build.patch -- Using source at C:/Dev/vcpkg/buildtrees/curl/src/7ff07b0670-aace9b898a.clean -- Configuring x86-windows -- Building x86-windows-dbg -- Building x86-windows-rel -- Installing: C:/Dev/vcpkg/packages/curl_x86-windows/share/curl/curl-config -- Installing: C:/Dev/vcpkg/packages/curl_x86-windows/share/curl/vcpkg-cmake-wrapper.cmake -- Installing: C:/Dev/vcpkg/packages/curl_x86-windows/share/curl/copyright -- Performing post-build validation -- Performing post-build validation done Stored binary cache: C:\Users\billy\AppData\Local\vcpkg/archives\a4\a49e1cd6bac769230fcfd89b7b912a1aa081fd3a.zip Building package curl[core,non-http,ssl,sspi,winssl]:x86-windows... done Installing package curl[core,non-http,ssl,sspi,winssl]:x86-windows... Installing package curl[core,non-http,ssl,sspi,winssl]:x86-windows... done Elapsed time for package curl:x86-windows: 47.49 s Total elapsed time: 52.72 s The package curl:x86-windows provides CMake targets: find_package(CURL CONFIG REQUIRED) target_link_libraries(main PRIVATE CURL::libcurl) PS C:\dev\vcpkg> ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we do this in RealFilesystem
instead? Also, this changes how junctions work wrt original_cwd
: is that what we want to do?
@strega-nil You mean you want all reads of current_path to get this treatment? I kinda want to leave functions in the filesystem interface which have identical names as std::filesystem having identical semantics but we could introduce canonical_current_path or similar.... |
I value the tool not breaking in the presence of paths of different case in current_path over preserving uncanonical symlinks or junctions. |
Related to issue #12709 I can't repro this issue any more, so I can't to test this PR. |
On the other hand after further discussion it seems that |
en... I reprod this issue today, and test this PR, it works. |
This is a better solution than that I tried in microsoft#13144 -- rather than trying to cannoicalize the path completely, which would destroy symlinks etc; this form calls FindFirstFile on each path element to get the real case from the filesystem. Fixes microsoft#13105. (Note the wrong case in the CWD in the prompt, but the correct case in all the output:) PS C:\DeV\vcPKG> .\vcpkg.exe install curl Computing installation plan... The following packages will be built and installed: curl[core,non-http,schannel,ssl,sspi,winssl]:x86-windows * zlib[core]:x86-windows Additional packages (*) will be modified to complete this operation. Detecting compiler hash for triplet x86-windows... Starting package 1/2: zlib:x86-windows Building package zlib[core]:x86-windows... Using cached binary package: C:\Users\billy\AppData\Local\vcpkg/archives\c6\c61dd1bcc23348934c55f4ced77f1e4b0f353394.zipBuilding package zlib[core]:x86-windows... done Installing package zlib[core]:x86-windows... Installing package zlib[core]:x86-windows... done Elapsed time for package zlib:x86-windows: 62.26 ms Starting package 2/2: curl:x86-windows Building package curl[core,non-http,schannel,ssl,sspi,winssl]:x86-windows... Could not locate cached archive: C:\Users\billy\AppData\Local\vcpkg/archives\9f\9fa16d473c9539e9ea7ab3922eff46618f3a4c4b.zip -- Downloading https://github.com/curl/curl/archive/9d954e49bce3706a9a2efb119ecd05767f0f2a9e.tar.gz... -- Extracting source C:/Dev/vcpkg/downloads/curl-curl-9d954e49bce3706a9a2efb119ecd05767f0f2a9e.tar.gz -- Applying patch 0002_fix_uwp.patch -- Applying patch 0004_nghttp2_staticlib.patch -- Applying patch 0005_remove_imp_suffix.patch -- Applying patch 0006_fix_tool_depends.patch -- Applying patch 0007_disable_tool_export_curl_target.patch -- Applying patch 0009_fix_openssl_config.patch -- Applying patch 0010_fix_othertests_cmake.patch -- Applying patch 0011_fix_static_build.patch -- Using source at C:/Dev/vcpkg/buildtrees/curl/src/767f0f2a9e-91d24adee1.clean -- Configuring x86-windows -- Building x86-windows-dbg -- Building x86-windows-rel -- Installing: C:/Dev/vcpkg/packages/curl_x86-windows/share/curl/curl-config -- Installing: C:/Dev/vcpkg/packages/curl_x86-windows/share/curl/vcpkg-cmake-wrapper.cmake -- Installing: C:/Dev/vcpkg/packages/curl_x86-windows/share/curl/copyright -- Performing post-build validation -- Performing post-build validation done Stored binary cache: C:\Users\billy\AppData\Local\vcpkg/archives\9f\9fa16d473c9539e9ea7ab3922eff46618f3a4c4b.zip Building package curl[core,non-http,schannel,ssl,sspi,winssl]:x86-windows... done Installing package curl[core,non-http,schannel,ssl,sspi,winssl]:x86-windows... Installing package curl[core,non-http,schannel,ssl,sspi,winssl]:x86-windows... done Elapsed time for package curl:x86-windows: 1.299 min Total elapsed time: 1.33 min The package curl:x86-windows provides CMake targets: find_package(CURL CONFIG REQUIRED) target_link_libraries(main PRIVATE CURL::libcurl) PS C:\DeV\vcPKG>
* Fix the case of current_path() before use on Windows. This is a better solution than that I tried in #13144 -- rather than trying to cannoicalize the path completely, which would destroy symlinks etc; this form calls FindFirstFile on each path element to get the real case from the filesystem. Fixes #13105. (Note the wrong case in the CWD in the prompt, but the correct case in all the output:) PS C:\DeV\vcPKG> .\vcpkg.exe install curl Computing installation plan... The following packages will be built and installed: curl[core,non-http,schannel,ssl,sspi,winssl]:x86-windows * zlib[core]:x86-windows Additional packages (*) will be modified to complete this operation. Detecting compiler hash for triplet x86-windows... Starting package 1/2: zlib:x86-windows Building package zlib[core]:x86-windows... Using cached binary package: C:\Users\billy\AppData\Local\vcpkg/archives\c6\c61dd1bcc23348934c55f4ced77f1e4b0f353394.zipBuilding package zlib[core]:x86-windows... done Installing package zlib[core]:x86-windows... Installing package zlib[core]:x86-windows... done Elapsed time for package zlib:x86-windows: 62.26 ms Starting package 2/2: curl:x86-windows Building package curl[core,non-http,schannel,ssl,sspi,winssl]:x86-windows... Could not locate cached archive: C:\Users\billy\AppData\Local\vcpkg/archives\9f\9fa16d473c9539e9ea7ab3922eff46618f3a4c4b.zip -- Downloading https://github.com/curl/curl/archive/9d954e49bce3706a9a2efb119ecd05767f0f2a9e.tar.gz... -- Extracting source C:/Dev/vcpkg/downloads/curl-curl-9d954e49bce3706a9a2efb119ecd05767f0f2a9e.tar.gz -- Applying patch 0002_fix_uwp.patch -- Applying patch 0004_nghttp2_staticlib.patch -- Applying patch 0005_remove_imp_suffix.patch -- Applying patch 0006_fix_tool_depends.patch -- Applying patch 0007_disable_tool_export_curl_target.patch -- Applying patch 0009_fix_openssl_config.patch -- Applying patch 0010_fix_othertests_cmake.patch -- Applying patch 0011_fix_static_build.patch -- Using source at C:/Dev/vcpkg/buildtrees/curl/src/767f0f2a9e-91d24adee1.clean -- Configuring x86-windows -- Building x86-windows-dbg -- Building x86-windows-rel -- Installing: C:/Dev/vcpkg/packages/curl_x86-windows/share/curl/curl-config -- Installing: C:/Dev/vcpkg/packages/curl_x86-windows/share/curl/vcpkg-cmake-wrapper.cmake -- Installing: C:/Dev/vcpkg/packages/curl_x86-windows/share/curl/copyright -- Performing post-build validation -- Performing post-build validation done Stored binary cache: C:\Users\billy\AppData\Local\vcpkg/archives\9f\9fa16d473c9539e9ea7ab3922eff46618f3a4c4b.zip Building package curl[core,non-http,schannel,ssl,sspi,winssl]:x86-windows... done Installing package curl[core,non-http,schannel,ssl,sspi,winssl]:x86-windows... Installing package curl[core,non-http,schannel,ssl,sspi,winssl]:x86-windows... done Elapsed time for package curl:x86-windows: 1.299 min Total elapsed time: 1.33 min The package curl:x86-windows provides CMake targets: find_package(CURL CONFIG REQUIRED) target_link_libraries(main PRIVATE CURL::libcurl) PS C:\DeV\vcPKG> * Fix *nix builds. * PR feedback. * Update toolsrc/src/vcpkg/base/files.cpp Co-authored-by: ras0219 <[email protected]>
* Fix the case of current_path() before use on Windows. This is a better solution than that I tried in microsoft/vcpkg#13144 -- rather than trying to cannoicalize the path completely, which would destroy symlinks etc; this form calls FindFirstFile on each path element to get the real case from the filesystem. Fixes #13105. (Note the wrong case in the CWD in the prompt, but the correct case in all the output:) PS C:\DeV\vcPKG> .\vcpkg.exe install curl Computing installation plan... The following packages will be built and installed: curl[core,non-http,schannel,ssl,sspi,winssl]:x86-windows * zlib[core]:x86-windows Additional packages (*) will be modified to complete this operation. Detecting compiler hash for triplet x86-windows... Starting package 1/2: zlib:x86-windows Building package zlib[core]:x86-windows... Using cached binary package: C:\Users\billy\AppData\Local\vcpkg/archives\c6\c61dd1bcc23348934c55f4ced77f1e4b0f353394.zipBuilding package zlib[core]:x86-windows... done Installing package zlib[core]:x86-windows... Installing package zlib[core]:x86-windows... done Elapsed time for package zlib:x86-windows: 62.26 ms Starting package 2/2: curl:x86-windows Building package curl[core,non-http,schannel,ssl,sspi,winssl]:x86-windows... Could not locate cached archive: C:\Users\billy\AppData\Local\vcpkg/archives\9f\9fa16d473c9539e9ea7ab3922eff46618f3a4c4b.zip -- Downloading https://github.com/curl/curl/archive/9d954e49bce3706a9a2efb119ecd05767f0f2a9e.tar.gz... -- Extracting source C:/Dev/vcpkg/downloads/curl-curl-9d954e49bce3706a9a2efb119ecd05767f0f2a9e.tar.gz -- Applying patch 0002_fix_uwp.patch -- Applying patch 0004_nghttp2_staticlib.patch -- Applying patch 0005_remove_imp_suffix.patch -- Applying patch 0006_fix_tool_depends.patch -- Applying patch 0007_disable_tool_export_curl_target.patch -- Applying patch 0009_fix_openssl_config.patch -- Applying patch 0010_fix_othertests_cmake.patch -- Applying patch 0011_fix_static_build.patch -- Using source at C:/Dev/vcpkg/buildtrees/curl/src/767f0f2a9e-91d24adee1.clean -- Configuring x86-windows -- Building x86-windows-dbg -- Building x86-windows-rel -- Installing: C:/Dev/vcpkg/packages/curl_x86-windows/share/curl/curl-config -- Installing: C:/Dev/vcpkg/packages/curl_x86-windows/share/curl/vcpkg-cmake-wrapper.cmake -- Installing: C:/Dev/vcpkg/packages/curl_x86-windows/share/curl/copyright -- Performing post-build validation -- Performing post-build validation done Stored binary cache: C:\Users\billy\AppData\Local\vcpkg/archives\9f\9fa16d473c9539e9ea7ab3922eff46618f3a4c4b.zip Building package curl[core,non-http,schannel,ssl,sspi,winssl]:x86-windows... done Installing package curl[core,non-http,schannel,ssl,sspi,winssl]:x86-windows... Installing package curl[core,non-http,schannel,ssl,sspi,winssl]:x86-windows... done Elapsed time for package curl:x86-windows: 1.299 min Total elapsed time: 1.33 min The package curl:x86-windows provides CMake targets: find_package(CURL CONFIG REQUIRED) target_link_libraries(main PRIVATE CURL::libcurl) PS C:\DeV\vcPKG> * Fix *nix builds. * PR feedback. * Update toolsrc/src/vcpkg/base/files.cpp Co-authored-by: ras0219 <[email protected]>
This change fixes a bug report over Discord wherein a user using PowerShell 5.x called Set-Location, using a path which is incorrect. They entered "C:\tools\vcpkg" but the actual directory is "C:\Tools\vcpkg". Note Tools should be capitalized. PowerShell 5.x allows the current directory to be set this way even though it is "wrong". This causes subsequent parts that look for exact path names, like pkgconfig, to not correct get the right bits.
Before:
After (note difference in case between the PS> prompt and the tool output):
Fixes #13105