Skip to content

Data files not working in new-build projects #4639

Closed

Description

@fgaz

Here's the problem: https://github.com/haskell/cabal/blob/484bb6c/cabal-install/Distribution/Client/CmdRun.hs#L211

We use the current directory as the base path for data files in new-run, but "current directory == package root" was true only before new-build.

Replacing curDir with the actual package root should fix this.

Activity

  1. self-assigned this
    on Jul 28, 2017
  2. added
    cabal-install: v2-build system
    on Jul 28, 2017
  3. added 2 commits that reference this issue on Jul 28, 2017
    7c04d7a
    e54e8ff
  4. hvr commented on Aug 5, 2017

    @hvr
    Member

    I just ran into this problem, and didn't realise you were fully aware of this already :-)

    As this made new-run unusable for some of my use-case, I had to yak-shave and fix this in my local cabal, and here's what I did including a few TODO-notes on what is missing:

    diff --git a/cabal-install/Distribution/Client/CmdRun.hs b/cabal-install/Distribution/Client/CmdRun.hs
    index 4d49167..807c5cb 100644
    --- a/cabal-install/Distribution/Client/CmdRun.hs
    +++ b/cabal-install/Distribution/Client/CmdRun.hs
    @@ -19,6 +19,7 @@ import Distribution.Client.Compat.Prelude
     
     import Distribution.Client.ProjectOrchestration
     import Distribution.Client.CmdErrorMessages
    +import Distribution.Client.Types (PackageLocation(..))
     
     import Distribution.Client.Setup
              ( GlobalFlags, ConfigFlags(..), ConfigExFlags, InstallFlags
    @@ -57,8 +58,6 @@ import qualified Data.Map as Map
     import qualified Data.Set as Set
     import System.FilePath
              ( (</>) )
    -import System.Directory
    -         ( getCurrentDirectory )
     
     
     runCommand :: CommandUI (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags)
    @@ -203,21 +202,29 @@ runAction (applyFlagDefaults -> (configFlags, configExFlags, installFlags, haddo
             ++ exeName
             ++ ":\n"
             ++ unlines (fmap (\p -> " - in package " ++ display (elabUnitId p)) elabPkgs)
    +
         let exePath = binDirectoryFor (distDirLayout baseCtx)
                                       (elaboratedShared buildCtx)
                                       pkg
                                       exeName
                    </> exeName
    -    curDir <- getCurrentDirectory
    -    let dataDirEnvVar = (pkgPathEnvVar (elabPkgDescription pkg) "datadir",
    -                         Just $ curDir </> dataDir (elabPkgDescription pkg))
    +
    +    mexeDataDir <- case elabPkgSourceLocation pkg of
    +                     LocalUnpackedPackage d -> pure $ Just (d </> dataDir (elabPkgDescription pkg))
    +                     -- TODO/FIXME: figure out how to handle remaing constructors of PackageLocation
    +
    +    -- TODO/FIXME: dataDirEnvVars could be more than one variable, if local/inplace packages w/ package-data are involved!
    +    let dataDirEnvVars = case mexeDataDir of
    +                          Just _ -> [(pkgPathEnvVar (elabPkgDescription pkg) "datadir",
    +                                      mexeDataDir)]
    +                          Nothing -> []
             args = drop 1 targetStrings
         runProgramInvocation
           verbosity
           emptyProgramInvocation {
             progInvokePath  = exePath,
             progInvokeArgs  = args,
    -        progInvokeEnv   = [dataDirEnvVar]
    +        progInvokeEnv   = dataDirEnvVars
           }
       where
         verbosity = fromFlagOrDefault normal (configVerbosity configFlags)
  5. added a commit that references this issue on Aug 6, 2017
    7c8fe62
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

cabal-install: v2-build systemtype: bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions