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

Vscode Extension failed because it can not locate bindings file when importing faiss-node #2

Open
masasso opened this issue May 2, 2023 · 4 comments
Labels
bug Something isn't working waiting for response Replied, and waiting for response

Comments

@masasso
Copy link

masasso commented May 2, 2023

Describe the bug
I am just trying to use the code provided in documentation inside the VSCODE extrension but I get the error below:

Code:

const { IndexFlatL2 } = require('faiss-node');

const dimension = 2;
const Faissindex = new IndexFlatL2(dimension);

console.log(Faissindex.getDimension()); // 2
console.log(Faissindex.isTrained()); // true
console.log(Faissindex.ntotal()); // 0

// inserting data into index.
Faissindex.add([1, 0]);
Faissindex.add([1, 2]);
Faissindex.add([1, 3]);
Faissindex.add([1, 1]);

console.log(Faissindex.ntotal()); // 4

const k = 4;
const results = Faissindex.search([1, 0], k);
console.log(results.labels); // [ 0, 3, 1, 2 ]
console.log(results.distances); // [ 0, 1, 4, 9 ]

Error:

Activating extension 'Extension.extension' failed: Could not locate the bindings file. Tried:
 → /home/matheus/Projects/Extension/build/faiss-node.node
 → /home/matheus/Projects/Extension/build/Debug/faiss-node.node
 → /home/matheus/Projects/Extension/build/Release/faiss-node.node
 → /home/matheus/Projects/Extension/out/Debug/faiss-node.node
 → /home/matheus/Projects/Extension/Debug/faiss-node.node
 → /home/matheus/Projects/Extension/out/Release/faiss-node.node
 → /home/matheus/Projects/Extension/Release/faiss-node.node
 → /home/matheus/Projects/Extension/build/default/faiss-node.node
 → /home/matheus/Projects/Extension/compiled/16.14.2/linux/x64/faiss-node.node
 → /home/matheus/Projects/Extension/addon-build/release/install-root/faiss-node.node
 → /home/matheus/Projects/Extension/addon-build/debug/install-root/faiss-node.node
 → /home/matheus/Projects/Extension/addon-build/default/install-root/faiss-node.node
 → /home/matheus/Projects/Extension/lib/binding/node-v106-linux-x64/faiss-node.node.

Environment:

  • Operating system: [e.g. Linux]
  • Nodejs Version: [e.g. v18.15.0]
  • Package Version: [e.g. v0.1.0]
  • Using inside VSCODE Extenson

To Reproduce
Steps to reproduce the behavior:

  1. Put the code i suggested in the simplest possible vscode extension app (https://code.visualstudio.com/api/get-started/your-first-extension) and this error will appear when you hit F5 to test it.

Expected behavior
Faiss node should be imported

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

@masasso masasso added the bug Something isn't working label May 2, 2023
@ewfian
Copy link
Owner

ewfian commented May 7, 2023

@masasso Thank you for reporting the issue.
I tried the above steps but didn't reproduce. From the runtime error logs, it seems that the compiled binary was not found.

Please try these options

  • Create a blank nodejs project, install faiss-node, and run the given code see if it works. This is to confirm whether the problem is related to VS Code Extension.
  • Provide detailed npm install faiss-node --verbose logs to troubleshoot whether the installation of prebuild packages failed.
  • Please provide the smallest reproducible VS Code project for investigation.
  • Try to compile the binary locally.

@tro9999
Copy link

tro9999 commented May 23, 2023

@masasso I got similar problems with OSX setup. I tried clean install and tested the example. I got an error indicating there is something "missing".... Library not loaded: '/usr/local/opt/libomp/lib/libomp.dylib'
After "brew install libomp"... example works as expected. Note I've OSX not pure linux,... I hope this helps.

@ewfian
Copy link
Owner

ewfian commented May 25, 2023

@masasso I got similar problems with OSX setup. I tried clean install and tested the example. I got an error indicating there is something "missing".... Library not loaded: '/usr/local/opt/libomp/lib/libomp.dylib'
After "brew install libomp"... example works as expected. Note I've OSX not pure linux,... I hope this helps.

@tro9999 libomp is a dependency under OSX, I have bundled it in #5 and a new version will be released.

@ewfian ewfian added the waiting for response Replied, and waiting for response label Jun 1, 2023
@jjspace
Copy link

jjspace commented Apr 30, 2024

I just ran into this issue too because bindings seemed to be looking for the .node file starting from the wrong directory as shown in the first comment. After digging through a bunch of other issues on google this one from node-bindings lead to a working solution TooTallNate/node-bindings#43

Just add faiss-node as an external in the webpack config.

  externals: {
    // modules added here also need to be added in the .vscodeignore file
    "faiss-node": "commonjs faiss-node",
  },

then the sample code above and my own code using Faiss worked fine in a VSCode extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working waiting for response Replied, and waiting for response
Projects
None yet
Development

No branches or pull requests

4 participants