Tests won’t pass on #MG5 too

Hi, I have a similar issue with MG5 when I’m running manually my code using PATH from test everything is working fine, but via codecrafters cli it is failing. I was trying to check how it is running the tests, but for some reason it is binary(
[tester::#MG5] Expected: “cat is /bin/cat”
[tester::#MG5] Received: “cat: not found”

Can anyone take a look what is wrong in my code please?
Here is the repo: we-shall-c

@andy1li In terms of reading the folders my code is identical to reference implementation, Is there a way we can get the actual command CLI is running for MG5? I really want to understand what is going on, otherwise it is not learning :upside_down_face:

Hi @sedrakpc, could you verify how you populated PATH_COMMANDS? It seems your code couldn’t locate cat because the size of PATH_COMMANDS is zero in processCommand:

After some digging I managed to find the issue, just changing #include <strings.h> to #include <string.h> fixed it, but I do not understand why yet.

1 Like

Great job finding the fix! I’m not deeply familiar with C either, but here’s some insight from ChatGPT:

The difference lies in the purpose of the two headers:

  • <string.h>: This is the standard C library header for string manipulation functions like strlen, strcpy, and strcat. It’s universally available on all platforms that comply with the C standard (ANSI/ISO), including Windows, Linux, and macOS.

  • <strings.h>: This is a POSIX-specific header that provides additional functions like strcasecmp, strncasecmp, bzero, and others. It’s commonly found on Linux and macOS, but it’s not available on platforms like Windows, which do not fully support POSIX.