0

I want to execute graldew. It is definitely in the same directory and it has all the permission. But when I try to execute it I get command not found. Also I can not even autocomplete it using TAB button.

Could someone explain why is it happening?enter image description here

Kosh
  • 218
  • 1
  • 6

2 Answers2

1

Have you tried ./graldew?

./ represents the current directory

DarkDiamond
  • 1,875
  • 11
  • 12
  • 19
xepa
  • 26
  • 3
  • 1
    Didn't explain why this is happening, though... – u1686_grawity Jan 16 '22 at 09:28
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 16 '22 at 09:29
  • https://superuser.com/questions/156582/why-is-not-in-the-path-by-default – harrymc Jan 16 '22 at 10:49
1

It is definitely in the same directory

Unlike Windows, the command-line shell in macOS (and other Unix-like systems) only executes commands found in $PATH and doesn't give any special treatment to "the same directory" – and the current directory is not in $PATH by default.

Files whose location isn't in $PATH can only be run using their exact path: ./gradlew will work for files in the current directory (i.e. .), though full /Users/..../android/gradlew or $PWD/gradlew can be used too.

It is also possible to add . at the end of $PATH, though generally not recommended. (Adding it at the beginning, like in Windows, is very risky as downloaded files could override system commands such as 'ls' or 'rm'; having it at the end – a bit less so.)

u1686_grawity
  • 426,297
  • 64
  • 894
  • 966