Repro
$ cat nob.c
#define NOB_IMPLEMENTATION
#define NOB_STRIP_PREFIX
#include "nob.h"
int main(int argc, char **argv)
{
NOB_GO_REBUILD_URSELF(argc, argv);
return 0;
}
$ cc -o nob nob.c
$ mkdir foo && cd foo
$ ../nob
[ERROR] could not stat nob.c: No such file or directory
Workaround
--- nob.c 2025-10-30 08:20:33.984305999 +0700
+++ nob.fixed.c 2025-10-30 08:20:59.128496254 +0700
@@ -4,6 +4,7 @@
int main(int argc, char **argv)
{
+ if (!set_current_dir(temp_dir_name(temp_running_executable_path()))) return 1;
+ argv[0] = temp_sprintf("./%s", temp_file_name(argv[0]));
NOB_GO_REBUILD_URSELF(argc, argv);
return 0;
}
Potential solution
Maybe NOB_GO_REBUILD_URSELF() should imply the above Workaround (that is should be just included in nob__go_rebuild_urself). But I'm not sure about any potential pitfalls of this solution.