[tester::#MG5] Running tests for Stage #MG5 (The type builtin: executable files)
[tester::#MG5] [setup] export PATH=/tmp/bar:$PATH
[tester::#MG5] [setup] export PATH=/tmp/bar:$PATH
[tester::#MG5] [setup] Available executables:
[tester::#MG5] [setup] - my_exe
[tester::#MG5] Running ./your_program.sh
[your-program] $ type cat
[your-program] cat is /usr/bin/cat
[tester::#MG5] ✓ Received expected response
[your-program] $ type cp
[your-program] cp is /usr/bin/cp
[tester::#MG5] ✓ Received expected response
[your-program] $ type mkdir
[your-program] mkdir is /usr/bin/mkdir
[tester::#MG5] ✓ Received expected response
[your-program] $ type my_exe
[your-program] my_exe: not found
[tester::#MG5] Output does not match expected value.
[tester::#MG5] Expected: "my_exe is /tmp/bar/my_exe"
[tester::#MG5] Received: "my_exe: not found"
[your-program] $
[tester::#MG5] Assertion failed.
[tester::#MG5] Test failed
I also get this problem from time to time. This seems to only happen when the same directory is included in PATH twice (/tmp/bar in this case). I can’t figure out the reason either.
however with codecrafters test I get same error as mentioned above:
remote: [tester::#MG5] Output does not match expected value.
remote: [tester::#MG5] Expected: "my_exe is /tmp/quz/my_exe"
remote: [tester::#MG5] Received: "my_exe: not found"
Hey @homocodian Looks like you’ve got past this stage. Do you happen to remember what was wrong? Would love to see if we can improve the tester / instructions.
Can’t say for sure, but I think, as @yanruijie902136 says, that it happens when the same directory gets put in the PATH twice.
The setup is semi-random, could it be that the test runner accidentally picks the same directory names twice and that cause it to overwrite something, like the executable flag?
I did a bit of digging, and it seems that sometimes the PATH will include the same dir twice (PATH=/tmp/foo:/tmp/foo), and when that happens, the executable bit will not be set (according to my very sophisticated printlns ).
I believe it might be because during the test setup, my_exe is copied to both directories (in this case to the same directory twice), and the executable bit is turned off in 1 of the places (in this case, since both dirs point to the same place, in both). I believe this confirms what @yanruijie902136 and @senevoldsen are also saying.
Hope this helps! Until the fix, we pray to random.
Hey @vlad-stoian,
Yes, you’re spot on. We confirmed that was the issue in the builtin: executable files stage.
Due to a flaw in how we were selecting random temporary directories, our logic wasn’t correctly handling cases where a chosen directory name already existed. This caused subsequent steps, like setting up executables with varying permissions, to operate within an unintended, pre-existing directory, leading to conflicts. The fix ensures we now actively check for and avoid using existing directory paths before creation.
We’ll keep an eye on this thread for any further reports of this nature.
Could anyone else who might have seen this confirm if the fix resolves the issue on your end too?