yesodweb / yesodweb/persistent

Make persistFileWith use project-root relative paths

Open
#633 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement Newcomer
Dominant language
Haskell
Stars
486
Forks
306
PR merge metrics
No merged PRs in 30d

Description

With code like this:

share [mkPersist sqlSettings, mkMigrate "migrateAll"]
    $(persistFileWith lowerCaseSettings "config/models")

If you run stack ghci from a directory other than the project root you get this error:

[ 2 of 13] Compiling Model            ( /home/enolan/mystuff/code/emp-pl-site/Model.hs, interpreted )

/home/enolan/mystuff/code/emp-pl-site/Model.hs:12:7:
    Exception when trying to run compile-time code:
      config/models: openFile: does not exist (No such file or directory)
    Code: persistFileWith lowerCaseSettings "config/models"
    In the splice: $(persistFileWith lowerCaseSettings "config/models")

I started a quick and dirty PR than just copy pastes makeRelativeToProject from file-embed in and uses it, but then I realized that's @snoyberg's package. Maybe file-embed should expose it? Or expose something like embedFileText :: FilePath -> Q Text?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the implementation and call path for persistFileWith, then compare the mentioned makeRelativeToProject approach in file-embed. Reproduce the failure by running stack ghci outside the project root. Done means the persistFileWith example can resolve config/models from another working directory, with the API approach agreed by maintainers.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.