Can't use gradle wrapper

I am trying to mod minecraft but whenever I try to run gradlew setupDecompWorkspace it says the function gradlew doesn’t exist. nothing changes if I do ./gradlew . i tried typing gradle wrapper in terminal and I got this:

Task :wrapper FAILED

FAILURE: Build failed with an exception.

  • What went wrong:

Some problems were found with the configuration of task ‘:wrapper’.

Cannot write to file ‘/usr/local/Cellar/gradle/5.5.1/libexec/bin/gradle/wrapper/gradle-wrapper.jar’ specified for property ‘jarFile’, as ancestor ‘/usr/local/Cellar/gradle/5.5.1/libexec/bin/gradle’ is not a directory.

Cannot write to file ‘/usr/local/Cellar/gradle/5.5.1/libexec/bin/gradle/wrapper/gradle-wrapper.properties’ specified for property ‘propertiesFile’, as ancestor ‘/usr/local/Cellar/gradle/5.5.1/libexec/bin/gradle’ is not a directory.

What do I do?

This seems like it’s more of a problem with Homebrew than with Gradle. I’d probably try uninstalling/reinstalling Gradle (brew rm/brew install) and trying it again.

For what it’s worth, I use sdkman to manage Gradle on my machines, so that could be another option for you if you can’t get Homebrew working.