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

Requires rebuild after every package install with yarn, multiple bugs in getOpenCV function #113

Open
arunlodhi opened this issue Sep 30, 2023 · 0 comments

Comments

@arunlodhi
Copy link

Hi Uriel,

Great work with the library!

I am using yarn and I noticed that whenever I add or remove a package, yarn resets the node_modules package states. This results in the loss of release files and opencv4nodejs requires rebuilding everytime a package install takes place.

Even if I manually copy over the opencv4nodejs.node file to OPENCV_BIN_DIR (as this is the directory the getOpenCV function checks for), it does not work because the function does not look for the correct file path.

From what I could decipher, the getOpenCV function uses the below logic:

  1. Looks for Debug/opencv4nodejs.node inside node_modules/@u4/opencv4nodejs/build/, then looks for Release/opencv4nodejs.node inside the same folder

  2. In case the Release build is not found, it checks for process.env.path - this would work only on windows, I think this should be process.env.PATH:

    if (!process.env.path) {
    logDebug('require', 'there is no path environment variable, skipping...')
    throw err
    }
    On my linux machine, this is the exact block the execution ends up in, and does not proceed.

  3. Next. it tries to add OPENCV_BIN_DIR to process.env.path, I think path should be contactenated with the colon operator on linux and semicolon on windows (unless this part is meant only for windows):

    process.env.path = `${process.env.path};${opencvBinDir};`

  4. After path modification, it tries to require the exact same release build path it did in Step 1, without any modification to the path - This is guaranteed to fail, are we trying to look for OPENCV_BIN_DIR/opencv4nodejs.node instead of node_modules/@u4/opencv4nodejs/build/Release/opencv4nodejs.node at this point?

I am not sure if the above logic is written as it was meant to be. Also, I would highly recommend making the output directory for node-gyp used within the package configurable via an environment variable and using the same environment variable to check for the build files existence in getOpenCV.

Kindly look into this.

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

1 participant