exercism / kotlin-test-runner

GNU Affero General Public License v3.0
4 stars 11 forks source link

Fix permission denied error #14

Closed ErikSchierboom closed 3 years ago

ErikSchierboom commented 3 years ago

Running the test runner using the following command (which script is found in https://github.com/exercism/kotlin-test-runner/pull/13):

./bin/run-in-docker.sh hello-world /home/erik/exercism-repos/kotlin-test-runner/examples/full /home/erik/exercism-repos/kotlin-test-runner/examples/full

outputs the following error:

Parsed arguments: LaunchArguments(exerciseSlug=hello-world, solutionsDir=/solution, resultFile=/output/results.json)
Running gradle
Exception in thread "main" java.io.IOException: Cannot run program "./gradlew" (in directory "/tmp/kotlin-autotest-runnner12745587494545002673"): error=13, Permission denied
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
        at exercism.kotlin.autotests.executor.ExecutorKt.runGradleProcess(executor.kt:64)
        at exercism.kotlin.autotests.executor.ExecutorKt.executeBuild(executor.kt:30)
        at exercism.kotlin.autotests.executor.ExecutorKt.executor(executor.kt:10)
        at exercism.kotlin.autotests.runner.MainKt$main$result$1.invoke(main.kt:28)
        at exercism.kotlin.autotests.runner.MainKt$main$result$1.invoke(main.kt)
        at exercism.kotlin.autotests.executor.EnvironmentKt.executeOnEnvironment(environment.kt:16)
        at exercism.kotlin.autotests.runner.MainKt.main(main.kt:28)
Caused by: java.io.IOException: error=13, Permission denied
        at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
        at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:340)
        at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:271)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
        ... 8 more

This is an odd error, as the /tmp directory is mounted as as tmpfs Docker mount, and should be writable.

ErikSchierboom commented 3 years ago

Note that this issue if (far) less pressing than #16.

dector commented 3 years ago

This is some strange tmpfs magic in Docker. I'm trying to create executable bash script with rwxr-xr-x permissions and still getting Permission Denied in terminal. 🤔

ErikSchierboom commented 3 years ago

Weird! Does it work if you change tmpfs to volume?

dector commented 3 years ago

I think I found something.

https://github.com/moby/moby/issues/35890 and https://github.com/moby/moby/issues/32131

Indeed, --mount type=tmpfs has no exec support yet. But --tmpfs /tmp:exec works. 😄 Will upload fix for that.

ErikSchierboom commented 3 years ago

@dector I'm running ./bin/run-in-docker.sh hello-world /home/erik/exercism-repos/kotlin-test-runner/examples/full /home/erik/exercism-repos/kotlin-test-runner/examples/full again with the latest fix, and the Permission denied error is indeed fixed! Great. I do get another error though:

Parsed arguments: LaunchArguments(exerciseSlug=hello-world, solutionsDir=/solution, resultFile=/output/results.json)
Running gradle
Exception in thread "main" java.io.IOException: Cannot run program "./gradlew" (in directory "/tmp/kotlin-autotest-runnner16159523151937320801"): /tmp/kotlin-autotest-runnner16159523151937320801/__out.log (No such file or directory)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
        at exercism.kotlin.autotests.executor.ExecutorKt.runGradleProcess(executor.kt:64)
        at exercism.kotlin.autotests.executor.ExecutorKt.executeBuild(executor.kt:30)
        at exercism.kotlin.autotests.executor.ExecutorKt.executor(executor.kt:10)
        at exercism.kotlin.autotests.runner.MainKt$main$result$1.invoke(main.kt:28)
        at exercism.kotlin.autotests.runner.MainKt$main$result$1.invoke(main.kt)
        at exercism.kotlin.autotests.executor.EnvironmentKt.executeOnEnvironment(environment.kt:16)
        at exercism.kotlin.autotests.runner.MainKt.main(main.kt:28)
Caused by: java.io.FileNotFoundException: /tmp/kotlin-autotest-runnner16159523151937320801/__out.log (No such file or directory)
        at java.base/java.io.FileOutputStream.open0(Native Method)
        at java.base/java.io.FileOutputStream.open(FileOutputStream.java:298)
        at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:237)
        at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:250)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
        ... 8 more
erik@VELPIE:~/exercism/kotlin-test-runner$ ./bin/run-in-docker.sh hello-world /home/erik/exercism-repos/kotlin-test-runner/examples/full /home/erik/exercism-repos/kotlin-test-runner/examples/full
[+] Building 1.5s (19/19) FINISHED                                                                                                    
 => [internal] load build definition from Dockerfile                                                                             0.0s
 => => transferring dockerfile: 38B                                                                                              0.0s
 => [internal] load .dockerignore                                                                                                0.0s
 => => transferring context: 2B                                                                                                  0.0s
 => [internal] load metadata for docker.io/adoptopenjdk/openjdk11:jdk-11.0.5_10-alpine-slim                                      1.2s
 => [build  1/10] FROM docker.io/adoptopenjdk/openjdk11:jdk-11.0.5_10-alpine-slim@sha256:0036883df4894f853a6c8e6e1832c105f3026c  0.0s
 => [internal] load build context                                                                                                0.0s
 => => transferring context: 2.35kB                                                                                              0.0s
 => CACHED [stage-1 2/5] COPY bin/run.sh /opt/test-runner/bin/run.sh                                                             0.0s
 => CACHED [build  2/10] RUN apk add --no-cache tar bash procps                                                                  0.0s
 => CACHED [build  3/10] WORKDIR /home/builder                                                                                   0.0s
 => CACHED [build  4/10] RUN wget https://services.gradle.org/distributions/gradle-6.0.1-bin.zip                                 0.0s
 => CACHED [build  5/10] RUN unzip gradle-6.0.1-bin.zip                                                                          0.0s
 => CACHED [build  6/10] RUN mv gradle-6.0.1 /home/gradle                                                                        0.0s
 => CACHED [build  7/10] COPY src ./src                                                                                          0.0s
 => CACHED [build  8/10] COPY build.gradle.kts ./                                                                                0.0s
 => CACHED [build  9/10] RUN /home/gradle/bin/gradle -i shadowJar                                                                0.0s
 => CACHED [build 10/10] RUN cp build/libs/autotest-runner.jar .                                                                 0.0s
 => CACHED [stage-1 3/5] COPY --from=build                                                                                       0.0s
 => CACHED [stage-1 4/5] COPY --from=build /home/builder/autotest-runner.jar /opt/test-runner/bin/                               0.0s
 => CACHED [stage-1 5/5] WORKDIR /opt/test-runner                                                                                0.0s
 => exporting to image                                                                                                           0.1s
 => => exporting layers                                                                                                          0.0s
 => => writing image sha256:0f29eaac8a4f826d3898e5ec51ea9b5fe0720359f1e50bbefccdd5feb30ce973                                     0.0s
 => => naming to docker.io/exercism/test-runner                                                                                  0.0s

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
Parsed arguments: LaunchArguments(exerciseSlug=hello-world, solutionsDir=/solution, resultFile=/output/results.json)
Running gradle
Exception in thread "main" java.io.IOException: Cannot run program "./gradlew" (in directory "/tmp/kotlin-autotest-runnner8757524361769826187"): /tmp/kotlin-autotest-runnner8757524361769826187/__out.log (No such file or directory)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
        at exercism.kotlin.autotests.executor.ExecutorKt.runGradleProcess(executor.kt:64)
        at exercism.kotlin.autotests.executor.ExecutorKt.executeBuild(executor.kt:30)
        at exercism.kotlin.autotests.executor.ExecutorKt.executor(executor.kt:10)
        at exercism.kotlin.autotests.runner.MainKt$main$result$1.invoke(main.kt:28)
        at exercism.kotlin.autotests.runner.MainKt$main$result$1.invoke(main.kt)
        at exercism.kotlin.autotests.executor.EnvironmentKt.executeOnEnvironment(environment.kt:16)
        at exercism.kotlin.autotests.runner.MainKt.main(main.kt:28)
Caused by: java.io.FileNotFoundException: /tmp/kotlin-autotest-runnner8757524361769826187/__out.log (No such file or directory)
        at java.base/java.io.FileOutputStream.open0(Native Method)
        at java.base/java.io.FileOutputStream.open(FileOutputStream.java:298)
        at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:237)
        at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:250)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
        ... 8 more

Any idea?