Closed fenollp closed 6 years ago
Erlang.mk will need to be patched. I'm not familiar with this version syntax thing but it can probably be handled easily during autopatch.
Cool so since erlang.mk doesn’t fetch/parse/talk to hex.pm to discover the versions of a package that exist then a constraint format that would satisfy all 3 tools is "~>X.Y.Z"
.
This format is accepted by rebar3 (so says CI).
Erlang.mk would need a simple patch to check format then drop ~>
before fetching package.
Now I don’t know if Mix handles this format (the Z part may be an issue). Can anyone try it?
Thanks
Mix accepts the ~> x.y.z format but the correct way to specify the requirement would be ~> x.y according to semver.
Rebar3 hex will switch to default ~> x.y
when unspecified.
Best to do the same in certifi
. If erlang.mk
wants to support dependencies that use hex deps it can do so by resolving them like the rest of the clients. Or if erlang.mk really didn't want to support hex it could parse the rebar.lock file for the full version string, it is expected users commit those, though it isn't guaranteed.
Sounds like rebar.lock is the way to go. Thanks for the tip.
Like I've said in the past, I don't want to write a third incompatible hex package manager. We already have enough issues with different versions being selected by rebar3/mix when working on an Elixir project with mix and then depending on it via rebar3. If we had an actual package manager for the whole ecosystem erlang.mk would already use it. For the time being I'm settling for maintaining compatibility with existing projects.
@fenollp Can you open a ticket? And as a workaround for now you don't need certifi to have dependencies specified as x.y.z
or ~>x.y.z
, you can just add the version you want as a BUILD_DEPS
of the top level project and we can work on a fix later.
Rebar3 and Mix resolve dependencies differently. There can not be a tool that gives the same result to be used by each of them, they are not and will not be compatible, so this single "package [resolver]" will never exist.
Yeah well, this issue doesn’t concern me: I use rebar3. So I’m not pushing a Makefile to certifi that imports erlang.mk and duplicates the versioned deps. To me the most simple way to make everyone happy here is the 2 line fix in mk to handle ~>X.YZ. I am not opening a ticket come on
Hrmm, just to confirm then both rebar3 and mlix able to resolve a dependency using such format {"parse_trans, "~>3.2"}
, (@ericmj @tsloughter ) but erlang.mk isn't (@essen ) ? That starts to be complicated... At least even if the resolving is different I would expect that all tools could handle the hex.pm api and package name resolving the same way :/
I agree that the patch from @fenollp is the correct solution for now, it should handle the initial issue spotted by @ericmj, isn't it? Question now is if it can work with erlang.mk .Another way is to just resolve on ~>3.2
and add a rebar.config.script for erlang.mk to override the dependency. @essen is there a way to detect erlang.mk is used from the environment?
Thinking more of it @essen if we publish with the rebar.lock would it work? Would erlang.mk uses it to fetch the dependencies? Does it execute the rebar command for it?
I'm tempted to revert to our own custom parse transform and keep the deterministic
flag to make it simpler for all including that lib already. That change appear to not be that easy to be handled in a timely fashion. @fenollp what would we lost in doing it?
Yeah well, this issue doesn’t concern me: I use rebar3.
Ah sorry looks like I missed the original thread. I'll forward my comments there.
@benoitc Don't worry about it, there is a very easy workaround so just do the ideal changes for your usage and I'll make it work again.
Like I've said in the past, I don't want to write a third incompatible hex package manager. We already have enough issues with different versions being selected by rebar3/mix when working on an Elixir project with mix and then depending on it via rebar3. If we had an actual package manager for the whole ecosystem erlang.mk would already use it. For the time being I'm settling for maintaining compatibility with existing projects.
We are working on an erlang library with shared functionality for implementing Hex package managers: https://github.com/wojtekmach/hex_erl. We are starting out with support for the HTTP API, building/unpacking/verifying package tarballs, and fetching/reading the registry. We will add more to this library as time goes on, for example the dependency resolver algorithm. But as @tsloughter said it may be that you don't want to use the same resolution algorithm that mix/hex does so the library will be plug-and-play where you can chose to use the parts that you want to use. I'm not sure how an erlang library will work with erlang.mk since it's based on makefiles but there's probably something we can figure out, maybe give it an escript frontend you can call.
Unfortunately there is not a single package manager we can build that will work for all build tools since their dependency handling works completely differently.
Hrmm, just to confirm then both rebar3 and mlix able to resolve a dependency using such format {"parse_trans, "~>3.2"}
Yes, this format will work for both rebar3 and mix and it's the format that is best suited for semver.
@fenollp can you update the PR to use {"parse_trans, "~>3.2"}
? I will do a release right after and document it.
I'm not sure how an erlang library will work with erlang.mk since it's based on makefiles but there's probably something we can figure out, maybe give it an escript frontend you can call.
Like any other Erlang libraries. You don't need to do anything, it's trivial for erlang.mk to use Erlang code. The autopatch functionality for rebar compatibility is written in Erlang and uses some code from rebar2 for example. This would be no different, so don't worry about it.
Sounds good. I will happily use this along with the dependency resolver algorithm in Erlang.mk once it's available. I'm guessing I can easily make it so that hex dependencies follow the hex rules, and other dependencies (git, etc.) can continue following what Erlang.mk is doing (first fetched wins).
All tools not having the same rules is unfortunate to say the least but this is a step in the right direction and at least this will mean that someone using Erlang.mk with only hex deps will end up with the same dependencies as someone using mix, so that's already something.
I hope there'll be some kind of announcement once the dependency resolver bits are in. Cheers.
rebar3 appears to be handling tildes the same as Mix.
Also now that I read the docs on ~>
, ~>X.Y.Z
is too restrictive.
There's apparently a workaround for erlang.mk projects and there will be a patch in the future, so I'm just going to update PR to say ~>X.Y
.
Done. BTW @benoitc could you activate TravisCI for this project? EDIT: then we could setup a Travis cron task to build master!
@fenollp thanks. CI is enabled now: https://travis-ci.org/certifi/erlang-certifi/builds/348220536
Thanks!
Continuation of https://github.com/certifi/erlang-certifi/pull/25 which itself is a solution to https://github.com/benoitc/hackney/issues/484 Discussion from https://github.com/certifi/erlang-certifi/pull/25#issuecomment-369590347 So this PR is looking to please rebar3, Mix & erlang.mk dependency handling.
It seems the
~>X.Y.Z
or~>X.Y
format pleases both Mix and rebar3. However erlang.mk does not like this format. @essen Do you think it would be reasonable for erlang.mk to support~>X.Y.Z
as if it was justX.Y.Z
? I am not even sure that is acceptable by Mix! Otherwise I don't see an easy fix to this issue and that makes using BEAM libs across languages not easy, at least if erlang.mk is concerned.Note: erlang.mk fails to build with
cc @ericmj cc
top @github/erlang/rebar3
: @tsloughter @tuncer @ferd