Problem with the loading of model

Good morning everyone.

I’m trying to load my model.stan, however it takes a very large time (after 3 hours it does not finish). I’m using MacBook Pro with Ventura 13.0. The same model in my other pc with windows system work and takes some minutes to be loaded. Can anyone help me please ?

You can observe the code below.

# start simulation choosing zone and number of simulation
# possible zones: nord, centro, sud

zone <- "sud"
number_simulation <- 1

library(rstan)
library(gridExtra)
library(truncnorm)

rstan_options (auto_write = TRUE)
options (mc.cores = parallel::detectCores ())
rstan_options(javascript = FALSE)

wd <- getwd()
wd_directory <- paste0(wd,"/Output","/Directory")
setwd(wd_directory)
wd_dir <- readRDS("directory.rds")
setwd(wd_dir)
wd_OP <- paste0(wd_dir,"/Output")
wd_input <- paste0(wd_dir,"/Input")
wd_output <- paste0(wd_OP,"/Fitting_simulations")
dir.create(wd_output,  recursive = TRUE, showWarnings = FALSE)



init <- readRDS(paste0(wd_OP,"/Initial_conditions_simulations/initial_parameters_",zone,".rds"))
data_model <- readRDS(paste0(wd_OP,"/Datasets_simulations/data_model_",zone,".rds"))
model <- stan_model(paste0(wd_input,"/Models/Model_",zone,".stan"))


If I interrupt R I obtain this error:

make cmd is
  make -f '/Library/Frameworks/R.framework/Resources/etc/Makeconf' -f '/Library/Frameworks/R.framework/Resources/share/make/shlib.mk' -f '/Users/andreabizzotto/.R/Makevars' CXX='$(CXX14) $(CXX14STD)' CXXFLAGS='$(CXX14FLAGS)' CXXPICFLAGS='$(CXX14PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX14LDFLAGS)' SHLIB_LD='$(SHLIB_CXX14LD)' SHLIB='fileac444a73971.so' OBJECTS='fileac444a73971.o'

make would use
clang++ -mmacosx-version-min=10.13 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I"/Library/Frameworks/R.framework/Versions/4.2/Resources/library/Rcpp/include/"  -I"/Library/Frameworks/R.framework/Versions/4.2/Resources/library/RcppEigen/include/"  -I"/Library/Frameworks/R.framework/Versions/4.2/Resources/library/RcppEigen/include/unsupported"  -I"/Library/Frameworks/R.framework/Versions/4.2/Resources/library/BH/include" -I"/Library/Frameworks/R.framework/Versions/4.2/Resources/library/StanHeaders/include/src/"  -I"/Library/Frameworks/R.framework/Versions/4.2/Resources/library/StanHeaders/include/"  -I"/Library/Frameworks/R.framework/Versions/4.2/Resources/library/RcppParallel/include/"  -I"/Library/Frameworks/R.framework/Versions/4.2/Resources/library/rstan/include" -DEIGEN_NO_DEBUG  -DBOOST_DISABLE_ASSERTS  -DBOOST_PENDING_INTEGER_LOG2_HPP  -DSTAN_THREADS  -DUSE_STANC3 -DSTRICT_R_HEADERS  -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION  -DBOOST_NO_AUTO_PTR  -include '/Library/Frameworks/R.framework/Versions/4.2/Resources/library/StanHeaders/include/stan/math/prim/fun/Eigen.hpp'  -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1   -I/usr/local/include   -fPIC  -Wall -g -O2  -O3 -mtune=native -arch x86_64 -ftemplate-depth-256 -c fileac444a73971.cpp -o fileac444a73971.o
if test  "zfileac444a73971.o" != "z"; then \
	  echo clang++ -mmacosx-version-min=10.13 -std=gnu++14 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L"/Library/Frameworks/R.framework/Resources/lib" -L/usr/local/lib -o fileac444a73971.so fileac444a73971.o  '/Library/Frameworks/R.framework/Versions/4.2/Resources/library/rstan/lib//libStanServices.a' -L'/Library/Frameworks/R.framework/Versions/4.2/Resources/library/StanHeaders/lib/' -lStanHeaders -L'/Library/Frameworks/R.framework/Versions/4.2/Resources/library/RcppParallel/lib/' -ltbb   -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation; \
	  clang++ -mmacosx-version-min=10.13 -std=gnu++14 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L"/Library/Frameworks/R.framework/Resources/lib" -L/usr/local/lib -o fileac444a73971.so fileac444a73971.o  '/Library/Frameworks/R.framework/Versions/4.2/Resources/library/rstan/lib//libStanServices.a' -L'/Library/Frameworks/R.framework/Versions/4.2/Resources/library/StanHeaders/lib/' -lStanHeaders -L'/Library/Frameworks/R.framework/Versions/4.2/Resources/library/RcppParallel/lib/' -ltbb   -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation; \
	fi
Warning message:
In readLines(file, warn = TRUE) :
  incomplete final line found on '/Users/andreabizzotto/Desktop/University/Covid19_italy/Codes/Input/Models/Model_sud.stan'
Error in sink(type = "output") : invalid connection


Operating System: Ventura 13.0
Compiler: RStudio

is there a newline missing from your Stan file Model_sud.stan?

(cf: 'Incomplete final line' warning when trying to read a .csv file into R - Stack Overflow)

Actually it does not miss… I think I have some problem with C but I am not an expert so I don’t know what I have to do.