microsoft / vcpkg

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

[opencv4] nvcc fatal : Could not set up the environment for Microsoft Visual Studio #39594

Open danielvandenberg95 opened 5 months ago

danielvandenberg95 commented 5 months ago

Operating system

Windows

Compiler

MSVC

Steps to reproduce the behavior

Have a username with spaces in it. This causes %TMP% and %TEMP% to contain spaces.
Using manifest 

{
  "name": "redacted",
  "version": "1.0.0.0",
  "dependencies": [
    "grpc",
    "magic-enum",
    {
      "name": "opencv4",
      "default-features": false,
      "features": [
        "jpeg",
        "cuda"
      ]
    }
  ],
  "builtin-baseline": "c247b81088dbe46c159be6157944d5db8bf76b4a",
  "vcpkg-configuration": {
    "registries": [
      {
        "$comment1": "See https://github.com/microsoft/vcpkg/issues/39454. Once https://github.com/microsoft/vcpkg/pull/39325 has been merged, update builtin-baseline and remove this registry.",
        "$comment2": "(or leave it here but empty out the packages array, then in the future we know how to add a different registry to the configuration if we need to...)",
        "kind": "git",
        "baseline": "89e222a90fc2847600be430a85783b8943f31f6c",
        "repository": "https://github.com/BillyONeal/vcpkg",
        "reference": "patch-tuesday-june-2024",
        "packages": [
          "opencv4"
        ]
      }
    ]
  },
  "$comment": "builtin-baseline describes the hash of the commit of microsoft/vcpkg from which version info is taken. To update grpc, update builtin-baseline to the hash of the commit of microsoft/vcpkg from which grpc should be built."
}

Run a buid from visual studio using VCPKG integration. (I'm assuming this step is not needed, I'm quite certain it'll fail however this is attempted.)

Failure logs

nvcc fatal   : Could not set up the environment for Microsoft Visual Studio using 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.20.27508/bin/HostX64/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat'
    ninja: build stopped: subcommand failed.

Additional context

See also https://stackoverflow.com/questions/55663890/how-to-solve-nvcc-fatal-could-not-set-up-the-environment-for-microsoft-visua While this issue probably lies in either vcvars64.bat or in nvcc, it might be possible to provide a workaround. Simply setting the %tmp% and %temp% paths to something else before build would suffice. Otherwise, at least throwing an warning when the temp folder contains spaces could save future users the 16 hours it took me to figure out this was the issue.

JonLiu1993 commented 5 months ago

Looks like an upstream issue, solution: make sure there aren't any quotes in the PATH, INCLUDE, LIB, and LIBPATH environment variables https://github.com/opencv/opencv/issues/17440