# Locate executable files

**URL:** <https://forum.codecrafters.io/t/locate-executable-files/15494>\
**Category:** Challenges\
**Tags:** challenge:shell\
**Created:** [November 6, 2025, 12:42am UTC](https://forum.codecrafters.io/t/locate-executable-files/15494 "2025-11-06T00:42:54Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yeabsirashimelis](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/yeabsirashimelis/32/19537_2.png) [@Yeabsirashimelis](https://forum.codecrafters.io/u/Yeabsirashimelis)\
**Post date:** [November 6, 2025, 12:42am UTC](https://forum.codecrafters.io/t/locate-executable-files/15494/1 "2025-11-06T00:42:54Z")

</div>

the my\_exe external command has random executable in the tester. it is not the same as the one i got from the system path, so the test kept failing

---

<div class="post-metadata">

**Author:** ![Yeabsirashimelis](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/yeabsirashimelis/32/19537_2.png) [@Yeabsirashimelis](https://forum.codecrafters.io/u/Yeabsirashimelis)\
**Post date:** [November 6, 2025, 6:14am UTC](https://forum.codecrafters.io/t/locate-executable-files/15494/5 "2025-11-06T06:14:14Z")

</div>

How do you solve the problem

---

<div class="post-metadata">

**Author:** ![maulana48](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/maulana48/32/19560_2.png) [@maulana48](https://forum.codecrafters.io/u/maulana48)\
**Post date:** [November 6, 2025, 10:52am UTC](https://forum.codecrafters.io/t/locate-executable-files/15494/6 "2025-11-06T10:52:07Z")

</div>

what’s happen to those my\_exe command?, i’t’s randomly selected path yet when I got lucky the result is still failed? :

remote: [your-program] $ type my\_exe

remote: [your-program] my\_exe is /tmp/quz/my\_exe

remote: [tester::#MG5] ^ Line does not match expected value.

remote: [tester::#MG5] Expected: “my\_exe is /tmp/qux/my\_exe”

remote: [tester::#MG5] Received: “my\_exe is /tmp/quz/my\_exe”

remote: [your-program] $

remote: [tester::#MG5] Assertion failed.

remote: [tester::#MG5] Test failed

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [November 6, 2025, 11:04am UTC](https://forum.codecrafters.io/t/locate-executable-files/15494/7 "2025-11-06T11:04:49Z")

</div>

Hey @Yeabsirashimelis @maulana48, could you double-check if your code implements the following logic?

 ![](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/a/c/ac2fb0071610652c4a3855c99ed43955548fab48.png)

Note that there are multiple files with the same name in different locations, but not all of them are executable. Only the first executable should be picked up.

As for the randomness, it’s there to prevent hardcoded solutions from passing, and isn’t related to the issue you’re encountering.

---

<div class="post-metadata">

**Author:** ![maulana48](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/maulana48/32/19560_2.png) [@maulana48](https://forum.codecrafters.io/u/maulana48)\
**Post date:** [November 6, 2025, 2:48pm UTC](https://forum.codecrafters.io/t/locate-executable-files/15494/9 "2025-11-06T14:48:49Z")

</div>

You got me there, it’s missing the permission check, I still don’t understand why when expected and received message is same it’s failed though, thanks for your help

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [November 6, 2025, 3:09pm UTC](https://forum.codecrafters.io/t/locate-executable-files/15494/10 "2025-11-06T15:09:03Z")

</div>

> I still don’t understand why when expected and received message is same it’s failed though

@maulana48 Possibly because `qux` and `quz` are easy to mix up?

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/b/5/b5b0a8b7661dcdf4a89da48737f61e9800246369.png)

---

<div class="post-metadata">

**Author:** ![Yeabsirashimelis](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/yeabsirashimelis/32/19537_2.png) [@Yeabsirashimelis](https://forum.codecrafters.io/u/Yeabsirashimelis)\
**Post date:** [November 6, 2025, 5:50pm UTC](https://forum.codecrafters.io/t/locate-executable-files/15494/11 "2025-11-06T17:50:09Z")

</div>

It was such a great response from you. it works directly when I correct the code exactly as you said.  
I wasn’t checking the files executing permissions

---

<div class="post-metadata">

**Author:** ![jsrivaya](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/jsrivaya/32/19619_2.png) [@jsrivaya](https://forum.codecrafters.io/u/jsrivaya)\
**Post date:** [November 7, 2025, 11:22am UTC](https://forum.codecrafters.io/t/locate-executable-files/15494/12 "2025-11-07T11:22:30Z")

</div>

Not sure if your doubt is on why this is failing, but here is why. You where not lucky, paths are different, you returned the path where there is a ‘my\_exe’ but that one is not executable.

> “my\_exe is /tmp/ **qux** /my\_exe” → qux
> 
> “my\_exe is /tmp/ **quz** /my\_exe” → quz

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [November 12, 2025, 11:22am UTC](https://forum.codecrafters.io/t/locate-executable-files/15494/13 "2025-11-12T11:22:54Z")

</div>

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.
