eksperimental
Version requirement to match X and version above, including prereleases
Hi eveyone,
I am looking to match all versions above 1.11 including 1.11.0-rc0, any idea how to achieve this?
iex(35)> Version.match?("1.11.0-rc1", "~> 1.11")
false
iex(36)> Version.match?("1.11.0-rc1", "~> 1.11", allow_pre: true)
false
iex(37)> Version.match?("1.11.0-rc1", ">= 1.11", allow_pre: true)
** (Version.InvalidRequirementError) invalid requirement: ">= 1.11"
(elixir 1.13.0-rc.1) lib/version.ex:433: Version.parse_requirement!/1
(elixir 1.13.0-rc.1) lib/version.ex:278: Version.match?/3
iex(37)> Version.match?("1.11.0-rc1", ">= 1.11.0", allow_pre: true)
false
iex(38)> Version.match?("1.11.0-rc1", ">= 1.11-0")
** (Version.InvalidRequirementError) invalid requirement: ">= 1.11-0"
(elixir 1.13.0-rc.1) lib/version.ex:433: Version.parse_requirement!/1
(elixir 1.13.0-rc.1) lib/version.ex:278: Version.match?/3
The only way to achieve this, is by using the lowest prerelease that I could come up with -0 which is a bit hackish but gets the job done.
iex(38)> Version.match?("1.11.0-rc1", ">= 1.11.0-0")
true
iex(39)> Version.match?("1.12.0", ">= 1.11.0-0")
true
iex(41)> Version.match?("1.11.0-rc1", "~> 1.11-0")
true
iex(41)> Version.match?("1.12.0", "~> 1.11-0")
true
Is there anything that I am missing?
Most Liked
dimitarvp
FWIW, I couldn’t make your examples work with Rust either – tried it as a sort of a sanity double-check.
use semver::*;
fn main() {
let req_a = VersionReq::parse(">=1.11.0-rc").unwrap();
let v0 = Version::parse("1.11.0-rc0").unwrap();
let v1 = Version::parse("1.11.0-rc1").unwrap();
println!("Does {} match {} ? => {}", v0, req_a, req_a.matches(&v0));
println!("Does {} match {} ? => {}", v1, req_a, req_a.matches(&v1));
}
That was the only way I could make it return true. All other variants – namely 1.11.0 and 1.11 – yielded false. (And their library doesn’t accept the ~> ... format)
1
kip
ex_cldr Core Team
I typically do it this way:
iex> Version.match?("1.11.0-rc1", "~> 1.11 or ~> 1.11-rc")
true
1
kip
ex_cldr Core Team
iex> Version.match?("1.11.0", "~> 1.11-rc")
true
You are right!!! Wonder why I didn’t notice that before.
1
Popular in Questions
** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2733ms. You can configure how long re...
New
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
After calling mix ecto.create I get this error:
17:00:32.162 [error] GenServer #PID<0.412.0> terminating
** (Postgrex.Error) FATAL...
New
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
Hi,
I’m quite new in Elixir and I’m trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and I...
New
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
I am trying to implement my new.html.eex file to create new posts on my website.
new.html.eex:
<h1>Create Post</h1>
<%= ...
New
I have VueJS GUIs with the project generated using Webpack.
I have Elixir modules that will need to be used by the VueJS GUIs.
I forese...
New
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
Lets say I have map like this fetching from my database
%{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
Other popular topics
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]
15:22:35.803 [error] gen_event {lager_file_backend...
New
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set?
Thanks.
New
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
New
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum.
...
New
Hey,
Just curious what are the main benefits of Elixir compared to Clojure?
When is Elixir more useful than Clojure and vice versa?
Th...
New
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
Credo is smart enough to check for (something like) this:
assert length(the_list) == 0
with this response:
Checking if an enum is empt...
New
Hi,
I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









