Skip to content

Commit

Permalink
defend against pathological cases
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinushey committed Oct 1, 2019
1 parent 46ced5c commit dbb6c68
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/cpp/session/SessionModuleContext.cpp
Expand Up @@ -1072,6 +1072,16 @@ FilePath findProgram(const std::string& name)

bool addTinytexToPathIfNecessary()
{
// avoid some pathological cases where e.g. TinyTeX folder
// exists but doesn't have the pdflatex binary (don't
// attempt to re-add the folder multiple times)
static bool s_added = false;
if (s_added)
return true;

if (!module_context::findProgram("pdflatex").empty())
return false;

std::string binDir;
Error error = r::exec::RFunction(".rs.tinytexBin").call(&binDir);
if (error)
Expand All @@ -1081,6 +1091,7 @@ bool addTinytexToPathIfNecessary()
if (!binPath.exists())
return false;

s_added = true;
core::system::addToSystemPath(binPath);
return true;
}
Expand Down

0 comments on commit dbb6c68

Please sign in to comment.