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

fail to use pnpm create @ast-grep/lang to complete a happy path #20

Open
LoTwT opened this issue Jan 15, 2025 · 15 comments
Open

fail to use pnpm create @ast-grep/lang to complete a happy path #20

LoTwT opened this issue Jan 15, 2025 · 15 comments

Comments

@LoTwT
Copy link
Contributor

LoTwT commented Jan 15, 2025

description

I ran pnpm create @ast-grep/lang and followed the prompted default configs, but it came across some errors.

The process was interrupted and the project codes were generated partially.

I think the Tree-sitter package to use and its default string are confusing. It's better to clarify its usage and update it with a more detailed description.

image image
@HerringtonDarkholme
Copy link
Member

HerringtonDarkholme commented Jan 16, 2025

You need to use a real tree-sitter npm package. alang is not a real programming language.

You need real programming language and has tree-sitter package.

https://github.com/ast-grep/langs/tree/main/packages/angular

For reference, you can use awk. https://www.npmjs.com/package/tree-sitter-awk

@HerringtonDarkholme
Copy link
Member

In terms of description, #16 is tracking a doc for such usage

@LoTwT
Copy link
Contributor Author

LoTwT commented Jan 16, 2025

I know and I tried a real tree-sitter npm package. It works. Looking forward to the document. ♥️

Besides, the only little confusing thing is that when setting the language name to some-lang, the Tree-sitter package to use will show a default value tree-sitter-some-lang. It may lead users to misunderstand that it will work. Should the default value be removed?

image

@HerringtonDarkholme
Copy link
Member

TBH I think this feature is only for language author or person who does already have a parser in hand. So tree-sitter-xxx is probably a good default name for them to find the package.

Besides that, I don't think ordinary user will look at this repo at all 🤣

@LoTwT
Copy link
Contributor Author

LoTwT commented Jan 16, 2025

🤣You are right.

@HerringtonDarkholme
Copy link
Member

btw I do think the error reporting is horrendous. I will create a new issue for it

@LoTwT
Copy link
Contributor Author

LoTwT commented Jan 17, 2025

I find some new issues.

When there's no tree-sitter-cli installed globally, it will fail.

Image

And after installing it, it came across another error

Image

@HerringtonDarkholme
Copy link
Member

HerringtonDarkholme commented Jan 17, 2025

hmm it's right, tree-sitter-cli should be in devDependencies

the other warning comes from tree-sitter cli. :/

Would you like to open an issue there?

@HerringtonDarkholme
Copy link
Member

I pushed a new 0.0.0-prerelease to npm

@LoTwT
Copy link
Contributor Author

LoTwT commented Jan 17, 2025

hmm it's right, tree-sitter-cli should be in devDependencies

the other warning comes from tree-sitter cli. :/

Would you like to open an issue there?

You say tree-sitter-cli should be in the devDependencies. But when I run pnpm create @ast-grep/lang@latest hlang, it's in the dependencies. Is it the right place?

Image

For the second error Failed to find tree-sitter section in package.json, unable to migrate, I don't know how to describe it in a minimum reproduction.😢

@HerringtonDarkholme
Copy link
Member

@LoTwT thanks for reporting! devDeps is fixed. I will also investigate how to suppress the warning.

@LoTwT
Copy link
Contributor Author

LoTwT commented Feb 17, 2025

description

Hi, @HerringtonDarkholme. Today I tried pnpm create @ast-grep/lang again and failed. The error stacks are the following. It seems related to the build script. 😭

system info

➜ npx envinfo --system  --binaries --browsers

  System:
    OS: macOS 15.3.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 1.73 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.14.0 - ~/.local/state/fnm_multishells/907_1739321328392/bin/node
    Yarn: 1.22.22 - ~/.local/state/fnm_multishells/907_1739321328392/bin/yarn
    npm: 10.9.2 - ~/.local/state/fnm_multishells/907_1739321328392/bin/npm
    pnpm: 10.4.1 - ~/.local/state/fnm_multishells/907_1739321328392/bin/pnpm
    bun: 1.2.3 - ~/.bun/bin/bun
  Browsers:
    Chrome: 133.0.6943.55
    Safari: 18.3

error

Image Image

@HerringtonDarkholme
Copy link
Member

can you manually run tree-sitter build -o parser.so ?

@LoTwT
Copy link
Contributor Author

LoTwT commented Feb 17, 2025

can you manually run tree-sitter build -o parser.so ?

Image

It works! 😱

@LoTwT
Copy link
Contributor Author

LoTwT commented Feb 17, 2025

It may related to the pnpm v10. The successful try is using the global tree-sitter-cli. It also fails after I remove it.

When I downgrade to pnpm v9, it works.

When using pnpm v10, it works after I run pnpm approve-builds and allow the scripts.


Another question, do these warnings matter?

Image

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