Homer White
Homer White

Reputation: 733

LANG error knitting document in R Studio preview 0.98.864

I have a preview release of the R Studio server (0.98.864 Ubuntu version) set up as an EC2 microinstance on AWS. When I attempt to knit a simple .Rmd document, I get the following error message:

Error in with_pandoc_safe_environment({ : 
  The 'LANG' environment variable must be set before running Pandoc.
Calls: <Anonymous> ... FUN -> get_pandoc_version -> with_pandoc_safe_environment
Execution halted

I have set the language variables by editing the /etc/environment, and for good measure I installed language-pack-en-base. Now when I run locale I get:

LANG=en_US.UTF-8
LANGUAGE=en
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8

So it would seem that the LANG environment variable has been set.

Indeed, when I run R from the command line, I get:

> Sys.getenv("LANG",unset=NA)
[1] "en_US.UTF-8"

It also appears to have been set for all users, because when I log in as a different user using

su - <username>

and run locale, I get the above results.

However, when I restart the server:

sudo rstudio-server restart

and then log in to the Server as a user, I get:

> is.na(Sys.getenv("LANG", unset = NA))
[1] TRUE

My language settings apply to all users, but somehow this information is not getting to the Server.

A partial workaround is to log on to the server as a user and to add

Sys.setenv(LANG="en_US.UTF-8")

to my .Rprofile. However, this applies to only one user at a time, and I would like to fix the problem for all users at once.

Can someone see where I have gone wrong?

Or is there another configuration file in R that must be modified? I have tried creating and adding various commands to /etc/rstudio/rserver.conf and to /etc/rstudio/rsession.conf (see this document), but nothing survives the configuration test.

Upvotes: 1

Views: 378

Answers (1)

Yihui Xie
Yihui Xie

Reputation: 30164

The LANG variable will be set to en_US.UTF-8 in rmarkdown if not already set. This change was brought in the commit bb2d87f.

Upvotes: 1

Related Questions