upleveled / system-setup

Set up a PERN development environment on Windows, macOS and Linux
28 stars 19 forks source link

Upgrade to Visual Studio 2022 #52

Closed ProchaLu closed 5 months ago

ProchaLu commented 5 months ago

Closes #31

Upgrade the choco command to use visualstudio2022-workload-vctools instead of visualstudio2017-workload-vctools and removing the npm configuration line for setting msvs_version to 2017, as it is no longer necessary with the updated Visual Studio version.

karlhorky commented 5 months ago

@Eprince-hub reported today that for building libpg-query, the visualstudio2022-workload-vctools package didn't work but visualstudio2022-workload-webbuildtools seems to list out "Windows SDK"

Error log ("missing any Windows SDK"):

 Victor@Victor MINGW64 ~/upleveled/next-js-repo-example-2023 (main)
 $ pnpm add libpg-query@16.1.0
 Packages: +602
 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 Progress: resolved 611, reused 602, downloaded 0, added 0, done
 node_modules/.pnpm/libpg-query@16.1.0/node_modules/libpg-query: Running install script, failed in 5.6s
 .../node_modules/libpg-query install$ node-pre-gyp install --fallback-to-build
 │ node-pre-gyp info it worked if it ends with ok
 │ node-pre-gyp info using node-pre-gyp@1.0.11
 │ node-pre-gyp info using node@19.8.1 | win32 | x64
 │ node-pre-gyp info check checked for "C:\Users\Victor\upleveled\next-js-repo-example-2023\node_modules\.pnpm\libpg-query@16.1.0\node_modules\libpg-query\build\Release\queryparser.node" (not found)
 │ node-pre-gyp http GET https://supabase-public-artifacts-bucket.s3.amazonaws.com/libpg-query-node/queryparser-v16.1.0-node-v111-win32-x64.tar.gz
 │ node-pre-gyp ERR! install response status 404 Not Found on https://supabase-public-artifacts-bucket.s3.amazonaws.com/libpg-query-node/queryparser-v16.1.0-node-v111-win32-x64.tar.gz 
 │ node-pre-gyp WARN Pre-built binaries not installable for libpg-query@16.1.0 and node@19.8.1 (node-v111 ABI, unknown) (falling back to source compile with node-gyp) 
 │ node-pre-gyp WARN Hit error response status 404 Not Found on https://supabase-public-artifacts-bucket.s3.amazonaws.com/libpg-query-node/queryparser-v16.1.0-node-v111-win32-x64.tar.gz 
 │ gyp info it worked if it ends with ok
 │ gyp info using node-gyp@9.4.1
 │ gyp info using node@19.8.1 | win32 | x64
 │ gyp info ok 
 │ gyp info it worked if it ends with ok
 │ gyp info using node-gyp@9.4.1
 │ gyp info using node@19.8.1 | win32 | x64
 │ gyp info find Python using Python version 3.12.2 found at "C:\Python312\python.exe"
 │ gyp ERR! find VS 
 │ gyp ERR! find VS msvs_version was set from command line or npm config
 │ gyp ERR! find VS - looking for Visual Studio version 2022
 │ gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
 │ gyp ERR! find VS checking VS2022 (17.9.34723.18) found at:
 │ gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools"
 │ gyp ERR! find VS - found "Visual Studio C++ core features"
 │ gyp ERR! find VS - found VC++ toolset: v143
 │ gyp ERR! find VS - missing any Windows SDK
 │ gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
 │ gyp ERR! find VS not looking for VS2015 as it is only supported up to Node.js 18
 │ gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
 │ gyp ERR! find VS 
 │ gyp ERR! find VS valid versions for msvs_version:
 │ gyp ERR! find VS 
 │ gyp ERR! find VS **************************************************************
 │ gyp ERR! find VS You need to install the latest version of Visual Studio
 │ gyp ERR! find VS including the "Desktop development with C++" workload.
 │ gyp ERR! find VS For more information consult the documentation at:
 │ gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
 │ gyp ERR! find VS **************************************************************
 │ gyp ERR! find VS 
 │ gyp ERR! configure error 
 │ gyp ERR! stack Error: Could not find any Visual Studio installation to use
 │ gyp ERR! stack     at VisualStudioFinder.fail (C:\Users\Victor\AppData\Local\node\corepack\pnpm\8.15.5\dist\node_modules\node-gyp\lib\find-visualstudio.js:122:47)
 │ gyp ERR! stack     at C:\Users\Victor\AppData\Local\node\corepack\pnpm\8.15.5\dist\node_modules\node-gyp\lib\find-visualstudio.js:75:16
 │ gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (C:\Users\Victor\AppData\Local\node\corepack\pnpm\8.15.5\dist\node_modules\node-gyp\lib\find-visualstudio.js:380:14)
 │ gyp ERR! stack     at C:\Users\Victor\AppData\Local\node\corepack\pnpm\8.15.5\dist\node_modules\node-gyp\lib\find-visualstudio.js:71:14
 │ gyp ERR! stack     at VisualStudioFinder.findVisualStudio2015 (C:\Users\Victor\AppData\Local\node\corepack\pnpm\8.15.5\dist\node_modules\node-gyp\lib\find-visualstudio.js:364:14)
 │ gyp ERR! stack     at C:\Users\Victor\AppData\Local\node\corepack\pnpm\8.15.5\dist\node_modules\node-gyp\lib\find-visualstudio.js:67:12
 │ gyp ERR! stack     at VisualStudioFinder.parseData (C:\Users\Victor\AppData\Local\node\corepack\pnpm\8.15.5\dist\node_modules\node-gyp\lib\find-visualstudio.js:237:5)
 │ gyp ERR! stack     at C:\Users\Victor\AppData\Local\node\corepack\pnpm\8.15.5\dist\node_modules\node-gyp\lib\find-visualstudio.js:143:14
 │ gyp ERR! stack     at ChildProcess.exithandler (node:child_process:411:7)
 │ gyp ERR! stack     at ChildProcess.emit (node:events:512:28)
 │ gyp ERR! System Windows_NT 10.0.22631
 │ gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Victor\\AppData\\Local\\node\\corepack\\pnpm\\8.15.5\\dist\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--fallback-to-build" …  
 │ gyp ERR! cwd C:\Users\Victor\upleveled\next-js-repo-example-2023\node_modules\.pnpm\libpg-query@16.1.0\node_modules\libpg-query
 │ gyp ERR! node -v v19.8.1
 │ gyp ERR! node-gyp -v v9.4.1
 │ gyp ERR! not ok
 │ node-pre-gyp ERR! build error
 │ node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\Victor\AppData\Local\node\corepack\pnpm\8.15.5\dist\node_modules\node-gyp\bin\node-gyp.js configure --fallback-…  
 │ node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Users\Victor\upleveled\next-js-repo-example-2023\node_modules\.pnpm\@mapbox+node-pre-gyp@1.0.11\node_modules\@mapbox\node-pre-gyp\lib\util\comp…  
 │ Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\Victor\AppData\Local\node\corepack\pnpm\8.15.5\dist\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=C:\Users\Vict…  
 │ node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:512:28)
 │ node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1098:16)
 │ node-pre-gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:304:5)
 │ node-pre-gyp ERR! System Windows_NT 10.0.22631
 │ node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Victor\\upleveled\\next-js-repo-example-2023\\node_modules\\.pnpm\\@mapbox+node-pre-gyp@1.0.11\\node_modules\\@mapbox\\node-pre…  
 │ node-pre-gyp ERR! cwd C:\Users\Victor\upleveled\next-js-repo-example-2023\node_modules\.pnpm\libpg-query@16.1.0\node_modules\libpg-query
 │ node-pre-gyp ERR! node -v v19.8.1
 │ node-pre-gyp ERR! node-pre-gyp -v v1.0.11
 │ node-pre-gyp ERR! not ok
 └─ Failed in 5.6s at C:\Users\Victor\upleveled\next-js-repo-example-2023\node_modules\.pnpm\libpg-query@16.1.0\node_modules\libpg-query
  ELIFECYCLE  Command failed with exit code 1.
karlhorky commented 5 months ago

@ProchaLu once @Eprince-hub confirms that any new installation commands work, you can create a new PR with the new package

Edit: This new visualstudio2022-workload-webbuildtools didn't work, trying other things

karlhorky commented 5 months ago

Maybe the original visualstudio2022-workload-vctools is alright after all, but we just need to add the optional packages too:

choco install visualstudio2022-workload-vctools --package-parameters "--includeOptional"

Because of these optional components on the components list:

Screenshot 2024-03-29 at 16 32 18

Microsoft.VisualStudio.Component.Windows10SDK.18362
Microsoft.VisualStudio.Component.Windows10SDK.19041
Microsoft.VisualStudio.Component.Windows10SDK.20348
Microsoft.VisualStudio.Component.Windows11SDK.22000

Documented on the page above:

Package parameters can be used to adjust this behavior:

  • --includeOptional - Includes the optional components.

If this is required, then we should probably have a separate step with this (not combined with Python)

karlhorky commented 5 months ago

But interestingly, these other versions are already installed either as "Recommended" or "Required":

karlhorky commented 5 months ago

Seems to be corroborated by comment over here:

Eprince-hub commented 5 months ago

@ProchaLu CC @karlhorky

After having a fresh Windows 11 installed on my machine and following the UpLeveled System Setup Guide, everything works now, and I was able to install libpg-query on my Windows machine without issue. There is no need to use any other options or a new chocolatey package as initially signalled here https://github.com/upleveled/system-setup/pull/52#issuecomment-2027368413