Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Still tries to build OpenCV even when already installed by chocolately on Windows #149

Open
liftyourgame opened this issue Jul 3, 2024 · 13 comments

Comments

@liftyourgame
Copy link

liftyourgame commented Jul 3, 2024

Have installed OpenCV on Windows by Chocolately in PowerShell:

choco install OpenCV -y -version 4.1.0

Set environment variable system wide:
OPENCV4NODEJS_DISABLE_AUTOBUILD=1

Install @u4/opencv4nodejs

npm install @u4/opencv4nodejs

Get this in the logs: and can't see node-gyp rebuild is running

`PS C:\Development\cctv> npm i
npm warn deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated [email protected]: This package is no longer supported.
npm warn deprecated @humanwhocodes/[email protected]: Use @eslint/config-array instead
npm warn deprecated [email protected]: Rimraf versions prior to v4 are no longer supported
npm warn deprecated [email protected]: Rimraf versions prior to v4 are no longer supported
npm warn deprecated [email protected]: Glob versions prior to v9 are no longer supported
npm warn deprecated [email protected]: Glob versions prior to v9 are no longer supported
npm warn deprecated [email protected]: This package is no longer supported.
npm warn deprecated @humanwhocodes/[email protected]: Use @eslint/object-schema instead
npm warn deprecated [email protected]: This package is no longer supported.
npm warn cleanup Failed to remove some directories [
npm warn cleanup [
npm warn cleanup 'C:\Development\cctv\node_modules',
npm warn cleanup [Error: EPERM: operation not permitted, rmdir 'C:\Development\cctv\node_modules@isaacs\cliui\build'] {
npm warn cleanup errno: -4048,
npm warn cleanup code: 'EPERM',
npm warn cleanup syscall: 'rmdir',
npm warn cleanup path: 'C:\Development\cctv\node_modules\@isaacs\cliui\build'
npm warn cleanup }
npm warn cleanup ],
npm warn cleanup [
npm warn cleanup 'C:\Development\cctv\node_modules\@u4',
npm warn cleanup [Error: EPERM: operation not permitted, rmdir 'C:\Development\cctv\node_modules@u4\opencv4nodejs\node_modules\eslint'] {
npm warn cleanup errno: -4048,
npm warn cleanup code: 'EPERM',
npm warn cleanup syscall: 'rmdir',
npm warn cleanup path: 'C:\Development\cctv\node_modules\@u4\opencv4nodejs\node_modules\eslint'
npm warn cleanup }
npm warn cleanup ]
npm warn cleanup ]
npm error code 1
npm error path C:\Development\cctv\node_modules@u4\opencv4nodejs
npm error command failed
npm error command C:\WINDOWS\system32\cmd.exe /d /s /c node-gyp rebuild
npm error opencv4nodejs.cc
npm error CustomMatAllocator.cc
npm error ExternalMemTracking.cc
npm error core.cc
npm error coreConstants.cc
npm error HistAxes.cc
npm error Mat.cc
npm error Point.cc
npm error Vec.cc
npm error Size.cc
npm error Rect.cc
npm error RotatedRect.cc
npm error TermCriteria.cc
npm error imgproc.cc
npm error imgprocConstants.cc
npm error MatImgproc.cc
npm error Contour.cc
npm error Moments.cc
npm error calib3d.cc
npm error calib3dConstants.cc
npm error MatCalib3d.cc
npm error io.cc
npm error ioConstants.cc
npm error VideoCapture.cc
npm error VideoWriter.cc
npm error photo.cc
npm error photoConstants.cc
npm error MatPhoto.cc
npm error video.cc
npm error BackgroundSubtractor.cc
npm error BackgroundSubtractorMOG2.cc
npm error BackgroundSubtractorKNN.cc
npm error ximgproc.cc
npm error MatXimgproc.cc
npm error SuperpixelSEEDS.cc
npm error SuperpixelSLIC.cc
npm error SuperpixelLSC.cc
npm error objdetect.cc
npm error CascadeClassifier.cc
npm error HOGDescriptor.cc
npm error DetectionROI.cc
npm error machinelearning.cc
npm error machinelearningConstants.cc
npm error ParamGrid.cc
npm error StatModel.cc
npm error SVM.cc
npm error TrainData.cc
npm error dnn.cc
npm error Net.cc
npm error C:\Development\cctv\node_modules@u4\opencv4nodejs\cc\dnn\Net.cc(115,48): error C2039: 'dump': is not a member of 'cv::dnn::dnn4_v20190122::Net' [C:\Development\cctv\node_modules@u4\opencv4nodejs\build\opencv4nodejs.vcxproj]
npm error gyp info it worked if it ends with ok
npm error gyp info using [email protected]
npm error gyp info using [email protected] | win32 | x64
npm error gyp info find Python using Python version 3.12.4 found at "C:\Python312\python.exe"
npm error gyp info find VS using VS2022 (17.10.35013.160) found at:
npm error gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools"
npm error gyp info find VS run with --verbose for detailed information
npm error gyp info spawn C:\Python312\python.exe
npm error gyp info spawn args [
npm error gyp info spawn args 'C:\Development\cctv\node_modules\node-gyp\gyp\gyp_main.py',
npm error gyp info spawn args 'binding.gyp',
npm error gyp info spawn args '-f',
npm error gyp info spawn args 'msvs',
npm error gyp info spawn args '-I',
npm error gyp info spawn args 'C:\Development\cctv\node_modules\@u4\opencv4nodejs\build\config.gypi',
npm error gyp info spawn args '-I',
npm error gyp info spawn args 'C:\Development\cctv\node_modules\node-gyp\addon.gypi',
npm error gyp info spawn args '-I',
npm error gyp info spawn args 'C:\Users\greg\AppData\Local\node-gyp\Cache\20.15.0\include\node\common.gypi',
npm error gyp info spawn args '-Dlibrary=shared_library',
npm error gyp info spawn args '-Dvisibility=default',
npm error gyp info spawn args '-Dnode_root_dir=C:\Users\greg\AppData\Local\node-gyp\Cache\20.15.0',
npm error gyp info spawn args '-Dnode_gyp_dir=C:\Development\cctv\node_modules\node-gyp',
npm error gyp info spawn args '-Dnode_lib_file=C:\\Users\\greg\\AppData\\Local\\node-gyp\\Cache\\20.15.0\\<(target_arch)\\node.lib',
npm error gyp info spawn args '-Dmodule_root_dir=C:\Development\cctv\node_modules\@u4\opencv4nodejs',
npm error gyp info spawn args '-Dnode_engine=v8',
npm error gyp info spawn args '--depth=.',
npm error gyp info spawn args '--no-parallel',
npm error gyp info spawn args '--generator-output',
npm error gyp info spawn args 'C:\Development\cctv\node_modules\@u4\opencv4nodejs\build',
npm error gyp info spawn args '-Goutput_dir=.'
npm error gyp info spawn args ]
npm error gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe
npm error gyp info spawn args [
npm error gyp info spawn args 'build\binding.sln',
npm error gyp info spawn args '/clp:Verbosity=minimal',
npm error gyp info spawn args '/nologo',
npm error gyp info spawn args '/p:Configuration=Release;Platform=x64'
npm error gyp info spawn args ]
npm error gyp ERR! build error
npm error gyp ERR! stack Error: C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe failed with exit code: 1
npm error gyp ERR! stack at ChildProcess. (C:\Development\cctv\node_modules\node-gyp\lib\build.js:209:23)
npm error gyp ERR! stack at ChildProcess.emit (node:events:519:28)
npm error gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:294:12)
npm error gyp ERR! System Windows_NT 10.0.22631
npm error gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Development\cctv\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
npm error gyp ERR! cwd C:\Development\cctv\node_modules@u4\opencv4nodejs
npm error gyp ERR! node -v v20.15.0
npm error gyp ERR! node-gyp -v v10.1.0
npm error gyp ERR! not ok

npm error A complete log of this run can be found in: C:\Users\greg\AppData\Local\npm-cache_logs\2024-07-03T05_18_45_353Z-debug-0.log
PS C:\Development\cctv>
`

@UrielCh
Copy link
Owner

UrielCh commented Jul 3, 2024

That's not the first time I saw this kind of error, do you have an anti-virus running on your system that may cause errors during the cleaning step? Try to disable the antivirus live protect and check if you have the same issue.

@liftyourgame
Copy link
Author

Thanks. Disabled Malwarebytes but still get the error. I don't think deleting is the problem is it? Why is it trying to build OpenCV when the OPENCV4NODEJS_DISABLE_AUTOBUILD flag is set to 1?

@studentutu
Copy link

same here, fixed it by using pnpm - somehow default npm tries to build lib even when all conditions to disable autobuild are met.

@liftyourgame
Copy link
Author

Did:

choco install pnpm
pnpm install

Still get the same result.

@studentutu
Copy link

try to clean all npm caches and such, and also remove ./node-modules - and strictly use pnpm - it will use symlinked folders in your ./node-module, this is probably why it works with pnpm
Also install globally nody-gyp or something like this ( see the package for opencv4nodejs), as it is one of the requirements for build project

@liftyourgame
Copy link
Author

So did:

npm cache clean --force
del node_modules
pnpm install -g node-gyp

pnpm install

Get the same result

@liftyourgame
Copy link
Author

Ran:

Remove-Item .\node_modules\

$env:OPENCV4NODEJS_DISABLE_AUTOBUILD=1
$env:OPENCV_INCLUDE_DIR='C:\\tools\\opencv\\build\\include'
$env:OPENCV_LIB_DIR='C:\tools\opencv\build\x64\vc15\lib'
$env:OPENCV_BIN_DIR='C:\tools\opencv\build\x64\vc15\bin'

pnpm i

Still get:

node_modules/.pnpm/@[email protected][email protected]/node_modules/@u4/opencv4nodejs: Running install script, failed in 1m 41.1s
.../node_modules/@u4/opencv4nodejs install$ node-gyp rebuild

Why is node-gyp rebuild running?

Seems to be starting around line 319 of compileLib.js

@tothadi
Copy link

tothadi commented Jul 18, 2024

Same here since version 7.0.0. I have a custom docker image with prebuild opencv but npm ci still tries to build everytime and gyp fails every time.

@meesii
Copy link

meesii commented Sep 13, 2024

same issues

@UrielCh
Copy link
Owner

UrielCh commented Sep 13, 2024

I have have a windows PC, let me try that....

any command line sequence to reproduce the issue ?

@meesii
Copy link

meesii commented Sep 13, 2024

@UrielCh
Yes, I set all the system environment variables, and then executed "npm i @u4-opencv4nodejs" and the above problem occurred.

Including setting "disableAutoBuild" in package.json, "OPENCV_INCLUDE_DIR", "OPENCV_LIB_DIR", "OPENCV_BIN_DIR" are also invalid.

I just installed Visual Studio 2022, and "npm i @u4-opencv4nodejs" was successful, but when running it, it still prompted me to install opencv.

Then I installed "@u4-opencv-build" and executed "npx build-opencv --version 4.6.0 rebuild", which also prompted me with errors related to "node-gyp".

error

@UrielCh
Copy link
Owner

UrielCh commented Sep 13, 2024

4.1.0 ??

that may be the issue, the current version is around 4.10.0, 4.1.0 is very old

@UrielCh
Copy link
Owner

UrielCh commented Sep 13, 2024

oups, you do not need the build-opencv anymore...
I improve that some version ago, now I use the default build process.

just use npm install @u4/opencv4nodejs once our environement variables are set or, after adding the extra parameters in package.json.

but the tatest version do not need any parameter, and will by default locate you choco openCV version and use it out of the box.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants