xfun error with Rmarkdown knitting pdf

I am trying to knit my rmarkdown to pdf however I get this error:
Error: 'set_envvar' is not an exported object from 'namespace:xfun'
Execution halted

Can anyone help me with it?