G++ not found

I am unable to run any ulam() code, or even the following:

    schools_dat <- list(J = 8, 
                         y = c(28,  8, -3,  7, -1,  1, 18, 12),
                         sigma = c(15, 10, 16, 11,  9, 11, 10, 18))
    fit <- rstan::stan(file = 'schools.stan', data = "schools_dat")

The message I get is:

'C:/rtools40/usr/mingw_/bin/g++' not found

But I see g++ sitting right here:


So this seems like a path problem. I believe the solution is to change the path in the Makevars file, but I have no idea how to do that. I would appreciate step-by-step instructions on that solution, or suggestions on other possible solutions.

I’m using:

Windows 10
R 4.0.3

Hi @zpalqm, welcome to the Stan forums and sorry you’re running into trouble getting Stan running. I’m not great with Windows personally, but have you seen these instructions yet? https://github.com/stan-dev/rstan/wiki/Configuring-C---Toolchain-for-Windows. If you have R 4.0.3 then the stuff in the section for R 4.0 would apply.

If you’ve already gone through those instructions (like the steps for checking BINPREF) and it still isn’t working then hopefully one of my Windows literate colleagues like @andrjohns or @bgoodri will be able to help you get this fixed.

Thanks, @jonah. I just followed the instruction at that link, but the issue persists.

That warning is harmless and does not affect sampling in any way. Does the model sample and then give that warning or is there no sampling at all (i.e., no fit object in the workspace)?

@andrjohns The process just runs endlessly with no output until I manually stop it. Then I get the warning, with nothing else.

Can you run the model with verbose=T and post the output?

successful in parsing the Stan model 'schools'.
'C:/rtools40/usr/mingw_/bin/g++' not found
Error in data_list2array(x) : 
  the dimensions for all elements (array) of the list are not same
failed to preprocess the data; sampling not done

Ah there’s the error, it looks like a data issue not a c++ issue.

What happens when you run:

example(stan_model, package="rstan", run.dontrun=T)


I think that worked. Here’s the last part of the output:

Chain 4:  Elapsed Time: 0.016 seconds (Warm-up)
Chain 4:                0.014 seconds (Sampling)
Chain 4:                0.03 seconds (Total)
Chain 4: 
Warning message:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
  'C:/rtools40/usr/mingw_/bin/g++' not found

Oh I believe the issue is that you’re specifying the data with quotations:

data = "schools_dat"

So it’s trying to pass a string as data. Can you try running the model without quotations around the data list?

1 Like

That worked! As for my ulam code, now I think the problem was just that it takes an extremely long to run, so I was giving up on it assuming it was stuck and that the warning message was telling me the reason.


So I can ignore that warning? Or should I still try to address it?

Nope the warning is safe to ignore, its just a misconfiguration on the back end that will be fixed in the next release

Great, thanks for your help.

1 Like