File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -195,9 +195,9 @@ async function callR<T>(
195195 outputFilter ?: ( output : string ) => string ,
196196 reportError = true ,
197197) : Promise < T > {
198- // establish cwd for execute (the current dir if there is an renv
198+ // establish cwd for our R scripts (the current dir if there is an renv
199199 // otherwise the project dir if specified)
200- const cwd = withinActiveRenv ( ) ? undefined : projectDir ;
200+ const cwd = withinActiveRenv ( ) ? Deno . cwd ( ) : projectDir ?? Deno . cwd ( ) ;
201201
202202 // create a temp file for writing the results
203203 const resultsFile = Deno . makeTempFileSync (
@@ -208,6 +208,7 @@ async function callR<T>(
208208 action,
209209 params,
210210 results : resultsFile ,
211+ wd : cwd ,
211212 } ) ;
212213
213214 try {
Original file line number Diff line number Diff line change 137137 request <- jsonlite :: parse_json(input , simplifyVector = TRUE )
138138 params <- request $ params
139139
140+ # Ensuring expected working dir for Quarto
141+ # R process workding may be changed by some workflows (in ~/.Rprofile)
142+ # https://github.com/quarto-dev/quarto-cli/issues/2646
143+ setwd(request $ wd ) # no need to reset it as R process is closed by R
144+
140145 # source in helper functions if we have a resourceDir
141146 if (! is.null(params $ resourceDir )) {
142147 res_dir <- file.path(params $ resourceDir , " rmd" )
You can’t perform that action at this time.
0 commit comments