josa42 / coc-sh

SH language server extension using bash-language-server for coc.nvim.
MIT License
206 stars 4 forks source link

CocInstall coc-sh installation fails with node 12.1 #26

Closed rafi closed 4 years ago

rafi commented 5 years ago

Installing coc-sh with CocInstall fails with node v12.5.0 npm 6.9.0 yarn 1.17.0 on macOS 10.14.5, click below to see install log:

npm install log
> tree-sitter@0.13.23 install /Users/rafi/.config/coc/sh/tools/node_modules/tree-sitter
> prebuild-install || node-gyp rebuild

prebuild-install WARN install No prebuilt binaries found (target=12.5.0 runtime=node arch=x64 libc= platform=darwin)
  CC(target) Release/obj.target/runtime/vendor/tree-sitter/src/runtime/get_changed_ranges.o
  CC(target) Release/obj.target/runtime/vendor/tree-sitter/src/runtime/language.o
  CC(target) Release/obj.target/runtime/vendor/tree-sitter/src/runtime/lexer.o
  CC(target) Release/obj.target/runtime/vendor/tree-sitter/src/runtime/node.o
  CC(target) Release/obj.target/runtime/vendor/tree-sitter/src/runtime/stack.o
  CC(target) Release/obj.target/runtime/vendor/tree-sitter/src/runtime/parser.o
  CC(target) Release/obj.target/runtime/vendor/tree-sitter/src/runtime/subtree.o
  CC(target) Release/obj.target/runtime/vendor/tree-sitter/src/runtime/tree.o
  CC(target) Release/obj.target/runtime/vendor/tree-sitter/src/runtime/tree_cursor.o
  CC(target) Release/obj.target/runtime/vendor/tree-sitter/src/runtime/utf16.o
  CC(target) Release/obj.target/runtime/vendor/tree-sitter/externals/utf8proc/utf8proc.o
  LIBTOOL-STATIC Release/runtime.a
  CXX(target) Release/obj.target/tree_sitter_runtime_binding/src/binding.o
  CXX(target) Release/obj.target/tree_sitter_runtime_binding/src/conversions.o
../src/conversions.cc:32:12: warning: 'Set' is deprecated: Use maybe version [-Wdeprecated-declarations]
  exports->Set(Nan::New("pointTransferArray").ToLocalChecked(), Uint32Array::New(js_point_transfer_buffer, 0, 2));
           ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8.h:3358:3: note: 'Set' has been explicitly marked deprecated here
  V8_DEPRECATE_SOON("Use maybe version",
  ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATE_SOON'
  declarator __attribute__((deprecated(message)))
                            ^
../src/conversions.cc:42:11: warning: 'Set' is deprecated: Use maybe version [-Wdeprecated-declarations]
  result->Set(Nan::New(start_position_key), PointToJS(range.start_point));
          ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8.h:3358:3: note: 'Set' has been explicitly marked deprecated here
  V8_DEPRECATE_SOON("Use maybe version",
  ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATE_SOON'
  declarator __attribute__((deprecated(message)))
                            ^
../src/conversions.cc:43:11: warning: 'Set' is deprecated: Use maybe version [-Wdeprecated-declarations]
  result->Set(Nan::New(start_index_key), ByteCountToJS(range.start_byte));
          ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8.h:3358:3: note: 'Set' has been explicitly marked deprecated here
  V8_DEPRECATE_SOON("Use maybe version",
  ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATE_SOON'
  declarator __attribute__((deprecated(message)))
                            ^
../src/conversions.cc:44:11: warning: 'Set' is deprecated: Use maybe version [-Wdeprecated-declarations]
  result->Set(Nan::New(end_position_key), PointToJS(range.end_point));
          ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8.h:3358:3: note: 'Set' has been explicitly marked deprecated here
  V8_DEPRECATE_SOON("Use maybe version",
  ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATE_SOON'
  declarator __attribute__((deprecated(message)))
                            ^
../src/conversions.cc:45:11: warning: 'Set' is deprecated: Use maybe version [-Wdeprecated-declarations]
  result->Set(Nan::New(end_index_key), ByteCountToJS(range.end_byte));
          ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8.h:3358:3: note: 'Set' has been explicitly marked deprecated here
  V8_DEPRECATE_SOON("Use maybe version",
  ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATE_SOON'
  declarator __attribute__((deprecated(message)))
                            ^
../src/conversions.cc:68:3: warning: 'Get' is deprecated: Use maybe version [-Wdeprecated-declarations]
  INIT(start_point, start_position_key, PointFromJS);
  ^
../src/conversions.cc:60:33: note: expanded from macro 'INIT'
    auto field = Type(js_range->Get(Nan::New(key))); \
                                ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8.h:3412:3: note: 'Get' has been explicitly marked deprecated here
  V8_DEPRECATE_SOON("Use maybe version", Local Get(Local key));
  ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATE_SOON'
  declarator __attribute__((deprecated(message)))
                            ^
../src/conversions.cc:69:3: warning: 'Get' is deprecated: Use maybe version [-Wdeprecated-declarations]
  INIT(end_point, end_position_key, PointFromJS);
  ^
../src/conversions.cc:60:33: note: expanded from macro 'INIT'
    auto field = Type(js_range->Get(Nan::New(key))); \
                                ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8.h:3412:3: note: 'Get' has been explicitly marked deprecated here
  V8_DEPRECATE_SOON("Use maybe version", Local Get(Local key));
  ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATE_SOON'
  declarator __attribute__((deprecated(message)))
                            ^
../src/conversions.cc:70:3: warning: 'Get' is deprecated: Use maybe version [-Wdeprecated-declarations]
  INIT(start_byte, start_index_key, ByteCountFromJS);
  ^
../src/conversions.cc:60:33: note: expanded from macro 'INIT'
    auto field = Type(js_range->Get(Nan::New(key))); \
                                ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8.h:3412:3: note: 'Get' has been explicitly marked deprecated here
  V8_DEPRECATE_SOON("Use maybe version", Local Get(Local key));
  ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATE_SOON'
  declarator __attribute__((deprecated(message)))
                            ^
../src/conversions.cc:71:3: warning: 'Get' is deprecated: Use maybe version [-Wdeprecated-declarations]
  INIT(end_byte, end_index_key, ByteCountFromJS);
  ^
../src/conversions.cc:60:33: note: expanded from macro 'INIT'
    auto field = Type(js_range->Get(Nan::New(key))); \
                                ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8.h:3412:3: note: 'Get' has been explicitly marked deprecated here
  V8_DEPRECATE_SOON("Use maybe version", Local Get(Local key));
  ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATE_SOON'
  declarator __attribute__((deprecated(message)))
                            ^
../src/conversions.cc:80:11: warning: 'Set' is deprecated: Use maybe version [-Wdeprecated-declarations]
  result->Set(Nan::New(row_key), Nan::New(point.row));
          ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8.h:3358:3: note: 'Set' has been explicitly marked deprecated here
  V8_DEPRECATE_SOON("Use maybe version",
  ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATE_SOON'
  declarator __attribute__((deprecated(message)))
                            ^
../src/conversions.cc:81:11: warning: 'Set' is deprecated: Use maybe version [-Wdeprecated-declarations]
  result->Set(Nan::New(column_key), ByteCountToJS(point.column));
          ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8.h:3358:3: note: 'Set' has been explicitly marked deprecated here
  V8_DEPRECATE_SOON("Use maybe version",
  ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATE_SOON'
  declarator __attribute__((deprecated(message)))
                            ^
../src/conversions.cc:92:35: warning: 'Get' is deprecated: Use maybe version [-Wdeprecated-declarations]
  Local js_row = js_point->Get(Nan::New(row_key));
                                  ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8.h:3412:3: note: 'Get' has been explicitly marked deprecated here
  V8_DEPRECATE_SOON("Use maybe version", Local Get(Local key));
  ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATE_SOON'
  declarator __attribute__((deprecated(message)))
                            ^
../src/conversions.cc:98:38: warning: 'Get' is deprecated: Use maybe version [-Wdeprecated-declarations]
  Local js_column = js_point->Get(Nan::New(column_key));
                                     ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8.h:3412:3: note: 'Get' has been explicitly marked deprecated here
  V8_DEPRECATE_SOON("Use maybe version", Local Get(Local key));
  ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATE_SOON'
  declarator __attribute__((deprecated(message)))
                            ^
../src/conversions.cc:105:41: error: too few arguments to function call, single argument 'context' was not specified
  if (std::isfinite(js_row->NumberValue())) {
                    ~~~~~~~~~~~~~~~~~~~ ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8.h:2564:3: note: 'NumberValue' declared here
  V8_WARN_UNUSED_RESULT Maybe NumberValue(Local context) const;
  ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8config.h:351:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
#define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
                              ^
../src/conversions.cc:106:52: error: too few arguments to function call, single argument 'context' was not specified
    row = static_cast(js_row->Int32Value());
                                ~~~~~~~~~~~~~~~~~~ ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8.h:2569:3: note: 'Int32Value' declared here
  V8_WARN_UNUSED_RESULT Maybe Int32Value(Local context) const;
  ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8config.h:351:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
#define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
                              ^
../src/conversions.cc:111:44: error: too few arguments to function call, single argument 'context' was not specified
  if (std::isfinite(js_column->NumberValue())) {
                    ~~~~~~~~~~~~~~~~~~~~~~ ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8.h:2564:3: note: 'NumberValue' declared here
  V8_WARN_UNUSED_RESULT Maybe NumberValue(Local context) const;
  ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8config.h:351:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
#define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
                              ^
../src/conversions.cc:112:58: error: too few arguments to function call, single argument 'context' was not specified
    column = static_cast(js_column->Int32Value()) * BYTES_PER_CHARACTER;
                                   ~~~~~~~~~~~~~~~~~~~~~ ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8.h:2569:3: note: 'Int32Value' declared here
  V8_WARN_UNUSED_RESULT Maybe Int32Value(Local context) const;
  ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8config.h:351:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
#define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
                              ^
../src/conversions.cc:130:47: error: too few arguments to function call, single argument 'context' was not specified
  return Nan::Just(arg->Uint32Value() * BYTES_PER_CHARACTER);
                             ~~~~~~~~~~~~~~~~ ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8.h:2567:3: note: 'Uint32Value' declared here
  V8_WARN_UNUSED_RESULT Maybe Uint32Value(
  ^
/Users/rafi/.node-gyp/12.5.0/include/node/v8config.h:351:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
#define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
                              ^
13 warnings and 5 errors generated.
make: *** [Release/obj.target/tree_sitter_runtime_binding/src/conversions.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:200:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Darwin 18.6.0
gyp ERR! command "/usr/local/Cellar/node/12.5.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/rafi/.config/coc/sh/tools/node_modules/tree-sitter
gyp ERR! node -v v12.5.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN enoent ENOENT: no such file or directory, open '/Users/rafi/.config/coc/sh/tools/package.json'
npm WARN tools No description
npm WARN tools No repository field.
npm WARN tools No README data
npm WARN tools No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! tree-sitter@0.13.23 install: `prebuild-install || node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the tree-sitter@0.13.23 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!     /Users/rafi/.cache/node/npm/_logs/2019-07-14T12_54_39_555Z-debug.log

[Process exited 1]

The package.json dependencies are pretty old, maybe some updates would do some good?

josa42 commented 5 years ago

bash-language-server does not install on node 12.x.

Reference:

dagadbm commented 4 years ago

just a reminder: this is no longer the case apparently. they have updated bash-language-server. also there is some solution for node-tree-sitter.

jrwrigh commented 4 years ago

@dagadbm I'm still getting the problem though.

jrwrigh commented 4 years ago

To fix manually, simply install bash-language-server where coc is trying to find it. So in my case, it was looking for it somewhere in the ~/.config/coc/sh/tools/node_modules directory. You can double check this by looking at the :CocOpenLog and see where it tried to find the language server.

In that directory (~/.config/coc/sh/tools), run yarn add bash-language-server. Tada, it works correctly. Not sure why the extension isn't actually installing it.

jrwrigh commented 4 years ago

Finally was able to get an actual printout of the installation logs (see junegunn/vim-plug/#910):

yarn install v1.19.1                                                                                                                                                                                                                          
[1/5] Validating package.json...
warning coc-sh@0.2.1: The engine "coc" appears to be invalid.
[2/5] Resolving packages...
[3/5] Fetching packages...
[4/5] Linking dependencies...
[5/5] Building fresh packages...
$ yarn clean && yarn build
yarn run v1.19.1
warning coc-sh@0.2.1: The engine "coc" appears to be invalid.
$ rimraf lib
Done in 0.20s.
yarn run v1.19.1
warning coc-sh@0.2.1: The engine "coc" appears to be invalid.
$ tsc -p tsconfig.json
Done in 2.45s.
Done in 9.88s.

I'm not familiar with how it is supposed to work, but it looks like it doesn't even attempt to install the bash-language-server.

josa42 commented 4 years ago

This should be resolved in v0.3.1. Please reopen if installation still fails.

smhc commented 2 years ago

This works ok if coc-sh is installed the way 'CocInstall' installs it. However if you have a 'package.json' which lists 'coc-sh' and you perform a 'npm install' or 'yarn install' the bash-language-server will not necessary be installed under the 'coc-sh/node_modules' directory as the code assumes.

i.e this line: https://github.com/josa42/coc-sh/blob/master/src/extension.ts#L56 is making an incorrect assumption on how node modules are installed by tools other than CocInstall.

I personally perform a 'yarn install' instead of 'CocInstall' as I use a cache directory for doing the install which CocInstall doesn't expose. It also does a more efficient installation than what CocInstall does.

It would be great if this extension could determine the path to 'bash-language-server' by walking up the tree looking into 'node_modules' directories the same way nodejs resolves required dependencies.

smhc commented 2 years ago

This package may help with the resolution using nodejs resolution strategy:

https://www.npmjs.com/package/resolve