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

Cannot rebuild sqlite3 #546

Open
cyrilfr opened this issue Dec 14, 2020 · 1 comment
Open

Cannot rebuild sqlite3 #546

cyrilfr opened this issue Dec 14, 2020 · 1 comment

Comments

@cyrilfr
Copy link

cyrilfr commented Dec 14, 2020

I have an Electron app using SQLite and TypeORM. When I try to rebuild the sqlite3 5.0.0 package for my electron version (7.2.3), I get an error:

electron-rebuild -f -w sqlite3

make: Leaving directory '/home/cyril/app/node_modules/monocypher/build'
⠸ Building module: sqlite3, Completed: 2gyp: Undefined variable napi_build_version in binding.gyp while trying to load binding.gyp
✖ Rebuild Failed

An unhandled error occurred inside electron-rebuild
node-gyp failed to rebuild '/home/cyril/app/node_modules/sqlite3'.
Error: `gyp` failed with exit code: 1



Error: node-gyp failed to rebuild '/home/cyril/app/node_modules/sqlite3'.
Error: `gyp` failed with exit code: 1


    at ModuleRebuilder.rebuildNodeGypModule (/home/cyril/app/node_modules/electron-rebuild/lib/src/module-rebuilder.js:193:19)
    at process._tickCallback (internal/process/next_tick.js:68:7)
@gmantri
Copy link

gmantri commented Dec 24, 2020

I ran into the same issue when rebuilding sqlite3 on my Windows machine (did not encounter the issue on my Mac). I added the following line of code to the variables section in binding.gyp file and that seems to solve the problem:

"napi_build_version%":"3"

Here's my revised binding.gyp file looks like:

{
  "includes": [ "deps/common-sqlite.gypi" ],
  "variables": {
      "sqlite%":"internal",
      "sqlite_libname%":"sqlite3",
      "napi_build_version%":"3"
  },
  "targets": [
    {
      "target_name": "<(module_name)",
      "cflags!": [ "-fno-exceptions" ],
      "cflags_cc!": [ "-fno-exceptions" ],
      "xcode_settings": { "GCC_ENABLE_CPP_EXCEPTIONS": "YES",
        "CLANG_CXX_LIBRARY": "libc++",
        "MACOSX_DEPLOYMENT_TARGET": "10.7",
      },
      "msvs_settings": {
        "VCCLCompilerTool": { "ExceptionHandling": 1 },
      },
      "include_dirs": [
        "<!@(node -p \"require('node-addon-api').include\")"],
      "conditions": [
        ["sqlite != 'internal'", {
            "include_dirs": [
              "<!@(node -p \"require('node-addon-api').include\")", "<(sqlite)/include" ],
            "libraries": [
               "-l<(sqlite_libname)"
            ],
            "conditions": [ [ "OS=='linux'", {"libraries+":["-Wl,-rpath=<@(sqlite)/lib"]} ] ],
            "conditions": [ [ "OS!='win'", {"libraries+":["-L<@(sqlite)/lib"]} ] ],
            'msvs_settings': {
              'VCLinkerTool': {
                'AdditionalLibraryDirectories': [
                  '<(sqlite)/lib'
                ],
              },
            }
        },
        {
            "dependencies": [
              "<!(node -p \"require('node-addon-api').gyp\")",
              "deps/sqlite3.gyp:sqlite3"
            ]
        }
        ]
      ],
      "sources": [
        "src/backup.cc",
        "src/database.cc",
        "src/node_sqlite3.cc",
        "src/statement.cc"
      ],
      "defines": [ "NAPI_VERSION=<(napi_build_version)", "NAPI_DISABLE_CPP_EXCEPTIONS=1" ]
    },
    {
      "target_name": "action_after_build",
      "type": "none",
      "dependencies": [ "<(module_name)" ],
      "copies": [
          {
            "files": [ "<(PRODUCT_DIR)/<(module_name).node" ],
            "destination": "<(module_path)"
          }
      ]
    }
  ]
}

However I still have this issue where the folder name contains {napi_build_version} string.

Hope this helps.

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

2 participants