Skip to content

Commit 286fe46

Browse files
committed
util: Add helpful error message when failing to execute file
Useful when forgetting to build necessary targets.
1 parent 47d79db commit 286fe46

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/mp/util.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#include <cerrno>
99
#include <cstdio>
10+
#include <filesystem>
11+
#include <iostream>
1012
#include <kj/common.h>
1113
#include <kj/string-tree.h>
1214
#include <pthread.h>
@@ -29,6 +31,8 @@
2931
#include <pthread_np.h>
3032
#endif // HAVE_PTHREAD_GETTHREADID_NP
3133

34+
namespace fs = std::filesystem;
35+
3236
namespace mp {
3337
namespace {
3438

@@ -138,6 +142,9 @@ void ExecProcess(const std::vector<std::string>& args)
138142
argv.push_back(nullptr);
139143
if (execvp(argv[0], argv.data()) != 0) {
140144
perror("execvp failed");
145+
if (errno == ENOENT && !args.empty()) {
146+
std::cerr << "Missing executable: " << fs::weakly_canonical(args.front()) << '\n';
147+
}
141148
_exit(1);
142149
}
143150
}

0 commit comments

Comments
 (0)