Skip to content

Cabal format duplicates dependencies #2353

Closed

Description

@tfausak

Running cabal format duplicates the build-depends section and duplicates dependencies in that section. For example, with this Cabal file:

name: example
version: 0
cabal-version: >=1.22.0.0
build-type: Simple
license: MIT
license-file: LICENSE.txt
maintainer: Taylor Fausak <[email protected]>
synopsis: TODO
description:
    TODO
category: Other

library
    build-depends:
        base ==4.*
    default-language: Haskell2010

Repeatedly running cabal format produces this:

    build-depends:
        base ==4.*
    build-depends:
        base ==4.*
    build-depends:
        base ==4.*,
        base ==4.*
    build-depends:
        base ==4.*,
        base ==4.*
    build-depends:
        base ==4.*,
        base ==4.*,
        base ==4.*,
        base ==4.*
    build-depends:
        base ==4.*,
        base ==4.*,
        base ==4.*,
        base ==4.*

I would expect cabal format to not make any changes to the given Cabal file. I'm using GHC version 7.8.3 and Cabal version 1.22.0.0.

Activity

  1. tibbe commented on Jan 12, 2015

    @tibbe
    Contributor

    /cc @benarmston

    On Mon, Jan 12, 2015 at 4:33 PM, Taylor Fausak [email protected]
    wrote:

    Running cabal format duplicates the build-depends section and duplicates
    dependencies in that section. For example, with this Cabal file:

    name: example
    version: 0
    cabal-version: >=1.22.0.0
    build-type: Simple
    license: MIT
    license-file: LICENSE.txt
    maintainer: Taylor Fausak [email protected]
    synopsis: TODO
    description:
    TODO
    category: Other

    library
    build-depends:
    base ==4.*
    default-language: Haskell2010

    Repeatedly running cabal format produces this:

    build-depends:
        base ==4.*
    build-depends:
        base ==4.*
    
    build-depends:
        base ==4.*,
        base ==4.*
    build-depends:
        base ==4.*,
        base ==4.*
    
    build-depends:
        base ==4.*,
        base ==4.*,
        base ==4.*,
        base ==4.*
    build-depends:
        base ==4.*,
        base ==4.*,
        base ==4.*,
        base ==4.*
    

    I would expect cabal format to not make any changes to the given Cabal
    file. I'm using GHC version 7.8.3 and Cabal version 1.22.0.0.

    —
    Reply to this email directly or view it on GitHub
    #2353.

  2. tfausak commented on Mar 6, 2015

    @tfausak
    CollaboratorAuthor

    I think the problem is in showGenericPackageDescription, but I'm not at all familiar with Cabal. I used this script to try some things out:

    import Distribution.ParseUtils (ParseResult (ParseOk))
    import Distribution.PackageDescription.Parse (parsePackageDescription)
    import Distribution.PackageDescription.PrettyPrint (showGenericPackageDescription)
    
    main :: IO ()
    main = case parsePackageDescription cabalFile of
        ParseOk _ package -> do
            print package
            putStrLn (showGenericPackageDescription package)
        _ -> return ()
    
    cabalFile :: String
    cabalFile = unlines
        [ "name: example"
        , "cabal-version: >=1.2"
        , "license: UnspecifiedLicense"
        , ""
        , "library"
        , "    build-depends:"
        , "        base -any"
        ]

    Running that gave me this output:

    GenericPackageDescription {packageDescription = PackageDescription {package = PackageIdentifier {pkgName = PackageName {unPackageName = "example"}, pkgVersion = Version {versionBranch = [], versionTags = []}}, license = UnknownLicense "UnspecifiedLicense", licenseFiles = [], copyright = "", maintainer = "", author = "", stability = "", testedWith = [], homepage = "", pkgUrl = "", bugReports = "", sourceRepos = [], synopsis = "", description = "", category = "", customFieldsPD = [], buildDepends = [], specVersionRaw = Right (UnionVersionRanges (ThisVersion (Version {versionBranch = [1,2], versionTags = []})) (LaterVersion (Version {versionBranch = [1,2], versionTags = []}))), buildType = Nothing, library = Nothing, executables = [], testSuites = [], benchmarks = [], dataFiles = [], dataDir = "", extraSrcFiles = [], extraTmpFiles = [], extraDocFiles = []}, genPackageFlags = [], condLibrary = Just (CondNode {condTreeData = Library {exposedModules = [], reexportedModules = [], requiredSignatures = [], exposedSignatures = [], libExposed = True, libBuildInfo = BuildInfo {buildable = True, buildTools = [], cppOptions = [], ccOptions = [], ldOptions = [], pkgconfigDepends = [], frameworks = [], cSources = [], jsSources = [], hsSourceDirs = [], otherModules = [], defaultLanguage = Nothing, otherLanguages = [], defaultExtensions = [], otherExtensions = [], oldExtensions = [], extraLibs = [], extraGHCiLibs = [], extraLibDirs = [], includeDirs = [], includes = [], installIncludes = [], options = [], profOptions = [], sharedOptions = [], customFieldsBI = [], targetBuildDepends = [Dependency (PackageName {unPackageName = "base"}) AnyVersion], targetBuildRenaming = fromList [(PackageName {unPackageName = "base"},ModuleRenaming True [])]}}, condTreeConstraints = [Dependency (PackageName {unPackageName = "base"}) AnyVersion], condTreeComponents = []}), condExecutables = [], condTestSuites = [], condBenchmarks = []}
    name: example
    cabal-version: >=1.2
    license: UnspecifiedLicense
    
    library
        build-depends:
            base -any
        build-depends:
            base -any
    
    
    

    The package description contains a lot of things, but this part looked interesting:

    targetBuildDepends = [Dependency (PackageName {unPackageName = "base"}) AnyVersion]
    

    There appears to only be one dependency. That tells me that it's being parsed correctly but it's being displayed incorrectly.

  3. tfausak commented on Apr 1, 2015

    @tfausak
    CollaboratorAuthor

    This still happens with cabal-install 1.22.0.1. From what I can tell, it only affects Cabal on OS X.

  4. tfausak commented on Apr 17, 2015

    @tfausak
    CollaboratorAuthor

    This does not happen anymore with cabal-install 1.22.2.0. One of these changes fixed it: cabal-install-v1.22.0.1...cabal-install-v1.22.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions