Make cpplint does not run

I tried running make cpplint and got the following message:

make: *** [cpplint] Error 1

I’ve never had issues before. I downloaded a new Stan repo (in case I had inadvertently changed a file in my current directory), but the error persists. Anyone else experiencing this?

git clone --recursive

Followed by a make cpplint worked for me

Maybe just try executing the make/cpplint rule manually? Looks like it’d be safe to copy-paste and go

1 Like

I also get

find: ‘stan’: No such file or directory
make/cpplint:5: recipe for target 'cpplint' failed
make: *** [cpplint] Error 1

From within the stan directory, can you run this to get the math submodule?

git submodule update --init --recursive

Then run make cpplint again.

I get the find: ‘stan’: No such file or directory thing too, but then things run.

I think I had done that, and did it again, but no change

That rule has $(CPPLINT), but I can’t find where it is set.

cpplint should be in stan/lib/stan_math/lib/cpplint_4.45/

edit: or whatever the correct version of cpplint is

Ok. That was the easiest problem to check.

$(CPPLINT) is defined in make/cpplint (or something similar; I’m working off memory typing on my phone).

CppLint requires Python 2 and won’t work with Python 3. I forget what error it produces, but hopefully that’s the issue. There should be a PYTHON2 make variable that you can set if you have one installed.

Yup. It’s PYTHON2:

You can either set it when you call make it put it in make/local.

Let me know if that fixes it.

It’s there

Not in my make/cpplint and I tried to find where it could be defined by grep, but no luck

It’s defined in the math library.

FWIW, it looks like there’s a fork of CppLint that is alleged to have Python 3 compatibility:

1 Like

Ok, I got it running now. The problem was that stan/make/cpplint had definition

PYTHON2 ?= python

It seems distros have started switching the default to Python 3, which is very sensible considering that Python 2 will not be maintained beyond 2020 and many major packages have dropped the support already.


python -c "print(__import__('sys').version.split(' ' )[0].split('.')[0])"

returns 3, then make should try to call python2 instead.

1 Like

I tried @bbbales2 and @syclik’s advice, with no success. I have python 3 on my machine. @avehtari, did you edit the make file? And how so? I tried replacing PYTHON2 ?= python with PYTHON3 ?= python but the error persists.

I also don’t get much info, just:

charlesm:math charlesm$ make cpplint
make: *** [cpplint] Error 1

I edited make/cpplint to have line

PYTHON2 ?= python2

Please don’t edit the make/cpplint file directly. You should be able to accomplish the same by putting this inside make/local or ~/.config/stan/make.local:

PYTHON2 = python2

@charlesm93, you need to have Python2 installed.

Installed python2 and created a new environment in anaconda. Was then able to run the regular make cpplint file.

1 Like

Don’t worry, I’m not going to push that. It was just a quick test. I assume there will be soon a fixed make/cpplint, which can check which command to use to run Python2.

Good! =). But more importantly, that’s not the suggestion you should be giving. You should be telling everyone to use make/local or ~/.config/stan/make.local.

I don’t think so. This isn’t how make is supposed to work… to have it do it is non-trivial. We’re moving away from having make try to do magic and only have it do the things it’s supposed to do.

Unless you know how to do it. In which case, we’ll just take a pull request.

1 Like