Open Cazadorro opened 3 years ago
I'm not sure there are practical things vcpkg can do to work around this as long as we rely on any powershell at all :(
@BillyONeal A few notes:
Doesn't VCPKG rely on the existence of cmake? Couldn't it just use CMake scripts to do half the stuff it needs to?
Not in applocal.ps1
-- that needs to be small / cheap to copy next to the platform msbuild scripts in %APPDATA%
.
Conan gets around this by simply using python for its scripting on eveyr platform IIRC, but VCPKG can't be using powershell on linux can it? So what stops whatever solution is available there from working on windows?
Linux does not have the equivalent of the applocal.ps1
feature in the first place. It's less necessary there because we restrict things in general to static linking so there would be no dynamic libraries to applocal.
Would it not be possible for VCPKG to not to just allow user to specify a custom directory for whatever this PowerShell stuff is using it for
It needs to be next to the msbuild props and targets so that they can find applocal.ps1.
I think truly resolving this (and a host of other problems we've had with powershell) means we need to rewrite what applocal.ps1 does in vcpkg.exe.
I think truly resolving this (and a host of other problems we've had with powershell) means we need to rewrite what applocal.ps1 does in vcpkg.exe.
Can't it be written in CMake? I am using CMake's BundleUtilities
for years, with shared libs on Windows, macOS, Linux, for Qt and GDAL and the libs and plugins behind. Since CMake 3.16, there is even file(GET_RUNTIME_DEPENDENCIES ....)
I think truly resolving this (and a host of other problems we've had with powershell) means we need to rewrite what applocal.ps1 does in vcpkg.exe.
Can't it be written in CMake? I am using CMake's
BundleUtilities
for years, with shared libs on Windows, macOS, Linux, for Qt and GDAL and the libs and plugins behind. Since CMake 3.16, there is evenfile(GET_RUNTIME_DEPENDENCIES ....)
No, we can't assume CMake is present (unless we could copy it next to the appdata msbuild props and targets). And that would still be a complete rewrite. If we're going rewrite we may as well do so in a way won't ever bring this problem back again.
If an enterprise restricts use of PowerShell to only constrained language mode, then, by design, you can't let untrusted scripts run with full language mode. A signed and trusted (signer is trusted) PowerShell script will always run in full language mode, but that may not be practical to sign every script in your enterprise unless your enterprise has invested in enabling that. We can't have some tools break out of this sandbox as those scripts may be malicious.
Another user reporting similar issues: https://www.reddit.com/r/cpp/comments/six9bk/comment/hvc8wm7/?utm_source=share&utm_medium=web2x&context=3
I have a similar/the same issue. I am trying to build openssl. I am using MSVC 2019 (updated this morning, 2022-05-25). The release build works, but the x64-windows-dbg fails. When looking at the error, it says:
Cannot dot-source this command because it was defined in a different language mode.
To invoke this command without importing its contents, omit the '.' operator.
That message appears in the file:
C:\local\vcpkg\buildtrees\openssl\copy-tool-dependencies-0-err.log
It is the only thing in the file (minus some terminal color coding I think and the name of the file it comes from: applocal.ps1.
I work in a hospital and the IT department seems to prevent any sourcing of files and always set PowerShell to restricted mode (I have not tested nor am I knowledgeable enough in PowerShell to know if it is only TEMP, TMP or the whole computer).
This prevents me from using vcpkg... :-(
Just as a follow up, I actually created a second project (still trying to use vcpkg as it would probably simplify dependency management...) and this second project does not have openssl as a dependency. This project lists only catch2 and CTRE as its dependencies. In that project, the configure/generate cycle of CMake gets passed the installation of the vcpkg projects (I use manifest mode).
That said, when I go on to simply build a main.cpp
which is the basic C++ hello world, project configuration and generation in CMake fails, and again, it's while trying to source applocal.ps1.
So basically, because the hospital where I work puts PowerShell in restricted mode (or something like that), I cannot use vcpkg at all it would seem.
Not sure you can/will do anything about that, but thought I would add a datapoint to the conversation.
This commit https://github.com/microsoft/vcpkg/pull/26585 had been closed. Is there any solution to fix this problem?
Describe the bug A clear and concise description of what the bug is.
Related (but this problem is way more pervasive than this issue) https://github.com/microsoft/vcpkg/issues/5229 though I don't appear to have this issue, the bat file works fine for me.
Vcpkg has run into this issue https://devblogs.microsoft.com/powershell/powershell-constrained-language-mode-and-the-dot-source-operator/
I don't understand powershell and will never touch it, but from what I understand powershell works in a restricted syntactic mode when ConstrainedLanguage is on, which I guess is configured by default for non-privledged accounts in some companies, and when TEMP or TMP is used ie, AppData/Local/Temp (appdata, the output directory does not allow for unconstrained usage of powershell.
So I don't have a way to waive this ConstrainedLanguage mode with out going to admin mode or changing TEMP and TMP user environmental variables, and as you'll see, this straight up breaks everything with vcpkg.
Environment
To Reproduce Steps to reproduce the behavior:
Example:
-- Configuring incomplete, errors occurred! See also "[projectpath]/myproject/cmake-build-debug/CMakeFiles/CMakeOutput.log". See also "[projectpath]/myproject/cmake-build-debug/CMakeFiles/CMakeError.log".
CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:105 (message): Command failed: [vcpkgdir]vcpkg/downloads/tools/powershell-core-7.1.3-windows/pwsh.exe -noprofile -executionpolicy Bypass -nologo -file [vcpkgdir]vcpkg/scripts/buildsystems/msbuild/applocal.ps1 -targetBinary [vcpkgdir]vcpkg/packages/libiconv_x64-windows/tools/libiconv/bin/iconv.exe -installedDir [vcpkgdir]vcpkg/packages/libiconv_x64-windows/bin Working Directory: [vcpkgdir]vcpkg Error code: 1 See logs for more information: [vcpkgdir]\vcpkg\buildtrees\libiconv\copy-tool-dependencies-err.log
Call Stack (most recent call first): scripts/cmake/vcpkg_copy_tool_dependencies.cmake:34 (vcpkg_execute_required_process) scripts/cmake/vcpkg_copy_tool_dependencies.cmake:44 (search_for_dependencies) ports/libiconv/portfile.cmake:40 (vcpkg_copy_tool_dependencies) scripts/ports.cmake:142 (include)
Error: Building package libiconv:x64-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: libiconv:x64-windows Vcpkg version: 2021-05-05-9f849c4c43e50d1b16186ae76681c27b0c1be9d9Additionally, attach any relevant sections from the log files above.