I am using alternative version numbering approach for my projects. I have encountered strange behavior by cabal
and stack
that does not allow me to fully enjoy benefits of this approach. Both cabal
and stack
enforce version to be of format Int
.Int
.Int
, which does not cover the case of another version format I use for branches (0.x.x
, 1.x.x
, 1.0.x
, etc).
If I have line version: 0.x.x
in my .cabal
file, I am getting Parse of field 'version' failed.
error when running cabal build
or Unable to parse cabal file {PROJECT_NAME}.cabal: NoParse "version" 5
when running stack init
.
Is there a way to disable version parsing on cabal
and stack
commands? Is there a flag for it? Or do I have to request this kind of change (adding flags, disabling version parsing) from the developers of cabal
and stack
?
Why is there any parsing at all? How does it help with building a package? Does cabal
or stack
automatically increment build numbers on some event? If yes, where could I read more about this? How could I influence the way version numbering incrementation gets implemented in cabal
and stack
? I want developers of haskell packages take into account the possibility of alternative version numbering approaches.
PS. For all interested folks, I want to quickly summarize the idea behind "weird" version numbers, such as 0.x.x
, 1.x.x
, 1.0.x
. I use the version numbers with x
's to describe streamlines of development that allow code changes while such version numbers as 1.0.0
, 1.1.0
, 2.35.46
are used to describe frozen states of development (to be precise, they are used for released versions of software). Note that such version numbers as 0.x.0
, 1.x.15
, 2.x.23
are also possible (used for snapshots/builds of software) and they mean that codebase has been inherited from branches with version numbers 0.x.x
, 1.x.x
and 2.x.x
correspondingly.
Why do I need such version numbers as 0.x.x
, 1.x.x
and 2.x.x
at all? In brief, different number of x
's mean branches of different types. For example, version number pattern N.x.x
is used for support branches, while pattern N.M.x
is used for release branches. Idea behind support branches is that they get created due to incompatibility of the corresponding codebases. Release branches get created due to feature freeze in corresponding codebase. For example, branches 1.0.x
, 1.1.x
, 1.2.x
, ... get created as a result of feature freezes (or releases) in branch 1.x.x
.
I know this is all confusing, but I worked hard to establish this version numbering approach and I continue working on awareness about the inconsistencies of version numbering through my presentations and other projects. This all makes sense once you think more about the pitfalls of semver approach (you can find detailed slideshare presentation on the matter following the link). But I do not want to defend it for now. For the time being, I just want cabal
and stack
to stop enforcing their, as I perceive them, unjustified rules to my project. Hope you can help me with that.
Is there a way to disable version parsing on cabal and stack commands? Is there a flag for it?
No.
Or do I have to request this kind of change (adding flags, disabling version parsing) from the developers of
cabal
andstack
?
You can of course ask, but there are so many outstanding issues that you are unlikely to get any traction. You will have to be very convincing -- convincing enough to overturn more than 20 years of experience that says the current versioning scheme is basically workable. Realistically, if you want this to happen you'll probably have to maintain a fork of these tools yourself, and provide an alternative place to host packages using this scheme.
Why is there any parsing at all? How does it help with building a package?
Packages specify dependencies, and for each dependency, specify what version ranges they work with. The build tools then use a constraint solver to choose a coherent set of package/version pairs to satisfy all the (transitive) dependencies. To do this, they must at a minimum be able to check whether a given version is in a given range -- which requires parsing the version number at least a little bit.
Does cabal or stack automatically increment build numbers on some event? If yes, where could I read more about this?
There is nothing automatic. But you should take a look at the Package Version Policy, which serves as a social contract between package maintainers. It lets one package maintainer say, "I am using bytestring
version 0.10.0.1
and it seems to work. I'm being careful about qualifying all my bytestring
imports; therefore I can specify a range like >=0.10 && <0.11
and be sure that things will just work, while giving the bytestring
maintainer the ability to push security and efficiency updates to my users." without having to pore through the full documentation of bytestring
and hope its maintainer had written about what his version numbers mean.
How could I influence the way version numbering incrementation gets implemented in cabal and stack?
As with your previous question about changing the way the community does things, I think modifications to the Package Versioning Policy are going to be quite difficult, especially changes as radical as you seem to be proposing here. The more radical the change, the more carefully motivated it will have to be to gain traction.
I honestly don't know what a reasonable place to take such motivation and discussion would be; perhaps the haskell-cafe mailing list or similar.