Coder Social home page Coder Social logo

Comments (6)

danstiner avatar danstiner commented on August 23, 2024 1

Thanks, the comment about looking where hlint is installed by stack really helped me understand. The issue seems to be that a library I rely on (hlint) has hlint.yaml declared as a data file and expects it to get copied. I assumed cabal would copy any required data files from dependencies but it seems it will not. The fix should be as simple as copy in data/hlint.yaml from that project and add a data-files directive to the cabal file so it gets copied.

My personal laptop is in for repairs so I'm not sure when I'll have access to a machine to make the fix, but I'lll try to find a way.

from hfmt.

danstiner avatar danstiner commented on August 23, 2024

I honestly don't know how cabal copy works or why this would be failing. Could you give more detailed steps to help me reproduce?

from hfmt.

magthe avatar magthe commented on August 23, 2024

The steps I use aren't the simplest, I think, but they should at least allow you to reproduce:

  stack build --dependencies-only
  stack \
        exec ghc-pkg -- list | grep pkgdb | awk '{print "--package-db=" $0}' > db-paths
  stack \
        exec --no-ghc-package-path cabal -- configure \
        $(cat db-paths) \
        --prefix=/usr --docdir="/usr/share/doc/${pkgname}"
  stack \
        exec --no-ghc-package-path cabal -- build
  stack \
        exec --no-ghc-package-path cabal -- copy \
        --destdir="${destdir}"

You end up with the result of the copy in destdir, and it's those contents that's then package up into a distro package.

from hfmt.

danstiner avatar danstiner commented on August 23, 2024

I ran those commands and the resulting executable worked fine (at least on the same machine). Do you maybe have custom hlint config that is causing this? Does the normal hfmt exe resulting from stack install work when run from the same working directory?

from hfmt.

magthe avatar magthe commented on August 23, 2024

Here's how I manage to reproduce it on a clean system (a system with only stack and cabal installed)

mkdir hfmt-destdir
cabal get hfmt
cd hfmt-0.2.3.1
stack build --dependencies-only
stack exec ghc-pkg -- list | grep pkgdb | awk '{print "--package-db=" $0}' > db-paths
stack exec --no-ghc-package-path cabal -- configure $(cat db-paths) --prefix=/usr --docdir="/usr/share/doc/hfmt"
stack exec --no-ghc-package-path cabal -- build
stack exec --no-ghc-package-path cabal -- copy --destdir="../hfmt-destdir"
cd ..
rm -fr hfmt-0.2.3.1
rm -fr ~/.stack
echo 'main = putStrLn "Hello, World!"' > main.hs
./hfmt-destdir/usr/bin/hfmt main.hs

on my system this results in

hfmt: user error (Failed to find requested hint files:
  /home/magnus/Private/tmp/hfmt-destdir/usr/bin/data/hlint.yaml
)

and if I move the binary to /usr/local/bin I can see that it looks for the file relative to the location of the binary.

It also looks for the file in the location where stack caches the hlint library (under ~/.stack/snapshots/...).

I think a good solution would be to:

  • look for configuration files based on --datadir
  • include all needed configuration files when using cabal copy

from hfmt.

magthe avatar magthe commented on August 23, 2024

Oh, take your time, I'm in no hurry :)

from hfmt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.