Skip to content

Cabal disagrees on the datadir in the Path_ module, and where it ends up installing data files. #5862

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

Closed
angerman opened this issue Jan 25, 2019 · 3 comments

Comments

@angerman
Copy link
Collaborator

The issue seems to be the handling of components. If we explicitly ask for the component, we end up with a fully qualified $pkgid, if we don't we get the plain pkg name. This can be illustrated on the alex packaged quite neatly:

$ runghc Setup.hs configure exe:alex 
$ runghc Setup.hs build exe:alex 
$ cat dist/build/alex/autogen/Paths_alex.hs |grep datadir
bindir, libdir, dynlibdir, datadir, libexecdir, sysconfdir :: FilePath
datadir    = "/usr/local/share/x86_64-osx-ghc-8.6.3/alex-3.2.4-BnUEMKTG1CcF5xN1sTDkoW-alex"
getDataDir = catchIO (getEnv "alex_datadir") (\_ -> return datadir)

vs.

$ runghc Setup.hs configure
$ runghc Setup.hs build
$ cat dist/build/alex/autogen/Paths_alex.hs |grep datadir
bindir, libdir, dynlibdir, datadir, libexecdir, sysconfdir :: FilePath
datadir    = "/usr/local/share/x86_64-osx-ghc-8.6.3/alex-3.2.4"
getDataDir = catchIO (getEnv "alex_datadir") (\_ -> return datadir)

Now this wouldn't be an issue, if runghc Setup.hs install installed the data files into /usr/local/share/x86_64-osx-ghc-8.6.3/alex-3.2.4-BnUEMKTG1CcF5xN1sTDkoW-alex for the component configured case, but instead it will install them in /usr/local/share/x86_64-osx-ghc-8.6.3/alex-3.2.4, which then gives rise to amazing errors at runtime :(

This seems mildly related to #5543, but I'm not sure it's the identical situation.

@angerman
Copy link
Collaborator Author

Could this be the patch I'm looking for?

diff --git a/Cabal/Distribution/Simple/Build/PathsModule.hs b/Cabal/Distribution/Simple/Build/PathsModule.hs
index f6a203874..2aa406f74 100644
--- a/Cabal/Distribution/Simple/Build/PathsModule.hs
+++ b/Cabal/Distribution/Simple/Build/PathsModule.hs
@@ -192,10 +192,14 @@ generate pkg_descr lbi clbi =
           bindir     = flat_bindir,
           libdir     = flat_libdir,
           dynlibdir  = flat_dynlibdir,
-          datadir    = flat_datadir,
           libexecdir = flat_libexecdir,
           sysconfdir = flat_sysconfdir
         } = absoluteComponentInstallDirs pkg_descr lbi cid NoCopyDest
+
+        InstallDirs {
+          datadir    = flat_datadir
+        } = absoluteInstallDirs pkg_descr lbi NoCopyDest
+
         InstallDirs {
           bindir     = flat_bindirrel,
           libdir     = flat_libdirrel,

@angerman
Copy link
Collaborator Author

There is a note in C/D/S/Install.hs

-- | Copy package global files.
copyPackage :: Verbosity -> PackageDescription
            -> LocalBuildInfo -> FilePath -> CopyDest -> IO ()
copyPackage verbosity pkg_descr lbi distPref copydest = do
  let -- This is a bit of a hack, to handle files which are not
      -- per-component (data files and Haddock files.)
      InstallDirs {
         datadir    = dataPref,
         -- NB: The situation with Haddock is a bit delicate.  On the
         -- one hand, the easiest to understand Haddock documentation
         -- path is pkgname-0.1, which means it's per-package (not
         -- per-component).  But this means that it's impossible to
         -- install Haddock documentation for internal libraries.  We'll
         -- keep this constraint for now; this means you can't use
         -- Cabal to Haddock internal libraries.  This does not seem
         -- like a big problem.
         docdir     = docPref,
         htmldir    = htmlPref,
         haddockdir = interfacePref}
             -- Notice use of 'absoluteInstallDirs' (not the
             -- per-component variant).  This means for non-library
             -- packages we'll just pick a nondescriptive foo-0.1
             = absoluteInstallDirs pkg_descr lbi copydest

@23Skidoo
Copy link
Member

Is this fixed by #6055?

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

3 participants