There seems to be something wrong with the test cases for stage “The type builtin: executable files #MG5”. I can run the code fine in my local machine but when I push my changes (or use the CLI) I get a few errors.
As other threads have pointed out, it seems to be fixed with finding executables in /bin rather than /usr/bin. Since /bin is a symbolic link to /usr/bin I guess it’s just cannot follow it, and I’m not sure if it’s part of the challenge to work around that.
Anyway, for now I just added a rule to ignore /usr/bin and this is solved:
Cannot fine my_exe, as it seems to think that there should be something created in /tmp. I get this error both on my local machine and on the test suite.
remote: [tester::#MG5] Output does not match expected value.
remote: [tester::#MG5] Expected: "my_exe is /tmp/orange/blueberry/banana/my_exe"
remote: [tester::#MG5] Received: "my_exe: not found"
remote: [your-program] my_exe: not found
Here’s a link to the repo (yes, I’m using the evil goto to break out of the inner loop, I didn’t feel like writing any functions ):
Sorry, I’m a little lost on what you mean. Are you saying that the tester program is updating the PATH variable, but only after the program it’s testing runs? That seems strange… but anyway, how can I source it during program execution?
The value of PATH doesn’t change during program execution, but the executables available on the filesystem can change after the shell has started. This is exactly how shells like bash/zsh can pickup a new program soon after you’ve installed it using something like brew install <program>.
Your shell will need to check all entries in PATH every time it receives a command it doesn’t understand - it shouldn’t “preload” all entries on startup.
The temporary directory is created and placed at the beginning of the PATH. It should found the my_exe executable there.
I’ve just changed things up so that instead of printing “my_exe: not found” it prints the PATH variable, so we can see clearly whether it’s there or not, and it’s in fact loaded properly:
[tester::#MG5] Expected: "my_exe is /tmp/grape/strawberry/strawberry/my_exe"
[tester::#MG5] Received: "/tmp/grape/strawberry/strawberry:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
If I return that path directly, it works fine. Which makes me think that the my_exe file is never actually there to be found.
I’ve found the issue with the second error regarding the my_exe command… it was completely my own fault, as I didn’t realize that I was calling strtok one extra time before actually starting going over the directories, effectively removing the first element in the PATH variable…
Sorry everyone
However, there’s still the issue of:
[tester::#MG5] Expected: "cp is /bin/cp"
[tester::#MG5] Received: "cp is /usr/bin/cp"
Since /bin files are all symlink to /usr/bin binaries, you could exclude paths that start by /bin, maybe the tester doesn’t mind. You could also reverse iterate so that /usr/bin comes first.
That’s what I’ve been doing to get around this, yeah. In the code from my repository I removed it to keep it cleaner, but when testing and submitting the challenge I put it back in just for this purpose. Hope it can get fixed!
Thanks! I’ll try to swap it out and see if there are any different results? I hope I’m not missing anything… but anyway, I’ll do that after the holidays.
I tried solving this by filling a dynamic array with the commands in PATH on program start up. I assumed we would add a “dot” or “source” command later to update path, but it seems like I just need to redo this with a command that simply reads PATH for every single loop