Error in Lyx call for rscript

I am using Lyx (2.06) on OS X (10.8.3) with R (3.01). I am trying to import a knitr file into Lyx. Lyx can find Rstudio, but Rscript does not work on the setwd command. The error log from Lyx is shown below. Any help is appreciated. (My first post on Stackoverflow. Sorry in advance for any inconvenient formatting.)

10:43:17.114: Importing ~/Documents/Temp/stest.lyx... 10:43:17.122: Rscript --verbose --no-save --no-restore "/Applications/LyX.app/Contents/Resources/scripts /lyxknitr.R" "/Users/wms5f/Documents/Temp/""stest.Rnw" "/Users/wms5f/Documents/Temp/""stest.tex" "/Users/wms5f/Documents/Temp/" 10:43:17.124: running 10:43:17.125: '/Library/Frameworks/R.framework/Versions/3.0/Resources/bin/R --slave --no-restore --no-save --no-restore --file=/Applications/LyX.app/Contents/Resources/scripts/lyxknitr.R --args /Users/wms5f/Docu 10:43:17.126: ments/Temp/stest.Rnw /Users/wms5f/Documents/Temp/stest.tex' 10:43:17.126: <.snip.> 10:43:18.424: 10:43:18.603: Package `sm', version 2.2-5: type help(sm) for summary information 10:43:20.609: Error in setwd(.cmdargs[4]) : missing value is invalid 10:43:20.610: Execution halted Running: Rscript --verbose --no-save --no-restore "/Applications/LyX.app/Contents/Resources/scripts/lyxknitr.R" "/Users/wms5f/Documents/Temp/""stest.Rnw" "/Users/wms5f/Documents/Temp/""stest.tex" "/Users/wms5f/Documents/Temp/" support/Systemcall.cpp (273): Systemcall: 'Rscript --verbose --no-save --no-restore "/Applications/LyX.app/Contents/Resources/scripts/lyxknitr.R" "/Users/wms5f/Documents/Temp/""stest.Rnw" "/Users/wms5f/Documents/Temp/""stest.tex" "/Users/wms5f/Documents/Temp/"' finished with exit code 1 Error: Cannot convert file An error occurred while running: Rscript --verbose --no-save --no-restore "/Applications/LyX.app/Contents/Resources/scripts/lyxknitr.R" "/Users/wms5f/Documents/Temp/""stest.Rnw" "/Users/wms5f/Documents/Temp/""stest.tex" "/Users/wms5f/Documents/Temp/" 10:43:55.912: file not imported! 10:43:55.913: (buffer-import knitr) 10:44:04.097: (dialog-show prefs: ⌘,) 

Explanation added:

Perhaps I was not very clear in my first post. I have a file called stest.Rnw that contains the following sweave code:

 \documentclass{article} \begin{document} Test \end{document} 

If I try to import this file into Lyx 2.06 using the Import -> Rnw (knitr) option, Lyx generates the following system command:

 Rscript --verbose --no-save --no-restore "/Applications/LyX.app/Contents/Resources/scripts/lyxknitr.R" "/Users/wms5f/Documents/Temp/""stest2.Rnw" "/Users/wms5f/Documents/Temp/""stest2.tex" "/Users/wms5f/Documents/Temp/" 

This command does not work when run from a bash prompt, or from within Lyx. I noticed extra double quotes, but deleting them before running the script got the same result. It doesn't seem like rscript is able to parse the 4th argument, which is just a directory. R never gets parsed by sweave, because it fails to initially parse the arguments passed to it by Lyx. At least that's how I read the error message.

I hope this will be helpful.

+4
source share
1 answer

You tried to import an Rnw file into LyX, which is not yet supported in LyX 2.0.6. It will appear in LyX 2.1: http://www.lyx.org/trac/ticket/7838

When LyX 2.1 is released, you can import it through the command line:

 tex2lyx -n -m knitr stest.Rnw 

I'm not sure why LyX needs to call Rscript when importing a file. You can send a bug report to LyX.

+3
source

Source: https://habr.com/ru/post/1485294/


All Articles