Skip to content

Fix windows cache_dir path #4377

Open
rasapala wants to merge 2 commits into
mainfrom
fix_cache_dir_win
Open

Fix windows cache_dir path #4377
rasapala wants to merge 2 commits into
mainfrom
fix_cache_dir_win

Conversation

@rasapala

Copy link
Copy Markdown
Collaborator

🛠 Summary

JIRA CVS-187603
Normalize path and add test.

🧪 Checklist

  • Unit tests added.
  • The documentation updated.
  • Change follows security best practices.
    ``

Copilot AI review requested due to automatic review settings July 16, 2026 10:39
@rasapala
rasapala requested review from atobiszei and mzegla July 16, 2026 10:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses Windows-specific path handling issues by normalizing backslashes to forward slashes for the CACHE_DIR plugin configuration when exporting graphs, and adds a unit test to prevent regressions. It also updates the Windows environment setup script to better propagate environment variables to the caller.

Changes:

  • Normalize Windows path separators for CACHE_DIR in GraphExport::createPluginString() (both when provided via manualString and via pluginConfig.cacheDir).
  • Add a Windows-only unit test validating that CACHE_DIR is serialized without backslashes.
  • Update windows_setupvars.bat control flow to propagate selected environment variables back to the calling shell and handle setup failures.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
windows_setupvars.bat Adjusts error handling and propagates selected environment variables to the caller session.
src/test/graph_export_test.cpp Adds a Windows-only unit test ensuring CACHE_DIR is normalized to forward slashes in the generated plugin config JSON.
src/graph_export/graph_export.cpp Introduces path-separator normalization helper and applies it to CACHE_DIR handling in plugin config generation/parsing.

Comment thread windows_setupvars.bat Outdated
Comment thread windows_setupvars.bat
Comment on lines +101 to +109
static std::string normalizeWindowsPathSeparators(const std::string& path) {
#ifdef _WIN32
std::string normalized = path;
std::replace(normalized.begin(), normalized.end(), '\\', '/');
return normalized;
#else
return path;
#endif
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we have some utils function for that already? Looks like a fairly common logic.

Comment on lines +675 to +681
// plugin_config is injected into pbtxt and later parsed as JSON again.
// Normalize Windows path separators to avoid backslash escape ambiguity.
auto cacheDirIt = d.FindMember("CACHE_DIR");
if (cacheDirIt != d.MemberEnd() && cacheDirIt->value.IsString()) {
auto normalizedCacheDir = normalizeWindowsPathSeparators(cacheDirIt->value.GetString());
cacheDirIt->value.SetString(normalizedCacheDir.c_str(), static_cast<rapidjson::SizeType>(normalizedCacheDir.size()), d.GetAllocator());
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we doing it here and not through pluginConfig.cacheDir.has_value() like for kvCachePrecision below?

@atobiszei

Copy link
Copy Markdown
Collaborator

The --cache_dir would propagate to classic models when using config.json if I recall correctly. Fix in graph_export would resolve the issue with OVMS started with single GenAI model. It won't work with --config_path i guess?
Is the fix with plugin config handling generic (ie does the issue exist also for non text GenAI models? Speech/Image gen).

@dtrawins dtrawins modified the milestones: 2026.0, 2026.3 Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants