Skip to content
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

Cabal format duplicates dependencies #2353

Closed
tfausak opened this issue Jan 12, 2015 · 4 comments
Closed

Cabal format duplicates dependencies #2353

tfausak opened this issue Jan 12, 2015 · 4 comments

Comments

@tfausak
Copy link
Collaborator

tfausak commented Jan 12, 2015

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.

@tibbe
Copy link
Member

tibbe commented Jan 12, 2015

/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.

@tfausak
Copy link
Collaborator Author

tfausak commented Mar 6, 2015

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.

@tfausak
Copy link
Collaborator Author

tfausak commented Apr 1, 2015

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

@tfausak
Copy link
Collaborator Author

tfausak commented Apr 17, 2015

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants