Skip to content

Bug: VS Build Tools detection loops forever on Windows — glob() returns empty arrays for paths with spaces #8

Description

@fghfhtrhf-tech

Bug description

On Windows, the VS Build Tools installation step loops forever (keeps reinstalling in a cycle).

Root cause

In kernel/bin/vs.js, the getpaths() method uses glob() to find VS installation paths inside C:\Program Files (x86)\Microsoft Visual Studio. However, glob returns empty arrays on Windows when the cwd contains spaces (like Program Files (x86)), even though the folders exist.

From Pinokio logs:

exists C:\Program Files (x86)\Microsoft Visual Studio { vcpaths: [] } { buildpaths: [] } { cmakepaths: [] }

So installed() always returns false → installer runs again → infinite loop.

Fix

Replace glob() with direct fs.existsSync() checks:

async getpaths() {
  let MSVC_PATH = []
  let BUILD_PATH = []
  let CMAKE_PATH = []
  let CL_PATH = []
  const program_file_paths = [process.env["ProgramFiles(x86)"], process.env["ProgramFiles"]]
  const years = ["2019", "2022", "2017"]
  const editions = ["BuildTools", "Community", "Professional", "Enterprise"]
  for(let rp of program_file_paths) {
    if (!rp) continue
    for(let year of years) {
      for(let edition of editions) {
        const base = path.join(rp, "Microsoft Visual Studio", year, edition)
        if (!fs.existsSync(base)) continue
        const msvc = path.join(base, "VC", "Tools", "MSVC")
        if (fs.existsSync(msvc)) MSVC_PATH.push(msvc)
        const build = path.join(base, "VC", "Auxiliary", "Build")
        if (fs.existsSync(build)) BUILD_PATH.push(build)
        const cmake = path.join(base, "Common7", "IDE", "CommonExtensions", "Microsoft", "CMake", "CMake", "bin")
        if (fs.existsSync(cmake)) CMAKE_PATH.push(cmake)
        const clbase = path.join(base, "VC", "Tools", "MSVC")
        if (fs.existsSync(clbase)) {
          const versions = fs.readdirSync(clbase)
          for(let v of versions) {
            const cl = path.join(clbase, v, "bin", "Hostx64", "x64")
            if (fs.existsSync(cl)) CL_PATH.push(cl)
          }
        }
      }
    }
  }
  return { MSVC_PATH, BUILD_PATH, CMAKE_PATH, CL_PATH }
}


This fix was tested and confirmed working on Windows 10

Environment
Windows 10
Pinokio 6.0.10
VS Build Tools 2019 installed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions