opentelemetry-demo icon indicating copy to clipboard operation
opentelemetry-demo copied to clipboard

Fix `gradlew` commands on Windows

Open mic-max opened this issue 2 years ago • 14 comments

The adservice fails to build at the RUN ./gradlew downloadRepos step

You must run

  • ./gradlew installDist from /src/adservice/
  • ./gradlew wrapper --gradle-version 7.4.2

Maybe only one of the above commands is necessary...

Then the following command should work: docker compose build cartservice

Proposed Fix:

Make the docker compose up the only required command to run the whole project, so this might be simply upgrading the jar file: /src/adservice/gradle/wrapper/gradle-wrapper.jar to the 7.4.2 version done in the command found above.

image The other changes to /src/adservice/gradle/wrapper/gradle-wrapper.properties and /src/adservice/gradlew are only related to line endings: image

mic-max avatar Jun 01 '22 01:06 mic-max

I am still unable to run from windows. The instruction from https://github.com/open-telemetry/opentelemetry-demo-webstore#gradle-update-windows-only also does not help.

C:\repos\opentelemetry-demo-webstore\src\adservice>.\gradlew installDist

> Task :compileJava FAILED
C:\repos\opentelemetry-demo-webstore\src\adservice\src\main\java\hipstershop\AdService.java:21: error: package hipstershop.Demo does not exist
import hipstershop.Demo.Ad;
                       ^
C:\repos\opentelemetry-demo-webstore\src\adservice\src\main\java\hipstershop\AdService.java:22: error: package hipstershop.Demo does not exist
import hipstershop.Demo.AdRequest;
                       ^
C:\repos\opentelemetry-demo-webstore\src\adservice\src\main\java\hipstershop\AdService.java:23: error: package hipstershop.Demo does not exist
import hipstershop.Demo.AdResponse;
                       ^
C:\repos\opentelemetry-demo-webstore\src\adservice\src\main\java\hipstershop\AdService.java:137: error: cannot find symbol
  private static final ImmutableListMultimap<String, Ad> adsMap = createAdsMap();
                                                     ^
  symbol:   class Ad
  location: class AdService
C:\repos\opentelemetry-demo-webstore\src\adservice\src\main\java\hipstershop\AdService.java:140: error: cannot find symbol
  private Collection<Ad> getAdsByCategory(@SpanAttribute("app.ads.category") String category) {

cijothomas avatar Jul 06 '22 16:07 cijothomas

@cijothomas Does running docker compose build --no-cache adservice work? If so, I think we can close and remove the instruction from README.md - the merged PR linked to this issue might have fixed the entire issue and the extra steps are no longer needed.

mic-max avatar Jul 06 '22 23:07 mic-max

image unfortunately, no :(

cijothomas avatar Jul 06 '22 23:07 cijothomas

Seems to potentially be an issue between mac & windows ending characters for the gradlew file. I fixed it by changing the ending character in notepad++ to Unix lf

cartersocha avatar Jul 08 '22 20:07 cartersocha

Has this been fixed @mic-max? I know we have the readme windows guidance

cartersocha avatar Jul 15 '22 04:07 cartersocha

Has this been fixed @mic-max? I know we have the readme windows guidance

I'm not sure, I haven't done any related change recently since I'm not able to reproduce the problem anymore..

mic-max avatar Jul 25 '22 18:07 mic-max

https://github.com/open-telemetry/opentelemetry-demo#gradle-update-windows-only This section does not work in windows.

pasting few lines from the error I see:

C:\repos\opentelemetry-demo\src\adservice>.\gradlew installDist Starting a Gradle Daemon (subsequent builds will be faster)

Task :compileJava C:\repos\opentelemetry-demo\src\adservice\src\main\java\hipstershop\AdService.java:21: error: package hipstershop.Demo does not exist import hipstershop.Demo.Ad; ^ C:\repos\opentelemetry-demo\src\adservice\src\main\java\hipstershop\AdService.java:22: error: package hipstershop.Demo does not exist import hipstershop.Demo.AdRequest; ^ C:\repos\opentelemetry-demo\src\adservice\src\main\java\hipstershop\AdService.java:23: error: package hipstershop.Demo does not exist import hipstershop.Demo.AdResponse; ^ C:\repos\opentelemetry-demo\src\adservice\src\main\java\hipstershop\AdService.java:137: error: cannot find symbol private static final ImmutableListMultimap<String, Ad> adsMap = createAdsMap(); ^ symbol: class Ad location: class AdService C:\repos\opentelemetry-demo\src\adservice\src\main\java\hipstershop\AdService.java:140: error: cannot find symbol private Collection<Ad> getAdsByCategory(@SpanAttribute("app.ads.category") String category) { ^ symbol: class Ad location: class AdService C:\repos\opentelemetry-demo\src\adservice\src\main\java\h

cijothomas avatar Jul 25 '22 19:07 cijothomas

Since the issue is not fixed, I'd suggest to keep this open.

cijothomas avatar Jul 25 '22 19:07 cijothomas

Did you try changing the file ending @cijothomas ? I’m unable to reproduce

cartersocha avatar Jul 25 '22 19:07 cartersocha

Did you try changing the file ending @cijothomas ?

No

cijothomas avatar Jul 25 '22 19:07 cijothomas

Hi expert, I have the same issue when building the adservice from Windows.if changing ending character can solve the problem, which gradle file is related to do ? I can help to test

echuang81 avatar Aug 02 '22 04:08 echuang81

@echuang81 check out the last comment on this stackoverflow post. It worked for me. https://stackoverflow.com/questions/70844518/cant-run-gradle-wrapper-with-docker-build

cartersocha avatar Aug 02 '22 05:08 cartersocha

Also try this if you haven’t yet: https://github.com/open-telemetry/opentelemetry-demo#gradle-update-windows-only

cartersocha avatar Aug 02 '22 05:08 cartersocha

Hi @cartersocha, thanks for your guidance. I tried re-clone with configuration autocrlf input set, as well as converting EOL to LF only character. Unfortunately, both also not working. hmm......

echuang81 avatar Aug 02 '22 13:08 echuang81

What is the state of this issue? I'm receiving the same error as @cijothomas while building in a clean ubuntu vm.

joshleecreates avatar Aug 11 '22 15:08 joshleecreates

I've solved this multiple times on my surface windows 11 by following these instructions. Not sure what others are encountering. I believe it's the file ending character causing problems but unsure how to fix for all or if that's the only problem.

I clone the repo, run docker compose build, it fails, change the gradlew that has no file ending by following below steps, then run docker compose build again & it works. 🤷‍♂️ @mic-max, @puckpuck

"Converting EOL to UNIX (LF) of the gradlew file should work. It can be fixed using notepad++.

Open the gradlew file in notepad++

Edit -> EOL Conversion -> UNIX (LF)

save"

cartersocha avatar Aug 12 '22 04:08 cartersocha

We discussed this in the sig meeting today.

Was the resolution adding a comment to the gradlew file or EOF character or something else? @puckpuck

cartersocha avatar Aug 15 '22 17:08 cartersocha

@echuang81 , @joshleecreates 90% chance it's a file ending issue. Please try this solution or this one and report if either works!

cartersocha avatar Aug 16 '22 05:08 cartersocha

Closing as this has now been solved to our knowledge. https://github.com/open-telemetry/opentelemetry-demo/blob/main/docs/docker_deployment.md#windows-pre-requisites

cartersocha avatar Aug 18 '22 00:08 cartersocha

=> ERROR [ghcr.io/open-telemetry/demo:v0.3.4-adservice builder 6/7] RUN ./gradlew downloadRepos 0.9s => CANCELED [ghcr.io/open-telemetry/demo:v0.3.4-featureflagservice builder 1/18] FROM docker.io/hexpm/elixir:1.13.3-erlang-25.0-debian-bullseye-202 0.9s => => resolve docker.io/hexpm/elixir:1.13.3-erlang-25.0-debian-bullseye-20210902-slim@sha256:319af72370fdded0a0a7ea976c2d7a0d5c465b901ab0bb2b2440cb0 0.0s => => sha256:a1edbbb43e6863c79911a71177e71c9781bbffe20edfe14cb532a0f688490d33 2.33kB / 2.33kB 0.0s => => sha256:319af72370fdded0a0a7ea976c2d7a0d5c465b901ab0bb2b2440cb0f23f1b650 772B / 772B 0.0s => => sha256:ffc8fc0c5b925981f57363ef56effdc6e657e0d141fdcfbbb749c145fe394db9 1.16kB / 1.16kB 0.0s => [ghcr.io/open-telemetry/demo:v0.3.4-featureflagservice internal] load build context 0.1s => => transferring context: 5.09kB 0.0s => CANCELED [ghcr.io/open-telemetry/demo:v0.3.4-featureflagservice stage-1 1/6] FROM docker.io/library/debian:bullseye-20210902-slim@sha256:e3ed4be2 0.9s => => resolve docker.io/library/debian:bullseye-20210902-slim@sha256:e3ed4be20c22a1358020358331d177aa2860632f25b21681d79204ace20455a6 0.0s => => sha256:e3ed4be20c22a1358020358331d177aa2860632f25b21681d79204ace20455a6 1.85kB / 1.85kB 0.0s => => sha256:8aa2e47f9a6cf001ecf3ad0f8439e1005743a3024b98e7bbf023ace55afea903 529B / 529B 0.0s => => sha256:7beb0248fd8163ea6effdf58af3e836c47f2f97d7e44e5109c95333c92190a48 1.46kB / 1.46kB 0.0s => CACHED [ghcr.io/open-telemetry/demo:v0.3.4-frontend deps 2/5] RUN apk add --no-cache libc6-compat 0.0s => CACHED [ghcr.io/open-telemetry/demo:v0.3.4-frontend deps 3/5] WORKDIR /app 0.0s => CACHED [ghcr.io/open-telemetry/demo:v0.3.4-frontend deps 4/5] COPY ./src/frontend/package*.json ./ 0.0s => CANCELED [ghcr.io/open-telemetry/demo:v0.3.4-frontend deps 5/5] RUN npm ci 2.2s

[ghcr.io/open-telemetry/demo:v0.3.4-adservice builder 6/7] RUN ./gradlew downloadRepos: #0 0.845 /bin/sh: 1: ./gradlew: not found


failed to solve: executor failed running [/bin/sh -c ./gradlew downloadRepos]: exit code: 127

This is still failing after following the latest instructions. Please reopen this.

cijothomas avatar Sep 08 '22 20:09 cijothomas

My bad. It does work with the newest instruction. I missed the part about "delete and re-clone the repo".

cijothomas avatar Sep 08 '22 20:09 cijothomas

My bad. It does work with the newest instruction. I missed the part about "delete and re-clone the repo".

All good :) glad we got this fully closed!

cartersocha avatar Sep 08 '22 20:09 cartersocha