JanDeDobbeleer/oh-my-posh · warning

empty m_EditorVersion

Error message

empty m_EditorVersion

What it means

The unity segment reads ProjectSettings/ProjectVersion.txt to report the Unity editor version. GetUnityVersion parses lines looking for the m_EditorVersion prefix; if the prefixed line exists but the remainder is empty after trimming, it throws 'empty m_EditorVersion'. The file exists and has the key but no value.

Source

Thrown at src/segments/unity.go:76

	if !u.env.HasFilesInDir(projectDir.Path, "ProjectVersion.txt") {
		log.Debug("no ProjectVersion.txt file found")
		return "", err
	}

	versionFilePath := filepath.Join(projectDir.Path, "ProjectVersion.txt")
	versionFileText := u.env.FileContent(versionFilePath)

	lines := strings.SplitSeq(versionFileText, "\n")
	versionPrefix := "m_EditorVersion: "
	for line := range lines {
		if !strings.HasPrefix(line, versionPrefix) {
			continue
		}
		version := strings.TrimPrefix(line, versionPrefix)
		version = strings.TrimSpace(version)
		if version == "" {
			return "", errors.New("empty m_EditorVersion")
		}
		fIndex := strings.Index(version, "f")
		if fIndex > 0 {
			return version[:fIndex], nil
		}
		return version, nil
	}

	return "", errors.New("ProjectSettings/ProjectVersion.txt is missing m_EditorVersion")
}

const (
	csharp6  = "C# 6"
	csharp73 = "C# 7.3"
	csharp8  = "C# 8"
	csharp9  = "C# 9"
)

View on GitHub (pinned to 0976794618)

Solutions

  1. Open the project in Unity (or run it) so ProjectVersion.txt is rewritten correctly
  2. Restore ProjectVersion.txt from version control (git checkout -- ProjectSettings/ProjectVersion.txt)
  3. Manually set the value, e.g. `m_EditorVersion: 2022.3.10f1`
  4. Disable the unity segment when not inside a valid Unity project

Example fix

// before: ProjectSettings/ProjectVersion.txt
m_EditorVersion:
// after
m_EditorVersion: 2022.3.10f1
Defensive patterns

Strategy: validation

Validate before calling

// before parsing, validate the file content
data, err := os.ReadFile("ProjectSettings/ProjectVersion.txt")
valid := err == nil && strings.TrimSpace(strings.TrimPrefix(strings.TrimSpace(string(data)), "m_EditorVersion:")) != ""

Prevention

When it happens

Trigger: Enabled calls GetUnityVersion while in a Unity project directory and ProjectSettings/ProjectVersion.txt contains a line starting with `m_EditorVersion:` (or the configured prefix) whose value is empty or only whitespace — typically a truncated or interrupted project serialization.

Common situations: Unity crashed or was killed mid-write leaving an incomplete ProjectVersion.txt; the file was hand-edited or diff-merged badly; a git LFS checkout produced an empty value; working in a partially initialized project folder.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of JanDeDobbeleer/oh-my-posh@0976794618 (2026-08-31). Data as JSON: /api/errors/cfa0b5cc31b5eccc. Report an issue: GitHub.