actualbudget / actual-server

Actual's server
https://actualbudget.org
MIT License
3.08k stars 585 forks source link

[Bug]: yarn install fails to build better-sqlite3 #382

Closed SirDave141 closed 1 month ago

SirDave141 commented 2 months ago

Verified issue does not already exist?

What happened?

After fetching and pulling the newest master branch, I went ahead and did the yarn install command. However, it reported a compilation problem — it was unable to compile the better-sqlite3. This has prompted me to examine the build.log file, where I have discovered that it is seeking Visual Studio's C++ Core Features.

Steps to reproduce?

  1. git pull the latest commit — in my case: 167522d
  2. Run yarn install in the folder.

Afterward, I have tried the yarn start command (I have a .bat file that does this for me) and it disallows me from using the server at all, as it cannot reach the database.

And so, after updating my Visual Studio, and installing the “Desktop development with C++”, the yarn install compiled without any difficulties!

Is there a solution to this issue without the need for C++ build tools?

What error did you receive?

The yarn install command:

➤ YN0000: · Yarn 4.0.1
➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed
➤ YN0000: ┌ Post-resolution validation
➤ YN0002: │ actual-sync@workspace:. doesn't provide @babel/core (p72996), requested by @babel/preset-typescript.
➤ YN0086: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code.
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed in 0s 694ms
➤ YN0000: ┌ Link step
➤ YN0007: │ better-sqlite3@npm:9.6.0 must be built because it never has been before or the last one failed
➤ YN0009: │ better-sqlite3@npm:9.6.0 couldn't be built successfully (exit code 1, logs can be found here: C:\Users\user\AppData\Local\Temp\xfs-e39b9bd5\build.log)
➤ YN0000: └ Completed in 4s 85ms
➤ YN0000: · Failed with errors in 5s 47ms

The build.log file before updating and installing Visual Studio's C++ build tools:

# This file contains the result of Yarn building a package (better-sqlite3@npm:9.6.0)
# Script name: install

prebuild-install warn install No prebuilt binaries found (target=22.3.0 runtime=node arch=x64 libc= platform=win32)
gyp info it worked if it ends with ok
gyp info using node-gyp@10.1.0
gyp info using node@22.3.0 | win32 | x64
gyp info find Python using Python version 3.12.4 found at "C:\Users\user\AppData\Local\Programs\Python\Python312\python.exe"

gyp ERR! find VS 
gyp ERR! find VS msvs_version not set from command line or npm config
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details.
gyp ERR! find VS 
gyp ERR! find VS Failure details: undefined
gyp ERR! find VS checking VS2022 (17.9.34902.65) found at:
gyp ERR! find VS "C:\Program Files\Microsoft Visual Studio\2022\Community"
gyp ERR! find VS - found "Visual Studio C++ core features"
gyp ERR! find VS - missing any VC++ toolset
gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
gyp ERR! find VS not looking for VS2017 as it is only supported up to Node.js 21
gyp ERR! find VS not looking for VS2017 as it is only supported up to Node.js 21
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 **************************************************************
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 (F:\Actual\node_modules\node-gyp\lib\find-visualstudio.js:116:11)
gyp ERR! stack at VisualStudioFinder.findVisualStudio (F:\Actual\node_modules\node-gyp\lib\find-visualstudio.js:72:17)
gyp ERR! stack at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
gyp ERR! stack at async createBuildDir (F:\Actual\node_modules\node-gyp\lib\configure.js:95:26)
gyp ERR! stack at async run (F:\Actual\node_modules\node-gyp\bin\node-gyp.js:81:18)
gyp ERR! System Windows_NT 10.0.19045
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "F:\\Actual\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--release"
gyp ERR! cwd F:\Actual\node_modules\better-sqlite3
gyp ERR! node -v v22.3.0
gyp ERR! node-gyp -v v10.1.0
gyp ERR! not ok

The yarn start command:

ERROR Error: Could not locate the bindings file. Tried:
 → F:\Actual\node_modules\better-sqlite3\build\better_sqlite3.node
 → F:\Actual\node_modules\better-sqlite3\build\Debug\better_sqlite3.node
 → F:\Actual\node_modules\better-sqlite3\build\Release\better_sqlite3.node
 → F:\Actual\node_modules\better-sqlite3\out\Debug\better_sqlite3.node
 → F:\Actual\node_modules\better-sqlite3\Debug\better_sqlite3.node
 → F:\Actual\node_modules\better-sqlite3\out\Release\better_sqlite3.node
 → F:\Actual\node_modules\better-sqlite3\Release\better_sqlite3.node
 → F:\Actual\node_modules\better-sqlite3\build\default\better_sqlite3.node
 → F:\Actual\node_modules\better-sqlite3\compiled\22.3.0\win32\x64\better_sqlite3.node
 → F:\Actual\node_modules\better-sqlite3\addon-build\release\install-root\better_sqlite3.node
 → F:\Actual\node_modules\better-sqlite3\addon-build\debug\install-root\better_sqlite3.node
 → F:\Actual\node_modules\better-sqlite3\addon-build\default\install-root\better_sqlite3.node
 → F:\Actual\node_modules\better-sqlite3\lib\binding\node-v127-win32-x64\better_sqlite3.node
    at bindings (F:\Actual\node_modules\bindings\bindings.js:126:9)
    at new Database (F:\Actual\node_modules\better-sqlite3\lib\database.js:48:64)
    at openDatabase (file:///F:/Actual/src/db.js:57:30)
    at getAccountDb (file:///F:/Actual/src/account-db.js:12:18)
    at needsBootstrap (file:///F:/Actual/src/account-db.js:23:19)
    at file:///F:/Actual/src/app-account.js:26:28
    at Layer.handle [as handle_request] (F:\Actual\node_modules\express\lib\router\layer.js:95:5)
    at next (F:\Actual\node_modules\express\lib\router\route.js:149:13)
    at Route.dispatch (F:\Actual\node_modules\express\lib\router\route.js:119:3)
    at Layer.handle [as handle_request] (F:\Actual\node_modules\express\lib\router\layer.js:95:5) {
  tries: [
    'F:\\Actual\\node_modules\\better-sqlite3\\build\\better_sqlite3.node',
    'F:\\Actual\\node_modules\\better-sqlite3\\build\\Debug\\better_sqlite3.node',
    'F:\\Actual\\node_modules\\better-sqlite3\\build\\Release\\better_sqlite3.node',
    'F:\\Actual\\node_modules\\better-sqlite3\\out\\Debug\\better_sqlite3.node',
    'F:\\Actual\\node_modules\\better-sqlite3\\Debug\\better_sqlite3.node',
    'F:\\Actual\\node_modules\\better-sqlite3\\out\\Release\\better_sqlite3.node',
    'F:\\Actual\\node_modules\\better-sqlite3\\Release\\better_sqlite3.node',
    'F:\\Actual\\node_modules\\better-sqlite3\\build\\default\\better_sqlite3.node',
    'F:\\Actual\\node_modules\\better-sqlite3\\compiled\\22.3.0\\win32\\x64\\better_sqlite3.node',
    'F:\\Actual\\node_modules\\better-sqlite3\\addon-build\\release\\install-root\\better_sqlite3.node',
    'F:\\Actual\\node_modules\\better-sqlite3\\addon-build\\debug\\install-root\\better_sqlite3.node',
    'F:\\Actual\\node_modules\\better-sqlite3\\addon-build\\default\\install-root\\better_sqlite3.node',
    'F:\\Actual\\node_modules\\better-sqlite3\\lib\\binding\\node-v127-win32-x64\\better_sqlite3.node'
  ]
}

Where are you hosting Actual?

Locally via Yarn

What browsers are you seeing the problem on?

Other

Operating System

Windows 10

shall0pass commented 2 months ago

better-sqlite3 is picky about node versions. Try node 20.