`NOB_GO_REBUILD_URSELF` fails if not run from the same folder where its source code is located
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- c
- Domain
- build-system
Research direction
Inspect nob.h at nob__go_rebuild_urself and compare its path handling with the reproducer in nob.c. Run the shown command from a subdirectory, then verify that NOB_GO_REBUILD_URSELF can locate nob.c and complete its rebuild behavior when launched outside the source directory.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- C++
- Stars
- 3.3k
- Forks
- 215
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from tsoding/nob.h
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
nob__walk_dir_opt_impl() tries to close zeroed handle for non directory entriesPossibly taken @whophi claimed this 65 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
nob_get_file_type error check is dead code: nob_copy_directory_recursively aborts and nob_walk_dir returns true on unreadable pathsPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 76/100
Similar issues
-
[request] vsg/1.1.16Openupstream update
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
conan-io/conan-center-index#31142 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
NVIDIA/DeepStream#78 ·