build-signed-apk icon indicating copy to clipboard operation
build-signed-apk copied to clipboard

cannot access './gradlew': No such file or directory

Open KyneSilverhide opened this issue 2 years ago • 14 comments

Hello,

I'm using your github action on a Ionic + Capacitor project. And that means the ./gradlew file is not in the root of my project, but inside an android sub-directory. image

This leads to the following error (well, I think that's the cause...) :

Run cp android.jks $GITHUB_WORKSPACE/signing-key.jks
Run chmod +x ./gradlew
chmod: cannot access './gradlew': No such file or directory
Error: Process completed with exit code 1.

Would it be possible to define another working directory in your action?

KyneSilverhide avatar Jul 30 '22 14:07 KyneSilverhide

I made the changes but I can't test it, can you try using the test branch uses: victorbnl/build-signed-apk@gradlew_file-test and tell me if it works? The new parameter is gradlew_file. Also can you try using that branch without specifying the parameter to see if you still get the same error? To ensure this parameter does default to ./gradlew as it should? Thanks!

victorbnl avatar Jul 30 '22 17:07 victorbnl

Sure, I'll try that and let you know :)

KyneSilverhide avatar Jul 30 '22 17:07 KyneSilverhide

Test 1 : new version, no addition parameter :white_check_mark:

Run victorbnl/build-signed-apk@gradlew_file-test
...
Run chmod +x ./gradlew
chmod: cannot access './gradlew': No such file or directory

Test 2 : new version, with aditionnal "gradlew_file" parameter ❌

Run chmod +x android/gradlew
  chmod +x android/gradlew
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
Run android/gradlew build
Downloading https://services.gradle.org/distributions/gradle-7.3.3-all.zip
...
FAILURE: Build failed with an exception.

* What went wrong:
Directory '/home/runner/work/fallout-jdr-helper/fallout-jdr-helper' does not contain a Gradle build.

A Gradle build should contain a 'settings.gradle' or 'settings.gradle.kts' file in its root directory. It may also contain a 'build.gradle' or 'build.gradle.kts' file.

While it does find the gradelw file, it seems the "context" is still wrong. image

KyneSilverhide avatar Jul 30 '22 18:07 KyneSilverhide

I updated that to be the gradlew_dir option (defaults to .) which does a cd ${{ inputs.gradlew_dir }} before the gradlew commands. You can try that

victorbnl avatar Jul 30 '22 18:07 victorbnl

Hmm.. I tried to add the folder but it's still the same error. image

Run cp android.jks $GITHUB_WORKSPACE/signing-key.jks
Run chmod +x android/gradlew
Run android/gradlew build
FAILURE: Build failed with an exception.

* What went wrong:
Directory '/home/runner/work/fallout-jdr-helper/fallout-jdr-helper' does not contain a Gradle build.

A Gradle build should contain a 'settings.gradle' or 'settings.gradle.kts' file in its root directory. It may also contain a 'build.gradle' or 'build.gradle.kts' file.

KyneSilverhide avatar Jul 30 '22 18:07 KyneSilverhide

Oh gosh I commited and forgot to push... :sob: :joy: you can try now. Sorry for losing your time x)

victorbnl avatar Jul 30 '22 18:07 victorbnl

Ahah :)

Well, unfortunately.. it's not starting anymore, so I guess something was indeed pushed... :p

Error: victorbnl/build-signed-apk/gradlew_file-test/action.yml (Line: 54, Col: 7): Required property is missing: shell
Error: victorbnl/build-signed-apk/gradlew_file-test/action.yml (Line: 54, Col: 7): Required property is missing: shell
Error: GitHub.DistributedTask.ObjectTemplating.TemplateValidationException: The template is not valid. victorbnl/build-signed-apk/gradlew_file-test/action.yml (Line: 54, Col: 7): Required property is missing: shell
   at GitHub.DistributedTask.ObjectTemplating.TemplateValidationErrors.Check()
   at GitHub.Runner.Worker.ActionManifestManager.ConvertRuns(IExecutionContext executionContext, TemplateContext templateContext, TemplateToken inputsToken, String fileRelativePath, MappingToken outputs)
   at GitHub.Runner.Worker.ActionManifestManager.Load(IExecutionContext executionContext, String manifestFile)
Error: Fail to load victorbnl/build-signed-apk/gradlew_file-test/action.yml
##[debug]System.ArgumentException: Fail to load victorbnl/build-signed-apk/gradlew_file-test/action.yml

KyneSilverhide avatar Jul 30 '22 18:07 KyneSilverhide

Right, I forgot one had to specify the shell when using run: this one should be fixed

victorbnl avatar Jul 30 '22 18:07 victorbnl

Ok, so it's opening the proper folder, but it still runs "./gradlew", instead of "gradlew" (I've kept the gradlew_file parameter but it's not used anymore I guess)

Warning: Unexpected input(s) 'gradlew_file' valid inputs are ['keystore_b64', 'keystore_file', 'keystore_password', 'key_alias', 'key_password', 'gradlew_dir']
...
Run cp android.jks $GITHUB_WORKSPACE/signing-key.jks
Run cd android/
Run chmod +x ./gradlew
chmod: cannot access './gradlew': No such file or directory

KyneSilverhide avatar Jul 30 '22 18:07 KyneSilverhide

It's not indeed, I didn't know you had to run gradlew instead of ./gradlew that seems unusual to me. Do you think just using gradlew everywhere would work or I should add another parameter gradle_command defaulting to ./gradlew to be set to gradlew in your case?

victorbnl avatar Jul 30 '22 18:07 victorbnl

I'm not sure while "./gradlew" is not working. It seems to find the "android" folder, otherwise it would have failed at this stage... So unless ./ somehow refers to the root folder instead of the current one... I don't know why its not working. One way of debugging it would be to add "ls -l" after the CD, so I could see what's inside the folder.

KyneSilverhide avatar Jul 30 '22 20:07 KyneSilverhide

After a bit of research, I found the working directory doesn't persist from one step to another. You need to use working-directory. Anyway it should be fixed now

victorbnl avatar Jul 30 '22 22:07 victorbnl

I don't see the "chmod +x" anymore in the logs... so it still fails... :(

Run cp android.jks $GITHUB_WORKSPACE/signing-key.jks
Run ./gradlew build
/home/runner/work/_temp/d2bb3c1f-0dde-4d49-ab72-c6e78b4619c0.sh: line 1: ./gradlew: Permission denied

KyneSilverhide avatar Jul 31 '22 07:07 KyneSilverhide

Right I had forgotten it, and now?

victorbnl avatar Jul 31 '22 10:07 victorbnl

Yes, that's it, it runs the build now ! Now I just have to fix the build errors but that's on my side. Thanks !

KyneSilverhide avatar Jul 31 '22 12:07 KyneSilverhide

Thanks to you for taking your time helping me testing it!! Also you can switch back to the main branch, I added the changes

victorbnl avatar Jul 31 '22 12:07 victorbnl