Error locating workspace root directory: stat


#1

image: circleci/node:latest

My build outputs its results into a build subdirectory, which is accessible via SSH at ~/projectName/build

      - persist_to_workspace:
          root: build
          paths:
            - .

I have this in my config (the documentation for this isn’t on the website by the way, as the root required key is not documented by required).

However, on the step I get the error:

Error locating workspace root directory: stat ~/projectName/build: no such file or directory
```

The command works if I were to SSH into the container and run it manually.

Unable to progress using workflows any further since the next job requires the items in the workspace.

#2

I’m having the same issue. I copied the example script from github and modified it slightly for my build. The directory is listed by the ls commands in the 2nd checkout_code step, but persist_to_workspace always fails with this error.


#3

If it helps, my full config.yml is:

version: 2.0

jobs:
  checkout_code:
    working_directory: ~/tmp
    docker:
      - image: circleci/clojure:lein-2.7.1
    steps:
      - checkout
      - run:
          name: post checkout check
          command: |
            echo $PWD
            ls -aslh .
            ls -aslh ~
            ls -aslh ~/tmp
      - persist_to_workspace:
          root: .
          paths:
            - .

  build_site:
    working_directory: ~/tmp
    docker:
      - image: circleci/clojure:lein-2.7.1
    steps:
      - attach_workspace:
          at: ~/tmp

      - run:
          name: build
          command: |
            lein run

      - persist_to_workspace:
          root: .
          paths:
            - resources/public

  deploy:
    working_directory: ~/tmp
    machine:
        enabled: true

    steps:
      - attach_workspace:
          at: ~/tmp/resources/public

      - run:
          name: Are my assets here?
          command: |
            pwd
            ls -lrt
            
      - run:
          name: Is awscli here?
          command: |
            aws -v

workflows:
  version: 2
  build-and-deploy:
    jobs:
      - checkout_code
      - build_site:
          requires:
            - checkout_code
      - deploy:
          requires:
            - checkout_code
            - build_site



#4

Had the same issue! I could fix it using an absolute url for the root key, e.g.: in my node image I use working_directory: ~/app and I set:

- persist_to_workspace:
     root: /root/app
     path: .

#5

Hi,

Having the same issue. Tried this approach with /root/app and I got permission denied error.

A little stuck here, need help. Any ideas?

Thanks


#6

Update - managed to get it working. My working dir was ~/app, therefore the root for the workspace had to be /home/circleci/app and it magically worked…


#7

Hello!

Could you take a look at this example and see if it helps make sense of this?

Happy to answer any questions!


#8

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.