How-to: Migrate app to RhinoSource:
This guide aims to make your application up and running using Rhino as quickly as possible. Lets assume an application has a following structure:
. ├── utils │ ├── foo.R │ └── bar.R ├── www │ ├── main.css │ └── main.js ├── server.R └── ui.R
The migration process should not be affected by the combination of server.R, ui.R, global.R, and app.R files in your application, or lack of thereof.
Prepare Your Application for
The first step is moving all application source files to a new
Once source files are moved, if you have a list of
. └── app ├── utils │ ├── bar.R │ └── foo.R ├── www │ ├── main.css │ └── main.js ├── server.R └── ui.R
library()calls put it in
dependencies.Rin the root directory. If you do not have such list, then Rhino will try to create one for you in initialization step.
. ├── app │ ├── utils │ │ ├── bar.R │ │ └── foo.R │ ├── www │ │ ├── main.css │ │ └── main.js │ ├── server.R │ └── ui.R └── dependencies.R
After doing so, you should be able to run your application using
What if: My App Uses renv
If you have used renv in your application, then chances are your
active renv session does not have Rhino installed. To address this
either deactivate renv or run
Apart from additional files related to renv, the target file structure is no different than the one presented above.
Initialize Your Rhino ApplicationHaving your application prepared, you can now run
. ├── .github │ └── workflows │ └── rhino-test.yml ├── app │ ├── js │ │ └── index.js │ ├── logic │ │ └── __init__.R │ ├── static │ │ └── favicon.ico │ ├── styles │ │ └── main.scss │ ├── utils │ │ ├── bar.R │ │ └── foo.R │ ├── view │ │ └── __init__.R │ ├── www │ │ ├── main.css │ │ └── main.js │ ├── main.R │ ├── server.R │ └── ui.R ├── renv │ └── ... ├── tests │ ├── cypress │ │ ├── integration │ │ └── .gitignore │ ├── testthat │ │ └── test-main.R │ └── cypress.json ├── .Rprofile ├── .lintr ├── .renvignore ├── app.R ├── dependencies.R ├── old.Rprofile ├── renv.lock ├── rhino.yml └── app.Rproj
If you did not use renv before, then Rhino initialized it for you.
However, if you did use renv, then Rhino added necessary dependencies to
Configure Your Rhino Application
The last step to get started with Rhino is configuring it. A minimal
setup that allows running the application is setting
rhino.yml. To be able to
run application immediately set
as this approach requires no further adjustments to application’s
As you adjust adjust your application to fit best practices suggested
by Rhino, you can modify
when application is fully migrated to Rhino,
legacy_entrypoint setting can be removed from
rhino.yml. Refer to Next Steps
section to see how to continue improving your application!
TODO: something along the lines of
The process described in
albeit not in great detail. The first step is to put all app files in
app directory, so it can be run with
shinyAppDir("app"). Practical experience of migrating apps
shows that it’s a useful step which quickly lets you verify whether the
app still works.
The process can be a bit unintuitive however. For example, if you
already have an
app.R file and ui/server/global in
R subdirectory, you should still move the whole structure
app. In this case you’ll end up with
app/app.R and ui/server/global in
app/R/. Having two
app.R files might feel
In general you use
rhino::init() for migration. This
cannot be done via RStudio GUI.
If you already have
.Rprofile with renv when migrating,
you’ll load it and won’t have Rhino inside. You need to run
rhino::init() from a different directory (or perhaps run
Rhino will renv::load() your renv.lock. In particular it will set
options("repos") based on
What to do when I get “unsatisfied dependencies” during migration?