pbs-assess / csasdown

:book: An R package for creating CSAS reports in PDF or Word format with R Markdown and bookdown
Other
47 stars 17 forks source link

Install Troubleshooting (Not a csasdown bug) #188

Closed SOLV-Code closed 3 years ago

SOLV-Code commented 3 years ago

Issue

Initial Problem

Steps so far

Now R and RStudio work fine (i.e. can run analysis scripts), but knitting doesn't work. It seems to run through all the markdown steps, but the .Rmd and .tex files are not generated. It doesn't seem to get to the step that generates the log file either... There are no errors in the markdown console, it just has the spinning icon twirling for 30 min plus.

I've tried multiple csasdown reports, and they all get stuck in the same place.

Next Steps

Details

Versions

RMarkdown console output

The Rmarkdown is frozen at:

  |....................................................................  |  98%
label: TradeOffCult (with options) 
List of 2
 $ fig.pos: chr "H"
 $ fig.cap: chr "(ref:TradeOffCult)"

  |..................................................................... |  98%
   inline R code fragments

  |..................................................................... |  99%
label: HCRBase (with options) 
List of 2
 $ echo   : logi FALSE
 $ results: chr "asis"

  |......................................................................| 100%
   inline R code fragments

output file: FRSSI_2021_Workshop_Handout.knit.md
cgrandin commented 3 years ago

First off I have to admit I don't know who this is, as your name isn't attached anywhere to your account!

I made progress recently on docker containers and I have one working for csasdown docs. Using it means that there are no installation issues anymore since you don't need R, Rstudio, or LaTex installed on your machine, it is a static Linux container containing everything necessary to compile csasdown docs.

If you would like to try this, it requires no tweaking of your machine's installed software so you can't break anything that's set up on your machine. But you will need a computer you can install Docker on (not a DFO machine) (Windows 10, Linux, or MAC): https://docs.docker.com/docker-for-windows/install/

Get a DockerHub account so you can get access to the csasdown docker image: https://hub.docker.com/

Once it's all installed, open a Powershell window and type:

docker pull cgrandin/csasdown

If it says you need credentials you will have to run the login command and provide your Docker Hub username and password at the prompts first, then try the pull again:

docker login

Look under Images in the Docker Hub Desktop software if you want to see it is loaded.

Create a new directory wherever you want to put your new techreport, resdoc, or SR and navigate there in Powershell, paste this code:

docker run -d -p 8787:8787 --mount type=bind,source="$(pwd)",target=/home/rstudio cgrandin/csasdown

Then open a new tab in a web browser (I know it works perfectly in Chrome) and type this in the URL bar:

localhost:8787

If there is a dialog asking for Rstudio name and password, use:

username: rstudio
password: qwerty

And an Rstudio instance opens in the browser. Create a new document and build as usual:

csasdown::draft("resdoc")
bookdown::render_book("index.Rmd")

You can also run the docker run command above in a folder where you already have a project and the files will be linked automatically.

That's it, no messing about with R packages or Latex.

One last thing, if you ever want to install packages from github like this:

remotes::install_github("group/repo")

you need to place a file called .Renviron in the folder and it must contain the text:

GITHUB_PAT = <gh_token>

where is a token you create on your GitHub account. There must be a newline after the line in the file.

image

SOLV-Code commented 3 years ago

Hi Chris,

Thank you for the detailed response. I will try this and let you know.

I will also pass this on to several DFO folks who I'm working on tech reports / res docs with, who've not been able to knit.

we haven't actually met (yet), because I spend most of my life in salmon world, but I was at a PBS seminar on markdown where you and Sean gave one of the talks. SOLV-Code is our shared github account, much like https://github.com/Pacific-salmon-assess or https://github.com/Pacific-salmon-assess

Cheers, Gottfried

cgrandin commented 3 years ago

I just updated the comment above with the username and password for the rstudio instance after you enter your browser and type localhost:8787. They will always be:

username: rstudio
password: qwerty
cgrandin commented 3 years ago

See issue #189

SOLV-Code commented 3 years ago

I am still working my way through the docker steps, but managed to get knitting to work on another machine, and so will get the draft docs out first. I will leave feedback re docker at #189, so I think you can close this issue

Thank you very much for your help. I've had a few csasdown issues over the years, and between you and Sean you always provided solutions with an incredibly fast turn-around. I imagine you get a lot of panicked requests from folks, but csasdown has become an essential part of the DFO/Consultant workflow. When I can't knit, everything stops :-)

cgrandin commented 3 years ago

"When I can't knit, everything stops" is the driving force for using Docker. It is guaranteed to knit the document since it isn't dependent on anyone's machine configuration!

Of course it's up to you to write good code to make sure your document builds but you won't have to worry about R package issues and tinytex issues anymore. I got tired of reinstalling tinytex yet again and hoping it worked when I had deadlines.

SOLV-Code commented 3 years ago

You've convinced me re: docker, and I've been reading up on the whole "container" concept which is new to me. This way I'm learning something new along the way, and that was (almost) worth the trouble over the last 24hrs...