getdnsapi/getdns-node

Error installing - ../src/GNConstants.cpp:239:32: error: ‘GETDNS_RCODE_COOKIE’

Closed this issue · 6 comments

built and installed getdns
then npm install --save getdns

After a number of warnings about things being deprecated compilation fails with
CXX(target) Release/obj.target/getdns/src/GNConstants.o ../src/GNConstants.cpp: In static member function ‘static void GNConstants::Init(v8::Local<v8::Object>)’: ../src/GNConstants.cpp:239:32: error: ‘GETDNS_RCODE_COOKIE’ was not declared in this scope; did you mean ‘GETDNS_RCODE_BADCOOKIE’? 239 | SetConstant("RCODE_COOKIE",GETDNS_RCODE_COOKIE,exports); | ^~~~~~~~~~~~~~~~~~~ | GETDNS_RCODE_BADCOOKIE make: *** [getdns.target.mk:113: Release/obj.target/getdns/src/GNConstants.o] Error 1 make: Leaving directory '/home/francis/src/resolv/node_modules/getdns/build' gyp ERR! build error gyp ERR! stack Error:make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:315:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
gyp ERR! System Linux 5.4.0-72-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/francis/src/resolv/node_modules/getdns
gyp ERR! node -v v14.16.1
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm WARN resolv@1.0.0 No description
npm WARN resolv@1.0.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! getdns@4.0.0 install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the getdns@4.0.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/francis/.npm/_logs/2021-05-11T11_49_44_685Z-debug.log
`

@FrancisTurner: I can confirm the issue; there is a breaking constant name change in getdns on the develop branch. See #39 for a suggested fix -- does it work for you?

@FrancisTurner: I can confirm the issue; there is a breaking constant name change in getdns on the develop branch. See #39 for a suggested fix -- does it work for you?

* [getdnsapi/getdns#471](https://github.com/getdnsapi/getdns/pull/471)

* #39

Thanks for the fix. I'll try and confirm that it works but it may take some time as I'm not very familiar with locally overiding npm etc.

@FrancisTurner: no rush, the getdns version with GETDNS_RCODE_BADCOOKIE has not even been released yet.

Primer on local NPM package linking ("locally overriding npm").

# NOTE: your local clone of getdns-node.
cd getdns-node

# NOTE: see (re)building against the latest getdns according to instructions in #39.
# NOTE: you may not need to supply paths if you installed the built getdns in your system.
LIBRARY_PATH="/your/getdns/build" CPLUS_INCLUDE_PATH="/your/getdns/build" npm run --silent rebuild

# NOTE: enable linking to the package under development in $PWD. It is considered "temporary", and should be unlinked when done.
# NOTE: may need to provide the same paths as for a build.
LIBRARY_PATH="/your/getdns/build" CPLUS_INCLUDE_PATH="/your/getdns/build" npm link

# NOTE: your local application under development, which depends on getdns-node.
cd my-appplication

# NOTE: link to the temporary getdns-node under development.
npm link getdns-node

Clean up links after testing to avoid issues later.

# NOTE: in getdns-node.
# NOTE: changes in npm v7 may require the --global flag.
npm unlink

# NOTE: in my-application.
# NOTE: may (unexpectedly?) affect package.json in npm v7.
npm unlink getdns-node

See

(Didn't know that npm unlink is an alias for npm uninstall.)


Just discovered that there were (unintentional?) breaking changes to linking in npm v7.

@FrancisTurner: I almost forgot, you can also point NPM directly to a branch on Github. This should be easier than npm link (but perhaps less useful for debugging), in particular if you have already installed the "problematic" version of getdns as a system library.

Update the dependency in your application's package.json.

{
  "dependencies": {
    "getdns": "github:joelpurra/getdns-node#feature/bad-cookie"
  }
}

You can also run npm install 'github:joelpurra/getdns-node#feature/bad-cookie' to perform the update. The above file was generated by running this command in an empty directory.

For a custom getdns library path, use the environment variables from before.

LIBRARY_PATH="/your/getdns/build" CPLUS_INCLUDE_PATH="/your/getdns/build" npm install 'github:joelpurra/getdns-node#feature/bad-cookie'

See

@FrancisTurner: FYI, merged and released the fix as node-getdns v4.1.0, as getdns v1.7.0 was released a few days ago. Thanks for reporting!

npm install getdns@latest