Fix parsing when an artifact id is a Maven scope/type keyword#110
Open
soutaro wants to merge 1 commit into
Open
Fix parsing when an artifact id is a Maven scope/type keyword#110soutaro wants to merge 1 commit into
soutaro wants to merge 1 commit into
Conversation
A dependency:list line is groupId:artifactId:type[:classifier]:version:scope:/path/to/file Fields were located by matching a keyword against the whole line, which picks the wrong colon when the artifact id itself equals a scope/type keyword (runtime, compile, test, provided, system, jar, pom). For com.dylibso.chicory:runtime the gav became com.dylibso.chicory:jar:1.7.5, producing a broken require_jar line (LoadError at runtime); the scope and system flag were likewise misdetected. Peel off the trailing file path first (it may contain a ':' on Windows, C:\...) via a single match, then split the remaining colon-clean coordinate once and address every field by position: type is field 3, version is last, an extra field between them is the classifier, scope is last. gav and coord are rebuilt from those parts. This removes the keyword regexes entirely and also handles an artifact id equal to the type itself. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
kares
self-requested a review
July 16, 2026 06:27
kares
approved these changes
Jul 16, 2026
kares
left a comment
Member
There was a problem hiding this comment.
This is a valid bug and the fix seems to work (tests pass), thank you Soutaro.
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.
Jars::Installer::Dependencygenerated a brokenrequire_jarline for any artifact whose artifact id equals a Maven scope/type keyword (runtime,compile,test,provided,system,jar,pom).For
com.dylibso.chicory:runtimeit produced:The generated
*_jars.rbthen failed at runtime withLoadError: cannot load such file -- com/dylibso/chicory/jar/1.7.5/jar-1.7.5.jar, breaking any gem that depends on such a jar (e.g.com.dylibso.chicory:runtime).Root cause
A
dependency:listline has the form:
groupId:artifactId:type[:classifier]:version:scope:/path/to/file Several fields were located by matching a keyword against the whole line:
@gav = @coord.sub(REG, ':'), whereREGalso lists the scope keywords, soString#subreplaced the leftmost match — the artifact id (:runtime:) — instead of the type separator (:jar:).scopeand thesystem?flag were derived fromcase line when /:test:/ …andline.index(':system:'), which matched a keyword artifact id rather than the real scope field.Because
sub/indexmatch the leftmost occurrence, any artifact id that happens to be a keyword corrupts the result.Fix
Parse positionally instead of by keyword matching:
:on Windows,C:\…) with a singlematchonTRAILING_FILE.typeis field 3,versionis last, an extra field between them is the classifier,scopeis last.coord/gavfrom those parts.This removes the keyword regexes entirely and also fixes the case where the artifact id equals the type itself (
jar/pom).