@@ -349,20 +349,22 @@ def compile_example(verbose: bool = False) -> None:
349349
350350 :param verbose: Boolean value; when ``True``, show output from make command.
351351 """
352- cmd = [
353- MAKE ,
354- Path (
355- os .path .join ('examples' , 'bernoulli' , 'bernoulli' + EXTENSION )
356- ).as_posix (),
357- ]
352+ path = Path ('examples' , 'bernoulli' , 'bernoulli' ).with_suffix (EXTENSION )
353+ if path .is_file ():
354+ path .unlink ()
355+
356+ cmd = [MAKE , path .as_posix ()]
358357 try :
359358 if verbose :
360359 do_command (cmd )
361360 else :
362361 do_command (cmd , fd_out = None )
363362 except RuntimeError as e :
364363 # pylint: disable=raise-missing-from
365- raise CmdStanInstallError (f'Command "make clean-all" failed\n { e } ' )
364+ raise CmdStanInstallError (f'Command "{ " " .join (cmd )} " failed:\n { e } ' )
365+
366+ if not path .is_file ():
367+ raise CmdStanInstallError ("Failed to generate example binary" )
366368
367369
368370def rebuild_cmdstan (
@@ -421,8 +423,6 @@ def install_version(
421423 clean_all (verbose )
422424 print ('Rebuilding version {}' .format (cmdstan_version ))
423425 build (verbose , progress = progress , cores = cores )
424- print ('Test model compilation' )
425- compile_example (verbose )
426426 print ('Installed {}' .format (cmdstan_version ))
427427
428428
@@ -638,6 +638,10 @@ def run_install(args: Union[InteractiveSettings, InstallationSettings]) -> None:
638638 else :
639639 print ('CmdStan version {} already installed' .format (args .version ))
640640
641+ with pushd (cmdstan_version ):
642+ print ('Test model compilation' )
643+ compile_example (args .verbose )
644+
641645
642646def parse_cmdline_args () -> Dict [str , Any ]:
643647 parser = argparse .ArgumentParser ("install_cmdstan" )
0 commit comments