diff --git a/R/monolix2rx.R b/R/monolix2rx.R index 65cd74f..acdb67c 100644 --- a/R/monolix2rx.R +++ b/R/monolix2rx.R @@ -89,10 +89,12 @@ monolix2rx <- function(mlxtran, update=TRUE, thetaMatType=c("sa", "lin"), .admd <- NULL .cmt <- NULL if (!is.null(.mlxtran$MODEL$LONGITUDINAL$LONGITUDINAL$file)) { - if (!file.exists(.mlxtran$MODEL$LONGITUDINAL$LONGITUDINAL$file)) { - stop("the model file '", .mlxtran$MODEL$LONGITUDINAL$LONGITUDINAL$file, "' does not exist\nyou may need to setup the model library to complete translation", - call.=FALSE) - } + withr::with_dir(.monolixGetPwd(.mlxtran), { + if (!file.exists(.mlxtran$MODEL$LONGITUDINAL$LONGITUDINAL$file)) { + stop("the model file '", .mlxtran$MODEL$LONGITUDINAL$LONGITUDINAL$file, "' does not exist\nyou may need to setup the model library to complete translation", + call.=FALSE) + } + }) } if (is.null(.mlxtran$MODEL$LONGITUDINAL$EQUATION) && !is.null(.mlxtran$MODEL$LONGITUDINAL$PK)) {