question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Template Haskell, cannot locate file

See original GitHub issue

I’m creating a protobuf service with Haskell using the project: https://github.com/higherkindness/mu-haskell. Inside IntelliJ-Haskell, I get the following error:

error: Exception when trying to run compile-time code:
  predictor.proto: openFile: does not exist (No such file or directory)
  Code: grpc "PredictorSchema" id "predictor.proto"

On the command line stack build works as expected. File is located at:

sub-package: ...
sub-package: ...
sub-package/
   predictor.proto
   /src/Haskell-file.hs <--- this contains the grpc line failing

stack.yaml

If I put the whole local path to the file (/home/project/sub-package/predictor.proto), IntelliJ-Haskell recognizes it and removes the error. However, this is not an actual solution after it goes to our GIT. Are there any easy fixes to this issue?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
llattilacommented, Feb 20, 2021

If I have understood correctly, the GHCi will use the base folder of the project. As such, when it is trying to locate the proto file, it is one folder deeper. However, stack build will use a different directory when building. Found some related discussions five years ago and the Stack developers mentioned, the problems come from the GHCi interface. I could ask from their support as well, whether there is a solution. For now, I have created a very non-hacky solution by creating a symbolic link in the base folder to my sub-package file which works locally 😄

I could update this when I hear something from the Stack guys to see whether things have changed.

0reactions
llattilacommented, Feb 28, 2021

Got some good feedback from the guys at FPComplete. They suggested using the following to handle the issue:

https://hackage.haskell.org/package/file-embed-0.0.13.0/docs/Data-FileEmbed.html#v:makeRelativeToProject

This should allow one to properly handle files even if there are multiple packages.

Read more comments on GitHub >

github_iconTop Results From Across the Web

profile fails with cannot find object file that lifts template haskell ...
cannot find object file EmbedString.o when all source files are for the executable. If instead, I have the EmbedString module in a library, ......
Read more >
Can't find inerface-file declaration for variable - Stack Overflow
This seems to be because dataToQa expects the function that toConstr shows (which is "pack" for Text ) to be in the same...
Read more >
6.13. Template Haskell
Template Haskell. Template Haskell allows you to do compile-time meta-programming in Haskell. The background to the main technical innovations is discussed in ...
Read more >
5.8. Filenames and separate compilation
Each Haskell source module should be placed in a file on its own. Usually, the file should be named after the module name,...
Read more >
7.16. Template Haskell
Template Haskell allows you to do compile-time meta-programming in Haskell. The background to the main technical innovations is discussed in " Template ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found