0

I am working on setting up a new M1 Silicon Monterey OS Mac and my handy-dandy Sweave engine that I like to add to Texshop does not work. I have a Sweave.engine file in my Engines folder with the following:

#!/bin/bash

export PATH=$PATH:/usr/texbin:/usr/local/bin R CMD Sweave “$1” pdflatex “${1%.*}“

It creates the drop down menu, but it seems unhappy about the path (as best I can guess) as it says it cannot find the file. Similarly running line by line in Terminal I get:

Mecomputerhere:~ lizzie$ R CMD Sweave “$1”
Error in (function (file, dir = ".", weave = TRUE, latex = TRUE, tangle = TRUE,  : 
  file '“”' not found
Calls: <Anonymous> -> do.call -> <Anonymous>
Execution halted

Here's the error in the tex console:

`Error in (function (file, dir =".", weave = TRUE, latex = TRUE, tangle = TRUE, : 
file `”test.Rnw”’ not found 
Calls: <Anonymous> -> do. call -> <Anonymous>
Execution halted
This is pdfTeX, Version 3.141592653-2.6-1.40.24 (Tex Live 2022)
(preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
! I can't find file `”test”’.
<*>"test"

I suspect this is a basic path issue (I am bad at paths) so any help would be much appreciated. Thanks in advance.

Update: This version of the engine code works:

#!/bin/bash
export PATH=$PATH:/usr/texbin:/usr/local/bin
R CMD Sweave "$1"
pdflatex "${1%.*}"
  • Welcome to TeX.se. Are you running sweave on the .Rnw file? The error you're getting looks like what happens when you run it on a .tex file. My sweave engine is identical, and works fine on MacOS 12.3. Your second command fails because you need to provide R CMD Sweave with an actual .Rnw filename, not "$1" which is a script variable. – Alan Munn Apr 28 '22 at 20:41
  • Thanks! Yes, I am running sweave on the .Rnw. If our sweave engines are identical then you also have the line: R CMD Sweave “$1” In your engine? I assumed that “$1” was some sort of expression to point to whatever the current file was. – user18967339 Apr 28 '22 at 23:18
  • Yes it’s identical. $1 is the first argument passed to the script, which when called within TeXShop will be the current file. Can you edit your question to show the actual error you get in the console when you try to use the engine? – Alan Munn Apr 29 '22 at 00:05
  • Thanks for your help. I had trouble copying from the `console' in Texshop. I have added it now to the question. – user18967339 Apr 29 '22 at 00:29
  • Is there really a space in your file name? It looks like “test. Rnw”. If so that’s certainly the problem. – Alan Munn Apr 29 '22 at 00:40
  • No, there's no space -- I just had to awkwardly cut and paste console output. My apologies, I know writing it correctly is critical but I cannot seem to copy from the console output directly or upload a screenshot. – user18967339 Apr 29 '22 at 00:47
  • No worries! I’m a bit stumped now. What happens if you do R CMD Sweave test.Rnw from the directory that contains the file? – Alan Munn Apr 29 '22 at 00:52
  • It just runs. Output file: test.tex – user18967339 Apr 29 '22 at 02:36
  • Based on Alan Munn's feedback here, I decided to just replace the file I had on my new computer with the exact file from my old computer (pasted above) and it worked! There's either some small difference in the code that I cannot see, or that empty line causes all the problems. Thank you so much for the help! I would not have tried this on my own. – user18967339 May 03 '22 at 01:12

0 Answers0