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:

C:\rtools40\mingw64\bin

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
RTools40

Hi @anon38878713, 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.

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)?

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

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)

?

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?

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