Error: the command make collectstatic could not be found within PATH or Pipfile's [scripts]


#1

Hi there,

I’m struggling to solve this one. At the end of my config, I have:

- run:
    command: |
      pipenv run "make collectstatic"
      pipenv run "make detect-migrations"
      pipenv run "make test"

And this is exactly where my job is failing:

#!/bin/bash -eo pipefail pipenv run “make collectstatic” pipenv run “make detect-migrations” pipenv run “make test”

Error: the command make collectstatic could not be found within PATH or Pipfile’s [scripts]. Exited with code 1

Any ideas on what may be causing this?

Here’s my full config file:

# Python CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-python/ for more details
#
version: 2
jobs:
  build:
    docker:
      - image: circleci/python:3.6.6
        environment:
          PIPENV_VENV_IN_PROJECT: true
          DATABASE_URL: postgresql://root@localhost/circle_test?sslmode=disable
      - image: circleci/postgres:10.3
        environment:
          POSTGRES_USER: root
          POSTGRES_DB: circle_test
    steps:
      - checkout
      - run: sudo chown -R circleci:circleci /usr/local/bin
      - run: sudo chown -R circleci:circleci /usr/local/lib/python3.6/site-packages
      - restore_cache:
          key: deps9-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
      - run:
          command: |
            sudo pip install pipenv
            pipenv install --dev
      - save_cache:
          key: deps9-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
          paths:
            - ".venv"
            - "/usr/local/bin"
            - "/usr/local/lib/python3.6/site-packages"
      - run:
          command: |
            pipenv run "make collectstatic"
            pipenv run "make detect-migrations"
            pipenv run "make test"

#2

I haven’t used pipenv, but I’m assuming you’re attempting to run a regular make command, that I’m guessing does some python things that you want to ensure occurs within the context of the python virtualenv setup by pipenv.

maybe throw a quick

- run:
    command: |
      which make

in ahead of your pipenv run commands, to confirm if make is installed in the python image.


#3

That’s a good idea — but that part passed alright, see:


#4

Hmmm, I wonder. I use pyenv and pyenv-virtualenv. If I want to run python commands on different run steps I need to do this:

source ~/.bash_profile && pyenv activate venv-py3.6.5

So, again, having not use pipenv maybe there’s some initialisation to be done, as each run command is a separate shell being executed.

Maybe this is where you do an environment exploration, I do this all the time, I find it helps, something along that line, so if you

- run:
    command: |
      which make
      pipenv run which make
      echo $PATH
      pipenv run echo $PATH
      export

I tend to do this just to confirm the assumptions that I have. I’ve found it helps maybe at least steer you in the right direction. I actually have an alias yaml snippet with a bunch of these commands in there and I can then just drop in this anchor where I need to fault find things, just before and after problem commands etc.

<<: *explore_environment

I can’t wait to try it out with orbs that are present in 2.1, so I don’t have to include the long list of commands everytime and also to share across repos.


#5

Thanks for your help, @grahamw! Here’s the output of that environment exploration:

#!/bin/bash -eo pipefail
which make
pipenv run which make
echo $PATH
pipenv run echo $PATH

/usr/bin/make
/usr/bin/make
/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Strange, ahm? Any thoughts?

a.


#6

No sorry, that’s weird. Maybe rerun the build with SSH and execute the commands manually to debug further. I’ve barely used pipenv, so I don’t know why it’d be complaining about not found in path when then which command works. Just make sure all the environment variables look right before you, though I think they are still set when you use the rebuild with SSH.

Oh, and just to cover off, you don’t have a typo in the name of your make target your executing with the pipenv run command compared to the makefile in that directory do you?


#7

I finally found out what was causing the CI to fail: the quotes after the pipenv run command.

This works:

- run:
          command: |
            pipenv run make collectstatic
            pipenv run make detect-migrations
            pipenv run make test

No idea why, but that solved it.


#8

Wow, yeah, strange one, but glad it’s fixed. :+1: