hexpm / hex

Package manager for the Erlang ecosystem.
https://hex.pm
969 stars 184 forks source link

Crash in Hex.Mix.to_lock #971

Closed lukaszsamson closed 1 year ago

lukaszsamson commented 1 year ago

elixir: 1.14.1 hex: 2.0.0

Unfortunately I don't remember what I was doing but hex crashed with

Process #PID<0.398.0> raised an exception
** (Protocol.UndefinedError) protocol String.Chars not implemented for %Hex.Solver.Constraints.Range{min: %Version{major: 0, minor: 2, patch: 0}, max: %Version{major: 0, minor: 3, patch: 0, pre: [0]}, include_min: true, include_max: false} of type Hex.Solver.Constraints.Range (a struct). This protocol is implemented for the following type(s): Atom, BitString, Date, DateTime, Float, Integer, List, NaiveDateTime, Time, URI, Version, Version.Requirement
    (elixir 1.14.1) lib/string/chars.ex:3: String.Chars.impl_for!/1
    (elixir 1.14.1) lib/string/chars.ex:22: String.Chars.to_string/1
    (hex 2.0.0) lib/hex/mix.ex:168: Hex.Mix.registry_dep_to_def/1
    (elixir 1.14.1) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2
    (hex 2.0.0) lib/hex/mix.ex:120: anonymous fn/1 in Hex.Mix.to_lock/1
    (elixir 1.14.1) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2
    (elixir 1.14.1) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2
    (elixir 1.14.1) lib/map.ex:263: Map.new_from_enum/2

This is strange as there is an implementation https://github.com/hexpm/hex/blob/50acd48457a726ecc9930099d5dcb324e16efa6c/lib/hex/solver/constraints/range.ex#L431

ericmj commented 1 year ago

We have not been able to reproduce this and haven't received any other reports so I am closing it.

A similar issue was recently fixed but it was introduced in Elixir 1.15.0-dev so probably not related. Since it's a missing protocol implementation I am guessing it has something to do with the code path to the consolidated protocols since archives are not consolidated.