Repository navigation
Restore Hex code paths without calling into Hex - #1269
Merged
Merged
Conversation
Compiling prunes code paths, including the Hex archive's, so `mix do compile + deps.get` couldn't load Hex modules. The fix for that called Hex.Stdlib.ensure_application!/1 to restore the paths, but Hex.Stdlib is in the pruned archive and wasn't loaded yet, so it raised UndefinedFunctionError instead. Call Mix.ensure_application!/1 directly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Compiling on Elixir 1.15 and later prunes code paths, including the Hex archive's. #1118 restored them in
Hex.RemoteConverger.converge/2whenHex.Mixcouldn't be loaded, but it calledHex.Stdlib.ensure_application!/1, which is in the same pruned archive and isn't loaded at that point. Somix do compile + deps.getstill failed, withUndefinedFunctionErrorforHex.Stdlib.ensure_application!/1instead of theHex.Mixerror from #1109. This callsMix.ensure_application!/1directly. Elixir 1.15 added both the pruning and that function, so the call only runs where it exists.I checked it with archives built from
mainand from this branch, in a project depending on jason, on Elixir 1.20.4 / OTP 29.1.1.mix do compile + deps.get --check-lockedandmix do compile + deps.update jasonraise withmainand complete with this branch. There's no automated test because it needs an installed archive and a compile that prunes. CallingMix.ensure_application!(:hex)in Hex's own test VM would load modules from whichever Hex archive is installed.A failed resolution after
compilestill raisesProtocol.UndefinedError, because the project's consolidatedString.Charshas no impls for the vendored solver's structs. hexpm/hex_solver#60 fixes that and arrives with the next vendored hex_solver release.The
Code.ensure_loaded?(Hex.Mix)guard from #1118 stays. IfHex.Mixwas loaded before compiling, for example inmix do deps.get + compile + deps.get, the paths aren't restored, and a Hex module that wasn't loaded yet would still fail to load.