System command 'make' failed. Models won't compile

@emily_ann Sorry for the hassle. Are you able to delete the OneDrive folder? Also what does cmdstan_path() return?

@andrjohns @WardBrian we’re getting more reports like this on the forum (and I’ve had several reported to me privately by other collaborators). Any ideas for how we can avoid these issues or something we can document somewhere to help people avoid it? It seems like OneDrive folders are interfering even when CmdStan is not installed in the OneDrive folder (in some cases it may have been but I’ve seen others where cmdstan_path() is set to the default location or somewhere other than a OneDrive folder, but there’s still a OneDrive related error).

cmdstan_path() returns:

C:/Users/{username}/OneDrive - {Agency}/Documents/.cmdstan/cmdstan-2.32.2

I’m hesitant to delete the folder, I would have to talk to IT.

Hmm, unlike the previous user in this thread who fixed this issue by deleting the OneDrive folder, in this case it looks like CmdStan is actually installed inside the OneDrive folder. Are you able to install it somewhere outside of OneDrive?

If I had to guess, these users have %HOME% set to the one drive location, and cmdstanr is using it. Note that this is bad practice on cmdstanr’s part, %HOME% is not one of the standard environment variables on Windows so it can be set to more or less anything (or nothing at all!) unless R is stepping in and monkeypatching this.

In CmdStanPy we use os.path.expanduser which uses a combination of things instead of %HOME% on windows:

On Windows, USERPROFILE will be used if set, otherwise a combination of HOMEPATH and HOMEDRIVE will be used. An initial ~user is handled by checking that the last directory component of the current user’s home directory matches USERNAME, and replacing it if so.

I haven’t seen issues with cmdstanpy and OneDrive yet, so I strongly suspect this difference is the reason

3 Likes

Interesting, I didn’t know that! @rok_cesnovar @andrjohns Should we change this in cmdstanr and try to follow what cmdstanpy is doing?

Yeah that makes sense for some of the cases we’ve seen, but there are other cases where the install is not the default location and not inside a OneDrive directory. For example, @Stan_Idiot above said their installation was in

so no OneDrive anywhere, except the error message was

So this seems like it wouldn’t be related to the HOME issue, unless I’m misunderstanding (quite possible).

1 Like

Hello, I’m a Stan/coding novice and I’d really appreciate help installing cmdstan. Like others here, I think OneDrive is causing me issues. I’ve tried different solutions posted online, including reinstalling Rstan and CmdStan many different ways, but still no success, although the errors I get have evolved. At the moment when I try running the ulam() function I get the following error:

Compiling Stan program...
Error in `(function (command = NULL, args = character(), error_on_status = TRUE, …`:
! System command 'make' failed
---
Exit status: 2
Stderr:
make: *** /c/Users/{username}/OneDrive: Is a directory.  Stop.
---

Running cmdstan_path() returns:
C:/Users/z3389438/OneDrive - UNSW/Documents/.cmdstan/cmdstan-2.33.1

Installing cmdstan outside OneDrive on the C drive…
cmdstanr::install_cmdstan(dir = "C:/Users/z3389438/AppData/Local/R/win-library/4.3/cmdstanr")

and running…
set_cmdstan_path("C:/Users/z3389438/AppData/Local/R/win-library/4.3/cmdstanr")

still give me an error:

CmdStan path set to: C:/Users/z3389438/AppData/Local/R/win-library/4.3/cmdstanr
Warning message:
Can't find CmdStan makefile to detect version number. Path may not point to valid installation.

After adding the PATH under System Variables I get the error:
The previous installation of CmdStan had a non-empty make/local file.

Just to ‘bump’ this issue for Windows users who also have OneDrive at their institution. I also had this exact issue and it was solved by deleting that one empty OneDrive folder as described above… but boy was this a headache!

I just deleted that empty OneDrive folder and that appears to have solved the problem for me too. Previously I was afraid to try it but I had become so desperate I even tried unlinking OneDrive from my institutional computer which nearly killed it. Thank you so much for everyone’s help!

Hi,
Arriving at this issue a bit late, but I am getting this make: *** problem, but I am not using OneDrive folder. I had CmdStan working just fine a few months ago but now I am getting this error when I try to load a stan model into R:

> file <- file.path(cmdstan_path(), "MS_RD.stan")
> mod <- cmdstan_model("MS_RD.stan")
Compiling Stan program...
make: *** /Users/{username}: Is a directory.  Stop.

Error: An error occured during compilation! See the message above for more information.

Here is my cmdstan path:

> cmdstan_path() 
[1] "/Users/{username} 1/.cmdstan/cmdstan-2.33.1"

I’ve tried loading a model version saved in the cmdstan folder and in a folder for the project I am working on. Both fail.

Any ideas on what could be causing this?

Just giving an update as I had the same issue and the solutions in this thread helped.

It appears that (like in my case) the organisation IT sets up the One Drive account as the default location for installations. This leaves the empty OneDrive folder (the original one) which can be deleted - leaving the One Drive - Organisation bla bla folder intact.

CmdStan will install in this One Drive folder by default if the organisation has set up the machine this way. The problem appears to go away when the older ‘One Drive’ folder is deleted. Thank you for the comments which helped in this case.

I’m having the very same issue on my company’s machine with OneDrive.

cmdstanr::install_cmdstan(dir = "C:/Stan", overwrite = TRUE, check_toolchain = TRUE)

set_cmdstan_path(path = "C:/Stan/cmdstan-2.34.1")

even after adding an environment variable pointing to “C:\Stan\cmdstan-2.34.1”, executing:

cmdstanr::cmdstanr_example("schools_ncp", "sample", quiet = FALSE)

produces the same error as others have complained:

---
Exit status: 2
Stderr:
make: *** /c/Users/MyUserName/OneDrive: Is a directory.  Stop.
---

I’ve tried everything I could think to no avail. To @jonah point, no OneDrive anywhere. My guess is that somewhere in a library or elsewhere is defaulting to %HOME% which points to OneDrive?

Can you share the value of the following 4 environment variables from inside R?

Sys.getenv("HOME")
Sys.getenv("USERPROFILE")
Sys.getenv("HOMEDRIVE")
Sys.getenv("HOMEPATH")

Thanks. Here’s what I have:

> Sys.getenv("HOME")
[1] "C:\\Users\\MyUserName\\OneDrive\\Documents"
> Sys.getenv("USERPROFILE")
[1] "C:\\Users\\MyUserName"
> Sys.getenv("HOMEDRIVE")
[1] "C:"
> Sys.getenv("HOMEPATH")
[1] "\\Users\\MyUserName"

Great, this in part confirms that the solution I proposed earlier will work. @jonah @andrjohns - it’s still probably easier for you guys to write it than me, but here is pseudocode of the logic needed to correctly get a home directory on windows:

if $USERPROFILE is set:
  return $USERPROFILE
else:
  return path_join($HOMEDRIVE, $HOMEPATH)

You can see Python doing something very similar here, with the extra complexity being from the fact that Python also tries to resolve links like ~some_other_username/, which we don’t need now.

1 Like

@rok_cesnovar @andrjohns I’ll defer to your Windows judgement on this, but seems like we should use this?

1 Like

Yeah, I agree!

Ok cool, would you be able to add that when you have time?

1 Like

The following worked for me on Windows with (dreaded, forced OneDrive), as per advice from @WardBrian.

library(cmdstanr)

# save old HOME
oldHOME<-Sys.getenv("HOME")

# reset HOME
Sys.setenv(HOME = "C:\\Users\\LXT")

# compile model
model1 <- cmdstanr::cmdstan_model("test.stan")

# if you want to set HOME back...
Sys.setenv(HOME=oldHOME)

Had the same problem, and your solution worked for me too!! Big thanks