[Shell][Python] mg5 multiple my exe?

Submitting changes (commit: 0149d7b)...

Our test runners might be experiencing downtime: https://status.codecrafters.io

Running tests. Logs should appear shortly...

[compile] Moved ./.codecrafters/run.sh → ./your_program.sh
[compile] Compilation successful.

[tester::#MG5] Running tests for Stage #MG5 (The type builtin: executable files)
[tester::#MG5] [setup] export PATH=/tmp/qux:$PATH
[tester::#MG5] [setup] export PATH=/tmp/bar:$PATH
[tester::#MG5] [setup] PATH is now: /tmp/bar:/tmp/qux:/usr/local/bin:...
[tester::#MG5] [setup] Available executables:
[tester::#MG5] [setup] - my_exe
[tester::#MG5] Running ./your_program.sh
[your-program] $ type cat
[your-program] cat is /bin/cat
[tester::#MG5] ✓ Received expected response
[your-program] $ type cp
[your-program] cp is /bin/cp
[tester::#MG5] ✓ Received expected response
[your-program] $ type mkdir
[your-program] mkdir is /bin/mkdir
[tester::#MG5] ✓ Received expected response
[your-program] $ type my_exe
[your-program] my_exe is /tmp/qux/my_exe
[tester::#MG5] ^ Line does not match expected value.
[tester::#MG5] Expected: "my_exe is /tmp/bar/my_exe"
[tester::#MG5] Received: "my_exe is /tmp/qux/my_exe"
[your-program] $
[tester::#MG5] Assertion failed.
[tester::#MG5] Test failed (try setting 'debug: true' in your codecrafters.yml to see more details)

View our article on debugging test failures: https://codecrafters.io/debug

Are there maybe 2 my_exe’s because my program finds one but it expects the other?

I fixed it by reversing the path list but i think that it shouldnt be like that? why would there even be two of the same and what does it expect alphabeticly sorted or reversed?

Hey @Zeviraty, reversing the PATH might not be the right approach here.

It’s completely okay for multiple files to have the same name within your PATH. For instance, my system has several entries for python3:

The catch is that NOT all files found via PATH are necessarily executable. You’ll want to skip any entries that don’t have execute permissions.

Let me know if you’d like further clarification!

1 Like