Skip to content

Conversation

@ilyam8
Copy link
Member

@ilyam8 ilyam8 commented Dec 11, 2025

Summary

This PR fixes incorrect plugin and binary paths on Windows installations.

Linux packages embed absolute paths in buildinfo (e.g. /usr/libexec/netdata/plugins.d). On Windows, however, the actual install prefix is determined at installation time (e.g. C:\Program Files\Netdata...), so the embedded absolute paths become invalid.

Solution

At startup, when running on Windows:

  1. Normalize executable.Directory and buildinfo.PluginsDir to forward-slash form (using filepath.ToSlash) so suffix matching is reliable.
  2. Check whether the executable lives inside the PluginsDir suffix.
  3. If yes, strip the suffix to recover the actual installation prefix.
  4. Rewrite: PluginsDir, NetdataBinDir, UserConfigDir, StockConfigDir.

Example:

  • Raw Windows executable directory:
C:\Program Files\Netdata\usr\libexec\netdata\plugins.d\go.d.plugin
  • Normalized for comparison:
C:/Program Files/Netdata/usr/libexec/netdata/plugins.d/go.d.plugin
  • Build-time PluginsDir suffix (normalized):
/usr/libexec/netdata/plugins.d
  • Suffix removal:
"C:/Program Files/Netdata/usr/libexec/netdata/plugins.d"
minus
"/usr/libexec/netdata/plugins.d"
=
"C:/Program Files/Netdata"
  • Final install prefix:
C:\Program Files\Netdata
Test Plan
Additional Information
For users: How does this change affect me?

Summary by cubic

Fixes invalid install paths on Windows by deriving the install prefix at runtime and rewriting buildinfo paths. Plugins and binaries now resolve correctly on Windows; no changes on Linux/macOS.

  • Bug Fixes
    • Detect Windows install prefix from the running executable directory when it matches the build-time PluginsDir suffix.
    • Rewrite UserConfigDir, StockConfigDir, PluginsDir, and NetdataBinDir using the detected prefix plus relative paths.
    • Skip rewriting when not on Windows or when layout doesn’t match (safe for dev/test).

Written for commit ea8f9d6. Summary will update automatically on new commits.

@github-actions github-actions bot added area/collectors Everything related to data collection collectors/go.d area/go labels Dec 11, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

Copy link
Contributor

Copilot AI left a comment

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 fixes incorrect plugin and binary paths on Windows installations by detecting the actual install prefix at runtime and rewriting buildinfo paths accordingly. Linux packages use embedded absolute paths that work out-of-the-box, but Windows installations have variable prefixes (e.g., "C:\Program Files\Netdata") determined at install time, making the embedded Unix-style paths invalid.

Key changes:

  • Added Windows-specific init() function in buildinfo package to detect and rewrite installation paths at runtime
  • Changed buildinfo logging from Debug to Info level for better visibility of path configuration

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/go/pkg/buildinfo/buildinfo.go Implements Windows install prefix detection and path rewriting logic in init() function using suffix matching and path normalization
src/go/cmd/godplugin/main.go Elevates buildinfo logging from Debug to Info level for better visibility of runtime-detected paths

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ilyam8 ilyam8 force-pushed the fix-go.d-install-path branch from ea8f9d6 to 8e882c1 Compare December 11, 2025 17:10
@ilyam8 ilyam8 enabled auto-merge (squash) December 11, 2025 17:13
@ilyam8 ilyam8 merged commit 539f59e into netdata:master Dec 11, 2025
230 of 242 checks passed
@ilyam8 ilyam8 deleted the fix-go.d-install-path branch December 11, 2025 17:14
stelfrag pushed a commit to stelfrag/netdata that referenced this pull request Dec 11, 2025
@stelfrag stelfrag mentioned this pull request Dec 11, 2025
Ferroin pushed a commit that referenced this pull request Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/collectors Everything related to data collection area/go collectors/go.d

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants