-
Notifications
You must be signed in to change notification settings - Fork 14
Description
Hi, cool project! I was excited to use this for a build system rewrite, but I'm running into a few issues. Seems to be a parity issue between when using this library?
The first issue I noticed was if I attempt to execute gcc from a subprocess::command, I get the error:
> gcc -g -o path/to/file.o -c path/to/file.c ...
gcc: fatal error: cannot execute 'cc1': execvp: No such file or directoryThis same command runs fine in a shell outside of the cpp executable/subprocess. This got me investigating other commands...
std::string cmd = "env";
std::cout << "> " << cmd << "\n";
int code = (subprocess::command{cmd} > output).run();
std::cout << "(" << code << ") < " << output << std::endl;> env
(0) <
env doesn't print anything, but echo $PATH prints the correct path?
As a sanity check to see if this was localized to the library, I tried using a simple exec to popen function:
std::string exec(const char* cmd) {
std::array<char, 128> buffer;
std::string result;
std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd, "r"), pclose);
if (!pipe) {
throw std::runtime_error("popen() failed!");
}
while (fgets(buffer.data(), static_cast<int>(buffer.size()), pipe.get()) != nullptr) {
result += buffer.data();
}
return result;
}
int main() {
std::string cmd = "env";
std::cout << "exec: " << cmd << std::endl;
std::cout << exec(cmd.c_str()) << std::endl;
std::cout << "subprocess: " << cmd << "\n";
(subprocess::command{cmd} > output).run();
std::cout << "< " << output << std::endl;
}exec: env
... env printed ...
subprocess: env
<
...where, as above shows, the exec function works as expected but the subprocess command does not? This is also the case when I supply the gcc command I mentioned above -- the simple exec function works, the subprocess one does not.
Any idea what the issue could be? I tried to investigate the docs, but the site does not seem to be working currently, so reaching out here.
Thanks for any 👀/ help!