Skip to content

[BUG]: A distribution without a version, such as java@tem, fails with a Lua error #98

Closed

Description

@linghengqian

Version
vfox-java main (3b38e44) and v0.6.1, vfox 1.0.13

OS
Linux

Describe the bug
A version that names only the distribution stops the plugin with a Lua error. vfox install java@tem and vfox install java@temurin fail in PreInstall, and vfox use --global java@tem fails in PreUse:

$ vfox install java@tem
plugin [PreInstall] method error: ~/.vfox/plugin/java/lib/distribution_version.lua:79: attempt to index a non-table object(nil) with key 'match'
stack traceback:
	~/.vfox/plugin/java/lib/distribution_version.lua:79: in function 'convert_version_for_api'
	~/.vfox/plugin/java/lib/distribution_version.lua:134: in function 'parse_version'
	~/.vfox/plugin/java/hooks/pre_install.lua:29: in main chunk
	[G]: ?
failed to install java
$ vfox use --global java@tem
plugin [preUse] error: err:~/.vfox/plugin/java/lib/distribution_version.lua:79: attempt to index a non-table object(nil) with key 'match'
stack traceback:
	~/.vfox/plugin/java/lib/distribution_version.lua:79: in function 'convert_version_for_api'
	~/.vfox/plugin/java/lib/distribution_version.lua:134: in function 'parse_version'
	~/.vfox/plugin/java/hooks/pre_use.lua:20: in main chunk
	[G]: ?

A .sdkmanrc holding java=tem selects nothing, even with 21.0.8+9-tem installed. ParseLegacyFile raises the same error there, and vfox env -s bash exits 0 without printing it. The v0.6.1 release zip fails the same way, at lines 66 and 121 of lib/distribution_version.lua.

When the name has no version part, parse_version takes it as the distribution and leaves version nil:

if not version_parts[2] then
-- no parts, check if we got a distribution name without version
distribution = distribution_version.parse_distribution(version_parts[1])
if not distribution then
-- no valid distribution found, handle as version with distribution "openjdk"
version = version_parts[1]
distribution = distribution_version.parse_distribution("openjdk")
end

It then hands that nil to convert_version_for_api, added in #57, which calls version:match:

-- Convert version format for Foojay API
version = distribution_version.convert_version_for_api(version)

function distribution_version.convert_version_for_api(version)
-- Handle EA version format: "X.ea.Y" -> "X-ea+Y"
local ea_version, ea_build = version:match("^(%d+)%.ea%.(%d+)$")

Skipping the conversion when there is no version does not fix vfox install. With that change PreInstall fails the same way at lib/foojay.lua:77, which also expects a version:

local latest = version:match("^%d+$") and "&latest=available" or ""

So java@tem needs either an error that asks for a version or a defined meaning, such as the newest release of that distribution.

Found while working on #91.

Activity

  1. linghengqian commented on Oct 18, 2026

    @linghengqian
    MemberAuthor
    • I am working on the current issue.
  2. self-assigned this
    on Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions