Template Haskell, cannot locate file
See original GitHub issueI’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:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 theStack
developers mentioned, the problems come from theGHCi 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.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.