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

Hi this is my config.yml for my Android project

Java Gradle CircleCI 2.0 configuration file

Check for more details

version: 2
# specify the version you desire here
- image: circleci/android:api-28-alpha

  # Specify service dependencies here if necessary
  # CircleCI maintains a library of pre-built images
  # documented at
  # - image: circleci/postgres:9.4

working_directory: ~/code

  # Customize the JVM maximum heap limit
  JVM_OPTS: -Xmx3200m
  TERM: dumb

  - checkout

  # Download and cache dependencies
  - restore_cache:
      key: jars-{{ checksum "build.gradle" }}-{{ checksum  "app/build.gradle" }}

  - run:
      name: Chmod permissions #if permission for Gradlew Dependencies fail, use this.
      command: sudo chmod +x ./gradlew
  - run:
      name: Download Dependencies
      command: ./gradlew androidDependencies

  - save_cache:
        - ~/.gradle
      key: v1-dependencies-{{ checksum "build.gradle" }}

and for this script i’am getting
chmod: cannot access ‘./gradlew’: No such file or directory
can anyone please help me


I am following up on old tickets in case people are running into the same issue.

The reason for this issue is due to the line: working_directory: ~/code

By default on CircleCI, you are in the ~/ folder but when you run the special checkout step using: - checkout it will do a git clone into a directory called project.

Because of this when you run ./gradlew it will fail as the gradlew file will be located under ~/project

The resolution for this is to either set ./gradlew to ~/project/gradlew or set working_directory: ~/project. If you are changing to the full path please be aware this may need to be changed for other files such as .gradle from the example given above.

Kind Regards
Owen Oliver