Closed twrightsman closed 10 months ago
Thank you for opening this issue!
I have never isolated an R envionment using conda before so this is helpful!
WRT to the http server, the sandpaper::serve()
function uses the {servr} package to host the server and it's options can be set up using the servr::server_config()
function. Once you set those up, you can run sandpaper::serve()
:
# 127.0.0.1 and port 4321 are the defaults for servr
R -e 'servr::server_config(host = "127.0.0.1", port = "4321"); sandpaper::serve()'
from there you can preview the lesson at http://127.0.0.1:4321
I admit that I never actually had a good grasp on how to deploy it with a server from the command line; my setup is vim with Nvim-R.
Thanks @zkamvar! That is exactly what I was missing. I also updated my comment above to include the very important conda activate workbench
step :smile:
Wunderbar! So, if I'm correct, then the setup for conda is:
conda create -n workbench 'git>=2.28' 'r-base>=3.6' 'pandoc>=2.11' pkg-config libxslt
conda activate workbench
R -e 'install.packages(c("sandpaper", "varnish", "pegboard", "tinkr"), \
repos = list(carpentries="https://carpentries.r-universe.dev/", CRAN="https://cran.us.r-project.org"))'
# 127.0.0.1 and port 4321 are the defaults for servr
R -e 'servr::server_config(host = "127.0.0.1", port = "4321"); sandpaper::serve()'
Does sandpaper::serve()
try to open a browser window by default? That would be the only thing I'd add, otherwise looks good!
The docs do warn about this, but on Linux this will need to compile a lot of things which took a fair bit of time.
Does
sandpaper::serve()
try to open a browser window by default? That would be the only thing I'd add, otherwise looks good!
In an interactive session, it does launch a window, but because R -e
is not launched interactively, you have to manually open it, or you can insert browseURL(servr::server_config()$url)
in between the two R statements so that it launches before serving.
The docs do warn about this, but on Linux this will need to compile a lot of things which took a fair bit of time.
Ah yes, if you are on a major linux platform (Ubuntu, CentOS, etc), you should be able to use the Posit Package Manager to get binaries: https://packagemanager.rstudio.com/client/#/
Otherwise, yes, we have inadvertently inverted the pain threshold for getting things installed so that now linux users have the most difficult time and Windows and Mac users are largely plug-and-play. The only consolance I have is that the long installation time is going to be a rare occurance.
Unfortunately the server_config
snippet above doesn't seem to work for me. For example, if we try R -e 'servr::server_config(host = "192.168.1.10", port = "5000"); sandpaper::serve()'
it will still serve on 127.0.0.1
and port 4321
.
Unfortunately the
server_config
snippet above doesn't seem to work for me. For example, if we tryR -e 'servr::server_config(host = "192.168.1.10", port = "5000"); sandpaper::serve()'
it will still serve on127.0.0.1
and port4321
.
😩 that's what I get for testing with just the default config. I will add an ellipses to the serve function in the next release so that you should be able to run sandaper::serve(host = "192.168.1.10", port = "5000")
For reference, this is the documentation of those options that will be available:
https://yihui.r-universe.dev/servr/doc/manual.html#server_config
I've added the feature and pushed it to the universe. It should be available within the hour.
Thanks so much @zkamvar! I can confirm this works on my end.
It seems https://cran.us.r-project.org is not accessible (permanently?), so I had to update the R install command:
R -e 'install.packages(c("sandpaper", "varnish", "pegboard", "tinkr"), \
repos = list(carpentries="https://carpentries.r-universe.dev/", CRAN="https://cloud.r-project.org"))'
Ah yes, sorry about that. CRAN is not yet an option because we need to ship quickly and the process for CRAN submission can get bogged down in very minor details.
I'm going to add this to the installation page so that I can close this issue. Sorry for the delay!
I just realised I misread your comment! Yes, "https://cloud.r-project.org" is likely going to return the best results as it will redirect your to the closest, most up-to-date server: https://cran.r-project.org/mirrors.html
I don't use RStudio and have been building Workbench lessons from the command line. For isolation from the rest of my system packages I looked in to installing everything with Conda on Linux, since I couldn't find this in the documentation.
Creating the environment
Note:
python
is only for usinghttp.server
to serve the web pages locally later; if someone knows the magical incantation to serve HTTP from R thenpython
won't be needed in the environment.Building the repository
preview = FALSE
is needed when building on a headless server without a GUI/browser.Serving the lesson
I couldn't use
sandpaper::serve()
because I needed to bind to a specific IP and port, whichsandpaper::serve()
currently doesn't (seem to) support.