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

Parsing cabal.project fails when its content is "packages: ..." without a trailing newline #54

Open
kztk-m opened this issue Feb 20, 2024 · 2 comments

Comments

@kztk-m
Copy link

kztk-m commented Feb 20, 2024

gen-hie fails to parse cabal.project when it consists only of the field "packages" without a trailing newline.

Suppose that the current directly contains proj, which contains proj.cabal with certain content.

$ ls 
proj
$ ls proj 
LICENSE     app/        proj.cabal

Then, if we generate cabal.project whose content is "packages: ..." without a trailing newline, gen-hie fails to parse the file.

$ echo -n "packages: proj/*.cabal" > cabal.project
$ gen-hie
Used cabal
 No .cabal files found under/Users/kztk/prog/haskell/cabal_package_f
 You may need to run stack build.

On the other hand, if the cabal.project has a trailing newline, everything works as expected.

$ echo  "packages: proj/*.cabal" > cabal.project
$ gen-hie 
cradle:
  cabal:
    - path: "proj/app/Main.hs"
      component: "proj:exe:proj"

I confirmed the above issue with implicit-hie 0.1.4.0.

I suspect this issue would be caused by the function field called by extractPkgs in src/Hie/Cabal/Parser.hs, which requires the newline in the end by calling skipToNextLine.

@Avi-D-coder
Copy link
Owner

Thank you for the report. PRs welcome!

@kztk-m
Copy link
Author

kztk-m commented Feb 21, 2024

I have created the PR #55 (comment) for this issue.

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