Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include instructions to set up with conda #50

Closed
twrightsman opened this issue May 16, 2023 · 12 comments
Closed

Include instructions to set up with conda #50

twrightsman opened this issue May 16, 2023 · 12 comments
Labels
documentation Improvements or additions to documentation

Comments

@twrightsman
Copy link

twrightsman commented May 16, 2023

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

conda create -n workbench 'git>=2.28' 'r-base>=3.6' 'pandoc>=2.11' pkg-config libxslt python
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"))'

Note: python is only for using http.server to serve the web pages locally later; if someone knows the magical incantation to serve HTTP from R then python won't be needed in the environment.

Building the repository

R -e 'library(sandpaper); sandpaper::build_lesson(preview = FALSE)'

preview = FALSE is needed when building on a headless server without a GUI/browser.

Serving the lesson

python3 -m http.server -b $HOST -d site/docs $PORT`

I couldn't use sandpaper::serve() because I needed to bind to a specific IP and port, which sandpaper::serve() currently doesn't (seem to) support.

@zkamvar
Copy link
Contributor

zkamvar commented May 16, 2023

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.

@twrightsman
Copy link
Author

Thanks @zkamvar! That is exactly what I was missing. I also updated my comment above to include the very important conda activate workbench step 😄

@zkamvar
Copy link
Contributor

zkamvar commented May 16, 2023

Wunderbar! So, if I'm correct, then the setup for conda is:

Installation

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"))'

Build and Preview

# 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()'

@twrightsman
Copy link
Author

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.

@zkamvar
Copy link
Contributor

zkamvar commented May 16, 2023

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.

@twrightsman
Copy link
Author

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.

@zkamvar
Copy link
Contributor

zkamvar commented May 16, 2023

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.

😩 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

@zkamvar
Copy link
Contributor

zkamvar commented May 16, 2023

I've added the feature and pushed it to the universe. It should be available within the hour.

@twrightsman
Copy link
Author

Thanks so much @zkamvar! I can confirm this works on my end.

@zkamvar zkamvar added the documentation Improvements or additions to documentation label Jun 2, 2023
@twrightsman
Copy link
Author

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"))'

@zkamvar
Copy link
Contributor

zkamvar commented Sep 20, 2023

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!

@zkamvar
Copy link
Contributor

zkamvar commented Sep 20, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants