Skip to content
This repository has been archived by the owner on Feb 6, 2019. It is now read-only.

fail installing #47

Open
albfan opened this issue Nov 11, 2018 · 7 comments
Open

fail installing #47

albfan opened this issue Nov 11, 2018 · 7 comments

Comments

@albfan
Copy link

albfan commented Nov 11, 2018

$ npm install tree-sitter-cli

> tree-sitter-cli@0.13.10 install /home/alberto/node_modules/tree-sitter-cli
> node-gyp rebuild

gyp: vendor/tree-sitter/project.gyp not found (cwd: /home/alberto/projects/tree-sitter/tree-sitter-cli) while loading dependencies of binding.gyp while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/lib/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
gyp ERR! System Linux 4.18.16-arch1-1-ARCH
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/alberto/projects/tree-sitter/tree-sitter-cli
gyp ERR! node -v v10.12.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm WARN enoent ENOENT: no such file or directory, open '/home/alberto/package.json'
npm WARN alberto No description
npm WARN alberto No repository field.
npm WARN alberto No README data
npm WARN alberto No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! tree-sitter-cli@0.13.10 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the tree-sitter-cli@0.13.10 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/alberto/.npm/_logs/2018-11-11T10_18_13_130Z-debug.log
@Aerijo
Copy link
Contributor

Aerijo commented Nov 11, 2018

npm WARN enoent ENOENT: no such file or directory, open '/home/alberto/package.json'

@albfan Are you trying to install it in the package repo, or your home folder?

@albfan
Copy link
Author

albfan commented Nov 11, 2018

@Aerijo seems npm looks for that file outside the repo. I tried both approachs

@albfan
Copy link
Author

albfan commented Nov 11, 2018

I tried again and now it works, but

$ tree-sitter-cli
bash: tree-sitter-cli: no se encontró la orden

how should I run tree-sitter-cli?

@Aerijo
Copy link
Contributor

Aerijo commented Nov 11, 2018

The instructions go over this; inside the package directory, there’s a binary called tree-sitter in the node modules bin folder.

http://tree-sitter.github.io/tree-sitter/creating-parsers#installing-the-tools

@albfan
Copy link
Author

albfan commented Nov 12, 2018

That's instructions seems to cover when you want to generate new parser, I just want to test interactively existing ones

This is a fixed example that works, but I want to try different things quickly:

https://github.com/albfan/tree-sitter-c-parser-example

I tried ruby-tree-sitter but seems it is outdated

Can I use tree-sitter-cli without any new parser?

I cloned tree-sitter-c, cd into it and run:

$ ~/node_modules/.bin/tree-sitter test
/home/alberto/projects/tree-sitter/tree-sitter-c/index.js:7
    throw error
    ^

Error: Cannot find module './build/Release/tree_sitter_c_binding'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
    at Function.Module._load (internal/modules/cjs/loader.js:506:25)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/home/alberto/projects/tree-sitter/tree-sitter-c/index.js:2:20)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)

So, as first use case: what should I do to test interactively tree-sitter-c parser?

@Aerijo
Copy link
Contributor

Aerijo commented Nov 12, 2018

I was referring to this in particular, which describes how to set up and run the command provided by tree-sitter-cli

This will install the CLI and its dependencies into the node_modules folder in your directory. An executable program called tree-sitter will be created at the path ./node_modules/.bin/tree-sitter. You may want to follow the Node.js convention of adding ./node_modules/.bin to your PATH so that you can easily run this program when working in this directory.

And shortly after:

Then run the the following command:

tree-sitter generate
npm install

This will generate the C code required to parse this trivial language, as well as all of the files needed to compile and load this native parser as a Node.js module. You can test this parser by creating a source file with the contents hello; and parsing it:

tree-sitter parse ./the-file

I'm not sure what you mean by interactively though; you can use tree-sitter test to run all tests in the corpus folder, but live changes aren't possible.

To run the tests, you will need to build the parser. In general, compiled files are not checked into version control.

@MarkL4YG
Copy link

MarkL4YG commented Jan 8, 2019

I am not quite sure whether or not this issue is related to mine but the title does match.
Currently installing tree-sitter-cli fails on my machine.
Information available here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants