Troubleshooting/ common programming errors

`pandoc-citeproc` error

After updating my MacOS to Ventura, I was unable to knit documents. I ran into the following error:

[WARNING] Deprecated: pandoc-citeproc filter. Use --citeproc instead.
Error running filter pandoc-citeproc:
Could not find executable pandoc-citeproc
Error: pandoc document conversion failed with error 83
In addition: Warning message:
Can't find generic `sew` in package knitr to register S3 method.
ℹ This message is only shown to developers using devtools.
ℹ Do you need to update knitr to the latest version? 
Execution halted

Solution

This error was fixed by running: remotes::install_github("crsh/rmdfiltr")

Scripts that need internet suddenly take forever on VPN

One possibility is that the program tries to use IPv6 but Duke's VPN isn't allowing it.

The instructions are for Wi-Fi connections on MacOS computers. If that's not your case, you can do the first check and then ask Zhenya for instructions for your case.

To check that it is the same problem

Open this and this links in the browser. The first one might require you to confirm that you trust that website. If either of these doesn't open at all then this solution won't help you, sorry. If they do open, start python/iPython in the terminal and issue the following commands one by one:

import requests
requests.get('http://www.testingmcafeesites.com/')
requests.get('https://www.google.com/')

If the first one quickly outputs "<Response [200]>" but the second one hangs then this is probably the same problem.

To check if the problem has the same source

In the shell, run

networksetup -getinfo "Wi-Fi" | grep IPv6:

If it outputs IPv6: Automatic then the problem might have the same source.

To solve

Do this only if both checks above pass.

networksetup -setv6off "Wi-Fi"

Set a reminder to undo this change at some later point with

networksetup -setv6automatic "Wi-Fi"
[email protected]. Permission denied (publickey)

Example:

git@github.com: Permission denied (publickey). 
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Error in strsplit(command, "\\s+")[[1]] : subscript out of bounds
In addition: Warning messages:
1: In system2(git_bin, arguments, wait = TRUE, stdout = TRUE) :
  Running command ''/usr/bin/git' -C /Users/xx123/BLAB_DATA/cdi_spreadsheet fetch --tags --prune' had status
2: In get_df_file("cdi_spreadsheet". "cdi.feather". version = version) :

Why? You have a repository cloned from GitHub via ssh and your ssh key is no longer recognized by GitHub. Why is it no longer recognized? I don't know.

To solve

  • Look around the error message to figure out what repository is causing the problem. In the example above, it was cdi_spreadsheet.

  • Find GitHub https URL of the repo (O and the path to the BLAB_DATA folder. For cdi_spreadsheet, these are ~/BLAB_DATA/cdi_spreadsheet and https://github.com/BergelsonLab/cdi_spreadsheet.git.

  • In Terminal,

cd ~/BLAB_DATA/cdi_spreadsheet
git remote set-url origin https://github.com/BergelsonLab/cdi_spreadsheet.git
git fetch  # to check the connection
An error about gfortran when installing R packages or running renv::restore()

Follow these instructions:New computer setup

After downloading gfortran following instructions on https://mac.r-project.org/tools/, if R fails to locate it, go to the file${R_HOME}/etc/Makeconf and update the following lines to update the location of gfortran:

FC = /opt/gfortran/bin/gfortran -mtune=native
FLIBS =  -L/opt/gfortran/lib/gcc/aarch64-apple-darwin20.0/12.2.0 -L/opt/gfortran/lib -lgfortran -lemutls_w -lquadmath
Error installing package (e.g., xml2) due to unable to load shared object ...

Go to the bottom of the error message, which likely includes a line like:

Reason: tried: '/Library/Frameworks/R.framework/Resources/lib/libicuuc.73.1.dylib' (no such file), '/Library/Java/JavaVirtualMachines/jdk-17.0.1+12/Contents/Home/lib/server/libicuuc.73.1.dylib' (no such file)

This means R failed to locate a specific file required for installing the package (in the example above, libicuuc.73.1.dylib. Try searching for this file in Finder and it might show up in another folder. If that happens, create a symlink that points from the existing file to where R was looking for, e.g.,

ln -s {where the file locates} {where R wants to find the file}
ln -s /Users/lilyzihuizhu/miniconda3/lib/libicuuc.73.1.dylib /Library/Frameworks/R.framework/Resources/lib/libicuuc.73.dylib
Rstudio freezes after opening a file/R project

Try deleting the .Rproj.user/ folder and reopening the R project. This folder will regenerate automatically.

Line xxx Execution halted under the Render tab in Rstudio

This error is most often caused by a piece of inline (e.g., We had `r N` p articipants). To troubleshoot:

  • Within the "Render" tab, in addition to the "Output" sub-tab, there should be an "Issues" sub-tab. Click on it, find out which variable caused the issue, and then look for the corresponding code in the document.

  • If the error message doesn't let you find the specific piece of inline code easily, you can use a custom evaluate.inline knitr knitting hook for inline code that will process the error and let the knitting continue. You should see an error message and a warning directly under the "Render" tab and in place of the intended output in the rendered document. Add the code below to the setup chunk. Delete after fixing the error to avoid accidentally missing future errors like this.

xcrun error

If you get

Try one of (solutions found here):

fatal error: 'stdlib.h' file not found

If you get

Check your PATH environment variable with Sys.getenv('PATH') or with echo $PATH in the terminal. If miniconda/anaconda are the first ones listed, try rearranging the paths so that /usr/local/bin is the first path in the list. Make sure to use : as the separator between paths.

Temporarily, use Sys.setenv(PATH = '???') in R or export PATH=??? (no spaces around =) in the terminal. A long-term solution is to manipulate PATH at the system level.

Here is an example of setting PATH in the terminal:

Problem w/ installing or loading R packages Matrix or lme4

After running renv::restore(), you might see have trouble installing these two packages or loading them directly. You might see something like:

or

This is probably because some Matrix versions are binary incompatible and you're using a newer Mac (with M1 and above chips).

If this is the case, follow this discussion post to manually install the packages.

Using APA 7 formatting when knitting with papaja

Right now, papaja only natively supports APA 6 formatting but we can tweak it to get closer to APA 7.

  1. Download the apa7.csl file (courtesy of Rainy who found it online) and put it in your manuscript folder.

  2. In your manuscript.Rmd file, add/modify these yaml headers:

    1. documentclass : "apa7"

    2. csl : apa7.csl

  3. Your TinyTex might throw random complaints about not being able to find apa7.csl . Not sure how generalizable this solution is but Lily got it to work by reinstalling the tinytex R package via tinytex::reinstall_tinytex(repository = "illinois") in the R console.

See this Github issue page for more info on further tweaking options to get the formatting as close to APA 7 as possible (not attested yet).

No longer relevant but might need them anyway

An email about CrowdStrike from Duke IT

Problem: you got an email that contains something like this:

Solution: someone with admin right on the computer should follow the instructions here:

https://oit.duke.edu/help/articles/kb0035361

Last updated