nodejs / llnode

An lldb plugin for Node.js and V8, which enables inspection of JavaScript states for insights into Node.js processes and their core dumps.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

npm install fails with Ubuntu 18.04, lldb 6.0

jlevon opened this issue · comments

e$ node-gyp -v
v3.6.2
~$ dpkg -l lldb lldb-6.0-dev
ii  lldb                                    1:6.0-41~exp5~ubuntu1    amd64                    Next generation, high-performance debugger
un  lldb-6.0-dev                            

fails "npm install" (w or without --debug):

$ npm install --debug

> llnode@3.1.0 preinstall /home/jlevon/src/llnode
> node scripts/configure.js

Build dir is: /home/jlevon/src/llnode
Looking for lldb executable...
Found lldb executable /usr/bin/lldb

Reading lldb version...
Installing llnode for /usr/bin/lldb, lldb version 6.0

Looking for llvm-config for lldb 6.0...
Using llvm-config in /usr/bin/llvm-config-6.0

Looking for headers for lldb 6.0...
Found lldb headers in /usr/lib/llvm-6.0/include

Looking for shared libraries for lldb 6.0...
Found liblldb.so in /usr/lib/llvm-6.0/lib
Writing config.gypi:
{
  "variables": {
    "lldb_lib_dir%": "/usr/lib/llvm-6.0/lib",
    "lldb_lib%": "lldb",
    "lldb_include_dir%": "/usr/lib/llvm-6.0/include",
    "build_addon": "false",
    "coverage": "false"
  }
}
Writing llnode.js shortcut to /home/jlevon/src/llnode/llnode.js

> llnode@3.1.0 install /home/jlevon/src/llnode
> node scripts/install.js

make: Entering directory '/home/jlevon/src/llnode/build'
  CXX(target) Debug/obj.target/plugin/src/constants.o
  CXX(target) Debug/obj.target/plugin/src/error.o
  CXX(target) Debug/obj.target/plugin/src/llnode.o
  CXX(target) Debug/obj.target/plugin/src/llv8.o
../src/llv8.cc:732:36: warning: trigraph ??) ignored, use -trigraphs to enable [-Wtrigraphs]
   RETURN_IF_INVALID(name, "Symbol(???)");
                                     
../src/llv8.cc: In member function ‘llnode::v8::Value llnode::v8::JSObject::GetDescriptorProperty(std::__cxx11::string, llnode::v8::Map, llnode::Error&)’:
../src/llv8.cc:1179:14: warning: variable ‘value’ set but not used [-Wunused-but-set-variable]
       double value;
              ^~~~~
  CXX(target) Debug/obj.target/plugin/src/llv8-constants.o
  CXX(target) Debug/obj.target/plugin/src/llscan.o
  CXX(target) Debug/obj.target/plugin/src/printer.o
../src/printer.cc: In member function ‘std::__cxx11::string llnode::Printer::Stringify(T, llnode::Error&) [with T = llnode::v8::JSArrayBuffer; Actual = llnode::v8::JSArrayBuffer; std::__cxx11::string = std::__cxx11::basic_string<char>]’:
../src/printer.cc:371:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       if (display_length < *byte_length) {
           ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
../src/printer.cc: In member function ‘std::__cxx11::string llnode::Printer::Stringify(T, llnode::Error&) [with T = llnode::v8::JSTypedArray; Actual = llnode::v8::JSTypedArray; std::__cxx11::string = std::__cxx11::basic_string<char>]’:
../src/printer.cc:436:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if (display_length < *byte_length) {
         ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
../src/printer.cc: In member function ‘std::__cxx11::string llnode::Printer::Stringify(T, llnode::Error&) [with T = llnode::v8::Map; Actual = llnode::v8::Map]’:
../src/printer.cc:516:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
  CXX(target) Debug/obj.target/plugin/src/node.o
  CXX(target) Debug/obj.target/plugin/src/node-constants.o
  CXX(target) Debug/obj.target/plugin/src/settings.o
  SOLINK(target) Debug/obj.target/plugin.so
  COPY Debug/lib.target/plugin.so
make: Leaving directory '/home/jlevon/src/llnode/build'

> llnode@3.1.0 postinstall /home/jlevon/src/llnode
> node scripts/cleanup.js

Moving /home/jlevon/src/llnode/build/Debug/plugin.so to /home/jlevon/src/llnode/llnode.so
fs.js:766
  return binding.rename(pathModule._makeLong(oldPath),
                 ^

Error: ENOENT: no such file or directory, rename '/home/jlevon/src/llnode/build/Debug/plugin.so' -> '/home/jlevon/src/llnode/llnode.so'
    at Object.fs.renameSync (fs.js:766:18)
    at Object.<anonymous> (/home/jlevon/src/llnode/scripts/cleanup.js:26:4)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:188:16)
    at bootstrap_node.js:609:3

I had to use this diff:

$ git diff
diff --git a/scripts/cleanup.js b/scripts/cleanup.js
index 02fd591..98d839e 100644
--- a/scripts/cleanup.js
+++ b/scripts/cleanup.js
@@ -15,7 +15,7 @@ if (osName === 'Darwin') {
 const llnodeLib = `plugin.${libExt}`;
 const destLib = `llnode.${libExt}`;
 
-let buildPath = `${cwd}/build/Release/${llnodeLib}`;
+let buildPath = `${cwd}/build/Release/lib.target/${llnodeLib}`;
 
 if (!fs.existsSync(buildPath))
   buildPath = `${cwd}/build/Debug/${llnodeLib}`;

That seems like a new one (although I think I saw the obj.target error before). Which Node.js version are you on?

(I'm also not sure about having node-gyp installed globally, I usually leave it for packages to handle the node-gyp version they need)

I'm confused actually, you got the error when trying to build with --debug, but the diff is changing a Release build related line. Did you run npm install instead of npm install --debug the second time?

$ node -v
v8.10.0

Before I realised what was going on (fall back to Debug), I thought it was a Debug/Release inconsistency.
So yes, the fix is for a run without --debug, sorry that wasn't clear.

Node.js v8.x is not supported anymore (but that shouldn't be the reason it's not working, we just dropped support a month ago). I'll try your patch later, but I'm reluctant on merging it without understanding what's going on first.

If you revert the patch, clear the workspace and run npm install --debug, does it still fail?

Node.js v8.x is not supported anymore

I just realized our README doesn't reflect that, even though our release notes does, sorry about that.

Yes, still fails:

Error: ENOENT: no such file or directory, rename '/home/jlevon/src/llnode/build/Debug/plugin.so' -> '/home/jlevon/src/llnode/llnode.so'
$ ls /home/jlevon/src/llnode/build/Debug/lib.target/plugin.so 
/home/jlevon/src/llnode/build/Debug/lib.target/plugin.so

Note that this is the newest node version available on Ubuntu LTS - 20 isn't out until later this month. If you're not able to support this version of node, maybe note the last release that does for us poor LTS users? Which is it, and I'll try a build of that?

Thank you for confirming the issue persists. I have a few ideas of what might be.

Note that this is the newest node version available on Ubuntu LTS - 20 isn't out until later this month. If you're not able to support this version of node, maybe note the last release that does for us poor LTS users? Which is it, and I'll try a build of that?

Node.js v8/x is EOL (it has been since December). We try to keep up with Node.js release schedule as much as possible. Maintaining llnode is hard (it requires reverse-engineering V8), and we have very few contributors, so we don't have the resources to support EOL Node.js versions. I think the default Node.js version you can install via apt on Ubuntu 18.04 is packaged and provided by Canonical, and not by us (Node.js project). AFAIK we don't recommend installing this way either (note that v8.10 is an older version of the Node.js v8.x release line, the last version before it went EOL was 8.17.0, so the version provided by Canonical possibly lacks some security and bug fixes), instead there are a few recommended ways you can install the latest version following this guide. It's also possible to download directly from https://nodejs.org/en/download/ or by using a version manager like nvm.

llnode 2.2.0 was the last version with support for v8.x. That doesn't mean llnode 3.1.0 will not work with v8.x, but we don't have test coverage for it.

Just FYI v2.2.0 also has the same issue

Your "guide" link didn't point anywhere, but I can confirm that the official v12.16.1 tarball for node builds OK. I don't know if it's worth making this be a change to README in which case I can work up a PR?

I was able to reproduce it on a docker container using the Node.js, npm and node-gyp version provided by Canonical. Both npm and node-gyp are somewhat outdated (more so than they should be on Node.js v8.10) when installed via the Canonical repo, I think the issue is because of outdated node-gyp, but the whole toolchain here is outdated (EOL). Using Node.js v8.10.0 installed via nvm it's possible to install llnode with no changes to the preinstall scripts. Also, the patch above breaks newer versions, so we won't be able to apply it as is.

Just for clarification, I wasn't suggesting the patch be applied; just that it's what I needed.

Your "guide" link didn't point anywhere, but I can confirm that the official v12.16.1 tarball for node builds OK

My bad, wanted to point out to this guide: https://github.com/nodesource/distributions/blob/master/README.md

I don't know if it's worth making this be a change to README in which case I can work up a PR?

I don't think it's worth since we don't have other instructions on how to install Node.js and I think that's out of scope for our README. We might be able to do something to keep our preinstall scripts more resilient though, so I'd like to keep this issue open for now.

The reason I suggested a README update is because you do have a "Pre-requisite" section that does mention the package installer but says nothing at all about nod version or source. Maybe it's obvious to most people that the vendor-provided Node installation can't work, but it wasn't to me.

Maybe it's obvious to most people that the vendor-provided Node installation can't work, but it wasn't to me

That's not a limitation of llnode by the way, there are other packages which will not work because the package distributed by Ubuntu is not official. It's also not limited to Node.js, I've had problems with many other runtimes when installing from the Ubuntu repository instead of via the official installation channel provided by each project. I agree with you, that's not something new users are supposed to know (and ideally it shouldn't be an issue in the first place).

We've updated our README to reflect which Node.js version are supported (v10+) and I have a PR to make the installation process more deterministic and robust (from what I've tested it fixes this issue).