summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/dc/dcgm/fix-paths.patch
blob: 86581f40698681814a085058d1849a4cad6ec029 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
diff --git a/common/LsHw.cpp b/common/LsHw.cpp
index 8d0f35cd89..12fe26957f 100644
--- a/common/LsHw.cpp
+++ b/common/LsHw.cpp
@@ -145,7 +145,7 @@
 {
     static std::string const cmd = "lshw -json";
     std::string cmdOutput;
-    static std::array<std::string, 2> const cmdPathPrefix { "/usr/bin/", "/usr/sbin/" };
+    static std::array<std::string, 1> const cmdPathPrefix { "@lshw@/bin/" };
 
     dcgmReturn_t result = DCGM_ST_OK;
     for (auto const &prefix : cmdPathPrefix)
@@ -162,4 +162,4 @@
     }
 
     return cmdOutput;
-}
\ No newline at end of file
+}
diff --git a/common/tests/LsHwTests.cpp b/common/tests/LsHwTests.cpp
index edb65e599e..5950fb8d9e 100644
--- a/common/tests/LsHwTests.cpp
+++ b/common/tests/LsHwTests.cpp
@@ -609,7 +609,7 @@
         std::unique_ptr<MockRunningUserChecker> checker = std::make_unique<MockRunningUserChecker>();
         checker->MockIsRoot(true);
         std::unique_ptr<MockRunCmdHelper> runCmdHelper = std::make_unique<MockRunCmdHelper>();
-        runCmdHelper->MockCmdOutput("/usr/bin/lshw -json", DCGM_ST_OK, lshwMultipleCpusAbridgedValidJson);
+        runCmdHelper->MockCmdOutput("@lshw@/bin/lshw -json", DCGM_ST_OK, lshwMultipleCpusAbridgedValidJson);
 
         LsHw lshw;
         lshw.SetChecker(std::move(checker));
@@ -626,7 +626,7 @@
         std::unique_ptr<MockRunningUserChecker> checker = std::make_unique<MockRunningUserChecker>();
         checker->MockIsRoot(true);
         std::unique_ptr<MockRunCmdHelper> runCmdHelper = std::make_unique<MockRunCmdHelper>();
-        runCmdHelper->MockCmdOutput("/usr/bin/lshw -json", DCGM_ST_OK, lshwSingleCpuAbridgedValidJson);
+        runCmdHelper->MockCmdOutput("@lshw@/bin/lshw -json", DCGM_ST_OK, lshwSingleCpuAbridgedValidJson);
 
         LsHw lshw;
         lshw.SetChecker(std::move(checker));
@@ -642,7 +642,7 @@
         std::unique_ptr<MockRunningUserChecker> checker = std::make_unique<MockRunningUserChecker>();
         checker->MockIsRoot(true);
         std::unique_ptr<MockRunCmdHelper> runCmdHelper = std::make_unique<MockRunCmdHelper>();
-        runCmdHelper->MockCmdOutput("/usr/bin/lshw -json", DCGM_ST_OK, lshwSingleCpuNoSerialNumberAbridgedValidJson);
+        runCmdHelper->MockCmdOutput("@lshw@/bin/lshw -json", DCGM_ST_OK, lshwSingleCpuNoSerialNumberAbridgedValidJson);
 
         LsHw lshw;
         lshw.SetChecker(std::move(checker));
@@ -658,7 +658,7 @@
         std::unique_ptr<MockRunningUserChecker> checker = std::make_unique<MockRunningUserChecker>();
         checker->MockIsRoot(true);
         std::unique_ptr<MockRunCmdHelper> runCmdHelper = std::make_unique<MockRunCmdHelper>();
-        runCmdHelper->MockCmdOutput("/usr/bin/lshw -json", DCGM_ST_OK, lshwSingleNonNvidiaCpuAbridgedValidJson);
+        runCmdHelper->MockCmdOutput("@lshw@/bin/lshw -json", DCGM_ST_OK, lshwSingleNonNvidiaCpuAbridgedValidJson);
 
         LsHw lshw;
         lshw.SetChecker(std::move(checker));
@@ -673,7 +673,7 @@
         std::unique_ptr<MockRunningUserChecker> checker = std::make_unique<MockRunningUserChecker>();
         checker->MockIsRoot(true);
         std::unique_ptr<MockRunCmdHelper> runCmdHelper = std::make_unique<MockRunCmdHelper>();
-        runCmdHelper->MockCmdOutput("/usr/bin/lshw -json", DCGM_ST_OK, lshwIncorrectIdValueTypeJson);
+        runCmdHelper->MockCmdOutput("@lshw@/bin/lshw -json", DCGM_ST_OK, lshwIncorrectIdValueTypeJson);
 
         LsHw lshw;
         lshw.SetChecker(std::move(checker));
@@ -687,7 +687,7 @@
         std::unique_ptr<MockRunningUserChecker> checker = std::make_unique<MockRunningUserChecker>();
         checker->MockIsRoot(true);
         std::unique_ptr<MockRunCmdHelper> runCmdHelper = std::make_unique<MockRunCmdHelper>();
-        runCmdHelper->MockCmdOutput("/usr/bin/lshw -json", DCGM_ST_OK, lshwMissingCpuJson);
+        runCmdHelper->MockCmdOutput("@lshw@/bin/lshw -json", DCGM_ST_OK, lshwMissingCpuJson);
 
         LsHw lshw;
         lshw.SetChecker(std::move(checker));
@@ -702,7 +702,7 @@
         std::unique_ptr<MockRunningUserChecker> checker = std::make_unique<MockRunningUserChecker>();
         checker->MockIsRoot(true);
         std::unique_ptr<MockRunCmdHelper> runCmdHelper = std::make_unique<MockRunCmdHelper>();
-        runCmdHelper->MockCmdOutput("/usr/bin/lshw -json", DCGM_ST_OK, lshwBadSyntaxJson);
+        runCmdHelper->MockCmdOutput("@lshw@/bin/lshw -json", DCGM_ST_OK, lshwBadSyntaxJson);
 
         LsHw lshw;
         lshw.SetChecker(std::move(checker));
@@ -716,6 +716,7 @@
 {
     SECTION("Will try /usr/sbin/")
     {
+        SKIP("Nixpkgs patches this out");
         std::unique_ptr<MockRunningUserChecker> checker = std::make_unique<MockRunningUserChecker>();
         checker->MockIsRoot(true);
         std::unique_ptr<MockRunCmdHelper> runCmdHelper = std::make_unique<MockRunCmdHelper>();
@@ -730,4 +731,4 @@
         REQUIRE(cpuSerials.value()[0] == "0x000000017820B1C80400000015FF81C0");
         REQUIRE(cpuSerials.value()[1] == "0x000000017820B1C8040000000A0200C0");
     }
-}
\ No newline at end of file
+}
diff --git a/modules/diag/DcgmDiagManager.cpp b/modules/diag/DcgmDiagManager.cpp
index d0a75dcede..ccd4347719 100644
--- a/modules/diag/DcgmDiagManager.cpp
+++ b/modules/diag/DcgmDiagManager.cpp
@@ -253,7 +253,7 @@
     int result;
 
     // Default NVVS binary path
-    cmd = "/usr/libexec/datacenter-gpu-manager-4/nvvs";
+    cmd = "@dcgm_out@/libexec/datacenter-gpu-manager-4/nvvs";
 
     // Check for NVVS binary path enviroment variable
     value = std::getenv("NVVS_BIN_PATH");
diff --git a/modules/mndiag/dcgm_mndiag_structs.hpp b/modules/mndiag/dcgm_mndiag_structs.hpp
index 40e61a8fd0..7e43ce8bed 100644
--- a/modules/mndiag/dcgm_mndiag_structs.hpp
+++ b/modules/mndiag/dcgm_mndiag_structs.hpp
@@ -33,8 +33,8 @@
 constexpr std::string_view ENV_ALLOW_RUN_AS_ROOT = "DCGM_MPIRUN_ALLOW_RUN_AS_ROOT";
 
 // Default paths
-constexpr std::string_view DEFAULT_MPIRUN_PATH     = "/usr/bin/mpirun";
-constexpr std::string_view DEFAULT_MNUBERGEMM_PATH = "/usr/libexec/datacenter-gpu-manager-4/plugins/cuda12/mnubergemm";
+constexpr std::string_view DEFAULT_MPIRUN_PATH     = "@mpi@/bin/mpirun";
+constexpr std::string_view DEFAULT_MNUBERGEMM_PATH = "@dcgm_out@/libexec/datacenter-gpu-manager-4/plugins/cuda12/mnubergemm";
 } //namespace MnDiagConstants
 
 // Message types
diff --git a/modules/mndiag/tests/MnDiagManagerTests.cpp b/modules/mndiag/tests/MnDiagManagerTests.cpp
index 40dbda3b72..5ec8dafa1c 100644
--- a/modules/mndiag/tests/MnDiagManagerTests.cpp
+++ b/modules/mndiag/tests/MnDiagManagerTests.cpp
@@ -2228,7 +2228,7 @@
         mockStateMachine->SetMnubergemmPathCallback([&capturedPath](std::string const &path) { capturedPath = path; });
 
         // Set env to custom path
-        std::string customPath = "/bin/true";
+        std::string customPath = "@coreutils@/bin/true";
         setenv(MnDiagConstants::ENV_MNUBERGEMM_PATH.data(), customPath.c_str(), 1);
 
         auto mockCoreProxy = std::make_unique<MockDcgmCoreProxy>();
@@ -3112,7 +3112,7 @@
     {
         // Save current environment state
         auto savedPath         = saveEnvVar(MnDiagConstants::ENV_MNUBERGEMM_PATH.data());
-        std::string customPath = "/bin/true";
+        std::string customPath = "@coreutils@/bin/true";
         setenv(MnDiagConstants::ENV_MNUBERGEMM_PATH.data(), customPath.c_str(), 1);
 
         // Setup mock DCGM API with callback to inspect request
@@ -3251,7 +3251,7 @@
         auto savedPath = saveEnvVar(MnDiagConstants::ENV_MNUBERGEMM_PATH.data());
 
         // Use a known executable that exists
-        std::string customPath = "/bin/true";
+        std::string customPath = "@coreutils@/bin/true";
         setenv(MnDiagConstants::ENV_MNUBERGEMM_PATH.data(), customPath.c_str(), 1);
 
         // Call the method and verify path
diff --git a/modules/mndiag/tests/MnDiagProcessUtilsTests.cpp b/modules/mndiag/tests/MnDiagProcessUtilsTests.cpp
index 633e327c42..168ed91db2 100644
--- a/modules/mndiag/tests/MnDiagProcessUtilsTests.cpp
+++ b/modules/mndiag/tests/MnDiagProcessUtilsTests.cpp
@@ -71,7 +71,7 @@
     {
         // Start a long-running process
         DcgmNs::Common::Subprocess::ChildProcessBuilder builder;
-        builder.SetExecutable("/bin/sleep").AddArg("0.5");
+        builder.SetExecutable("@coreutils@/bin/sleep").AddArg("0.5");
 
         IoContext ioContext {};
         auto process = std::make_unique<DcgmNs::Common::Subprocess::ChildProcess>(builder.Build(ioContext));
@@ -155,4 +155,4 @@
 
         REQUIRE(result.empty());
     }
-}
\ No newline at end of file
+}
diff --git a/modules/mndiag/tests/MpiRunnerTests.cpp b/modules/mndiag/tests/MpiRunnerTests.cpp
index 526c80fd47..1e8596d3b7 100755
--- a/modules/mndiag/tests/MpiRunnerTests.cpp
+++ b/modules/mndiag/tests/MpiRunnerTests.cpp
@@ -60,7 +60,7 @@
 
     std::string GetMpiBinPath() const override
     {
-        return "/bin/bash";
+        return "@shell@";
     }
 
 private:
@@ -138,9 +138,9 @@
         runner.ConstructMpiCommand(&config);
 
         // Verify command construction
-        REQUIRE(runner.GetMpiBinPath() == "/bin/bash");
+        REQUIRE(runner.GetMpiBinPath() == "@shell@");
         std::string fullCommand = runner.GetLastCommand();
-        REQUIRE(fullCommand.find("/bin/bash -c") != std::string::npos);
+        REQUIRE(fullCommand.find("@shell@ -c") != std::string::npos);
         REQUIRE(fullCommand.find("sleep 1") != std::string::npos);
         REQUIRE(fullCommand.find("Output from sleep process") != std::string::npos);
 
@@ -244,4 +244,4 @@
         // Test with invalid parameter (null pointer)
         REQUIRE(runner.PopulateResponse(nullptr, nodeInfoMap_t()) == DCGM_ST_BADPARAM);
     }
-}
\ No newline at end of file
+}
diff --git a/modules/sysmon/DcgmCpuTopology.cpp b/modules/sysmon/DcgmCpuTopology.cpp
index 786d3877fc..ccbeccc81d 100644
--- a/modules/sysmon/DcgmCpuTopology.cpp
+++ b/modules/sysmon/DcgmCpuTopology.cpp
@@ -136,7 +136,7 @@
 {
     static std::string cmd = "lscpu --json";
     std::string cmdOutput;
-    static std::array<std::string, 2> cmdPathPrefix = { "/usr/bin/", "/usr/sbin/" };
+    static std::array<std::string, 1> cmdPathPrefix = { "@util-linux@/bin/" };
 
     dcgmReturn_t result = DCGM_ST_OK;
     for (auto const &prefix : cmdPathPrefix)
diff --git a/nvvs/plugin_src/nvbandwidth/NVBandwidthPlugin.cpp b/nvvs/plugin_src/nvbandwidth/NVBandwidthPlugin.cpp
index 261bba4490..4d439ad452 100644
--- a/nvvs/plugin_src/nvbandwidth/NVBandwidthPlugin.cpp
+++ b/nvvs/plugin_src/nvbandwidth/NVBandwidthPlugin.cpp
@@ -238,7 +238,7 @@
     std::vector<std::string> const search_paths
         = { GetCurrentModuleLocation(),
             fmt::format("./apps/nvvs/plugins/cuda{}", m_cudaDriverMajorVersion),
-            fmt::format("/usr/libexec/datacenter-gpu-manager-4/plugins/cuda{}", m_cudaDriverMajorVersion),
+            fmt::format("@dcgm_out@/libexec/datacenter-gpu-manager-4/plugins/cuda{}", m_cudaDriverMajorVersion),
             GetNvvsBinCheckPath(m_cudaDriverMajorVersion) };
     std::stringstream path_buf;
 
diff --git a/testing/TestDiagManager.cpp b/testing/TestDiagManager.cpp
index 8087123a49..a6333b3a3d 100644
--- a/testing/TestDiagManager.cpp
+++ b/testing/TestDiagManager.cpp
@@ -236,7 +236,7 @@
     if (nvvsPathEnv)
         nvvsBinPath = std::string(nvvsPathEnv) + "/nvvs";
     else
-        nvvsBinPath = "/usr/libexec/datacenter-gpu-manager-4/nvvs";
+        nvvsBinPath = "@dcgm_out@/libexec/datacenter-gpu-manager-4/nvvs";
 
     std::string diagResponseVersionArg = fmt::format("--response-version {}", dcgmDiagResponse_version12);
     expected.push_back(nvvsBinPath + " --channel-fd 3 " + diagResponseVersionArg