diff --git a/_quarto.yml b/_quarto.yml index b7dab8e8..1b376b02 100644 --- a/_quarto.yml +++ b/_quarto.yml @@ -124,6 +124,8 @@ website: contents: - text: "Tips" href: docs/tips.qmd + - text: "Troubleshoots" + href: docs/troubleshoots.qmd - title: "Templates" style: "docked" diff --git a/docs/troubleshoots.qmd b/docs/troubleshoots.qmd new file mode 100644 index 00000000..210fd53a --- /dev/null +++ b/docs/troubleshoots.qmd @@ -0,0 +1,151 @@ +--- +title: "Troubleshoots" +number-sections: true +--- + +::: {.callout-note} + +**surveydown** requires some basic setups in order to get running. If you find glitches or failures, this page is for you. + +::: + +## R & RStudio + +Make sure you have installed the up-to-date versions of **R** and **RStudio**. Both can be installed via [**this link**](https://posit.co/download/rstudio-desktop/). + +**R** is the coding language that supports **surveydown**, and **RStudio** is the IDE that runs **R**. Other than **RStudio**, you can also choose [VS Code](https://code.visualstudio.com) or [Positron](https://positron.posit.co). These two IDEs are both open to multiple coding languages, with **R** included and high supported. + +## Quarto + +[**Quarto**](https://quarto.org) is a publication system that supports Markdown and code scripts. **surveydown** uses Quarto to turn scripts into nicely formatted survey pages. + +To install Quarto, go to [**this page**](https://quarto.org/docs/get-started/) and click on the big download button. + +## R Packages + +After you've installed all the above environments, it's time to take care of the R packages. The function used to install R packages is `install.packages()`, and is thus used a lot in this section. You might want to re-run this function for these packages in order to get the most up-to-date version. + +### Launch the R Console + +The **R Console** is used to run R codes as well as installing R packages. It can be launched by one of the **2 ways**: + +::: {.panel-tabset} + +#### RStudio + +Launch an **RStudio** session and you'll find your **R Console** in it. It's located at the bottom left by default. + +
+R Console in RStudio +
+ +#### Terminal + +Launch your **Terminal** and simply type "**R**" (capitalized) and then Enter. + +
+R Console in Terminal +
+ +::: + +### Shiny + +All surveydown surveys are [**Shiny**](https://shiny.posit.co) webapps, so Shiny is an essential component. + +In your R Console, install **Shiny**: + +```{r} +install.packages("shiny") +``` + +### surveydown + +In your R Console, install **surveydown**: + +```{r} +# CRAN version - stable but might lack the latest features +install.packages("surveydown") + +# GitHub version - with the latest features +pak::pak("surveydown-dev/surveydown", ask = FALSE) +``` + +The GitHub version installation requires the `pak` package. If you don't have it, install it using: + +```{r} +install.packages("pak") +``` + +::: {.callout-note} + +Sometimes neither of these approaches work, often because your path is managed by some package managing system like [Anaconda](https://www.anaconda.com). In this case, a third alternative is to download the zip file of the package source code and then install it locally. + +To download the zip file, go the the [surveydown repo](https://github.com/surveydown-dev/surveydown), click on the green "Code" button and click on "Download Zip", or simplify click on [this link](https://github.com/surveydown-dev/surveydown/archive/refs/heads/main.zip). + +Unzip this repo, then open the **surveydown.Rproj** file. In your R Console panel, run this code to install: + +```{r} +# install.packages("pak") +pak::local_install(ask = FALSE) +``` + +::: + +Some useful links: + +- [surveydown CRAN Page](https://cran.r-project.org/web/packages/surveydown/index.html) +- [surveydown GitHub repo](https://github.com/surveydown-dev/surveydown/) +- [surveydown installation docs](docs/getting-started.html#install) + +### sdApps (Optional) + +**sdApps** is a companion R package with **surveydown**. It is intended for supportive webapps for surveydown. Now it has an `sd_studio()` function that launches the **surveydown Studio**, which supports GUI interface for survey construction, preview, and database management. + +In your R Console, install **sdApps**: + +```{r} +# GitHub version - sdApps is not on CRAN yet +pak::pak("surveydown-dev/sdApps", ask = FALSE) +``` + +Call `sdApps::sd_studio()` to launch the **surveydown Studio**: + +```{r} +sdApps::sd_studio() +``` + +
+surveydown Studio +
+ +### Other R Packages + +You might need some other R packages to get your survey running, for example, `tidyverse`, `kableExtra`, etc. Likewise, you can use the `install.packages()` function to install them: + +```{r} +install.packages("tidyverse") +install.packages("kableExtra") +``` + +## Database Connection + +### GSSAPI + +::: {.callout-note} + +If you encounter connection problem using **surveydown** with versions earlier than `v0.12.5`, this part might be helpful for you. + +::: + +You might encounter connection problem caused by failure of GSSAPI (Generic Security Services Application Program Interface). It is a a protection layer for data security supported by PostgreSQL. In SQL management, it is controlled by the `gssencmode` argument. + +In previous versions of **surveydown** (before `v0.12.5`), the `sd_db_connect()` and `sd_dashboard()` functions have a `gssencmode` default to `"prefer"`, which enables GSSAPI, but may cause connection failuer under some network conditions (VPN, for example). Our previous solution is to manually change `gssencmode` from `"prefer"` to `"disable"`, but it is less intuitive and causes more trouble than efficiency. + +Therefore, our current solution (versions after `v0.12.5`) is to remove the `gssencmode` argument from these functions, in which the GSSAPI is set to `"prefer"` by default, but if the connection errors due to network problem, it will auto-switch to `"disable"` and leave a message. + +### Database Config + +If your shinyapps deloyment fails, you should firstly make sure your Suppabase credentials are correctly defined, including your Supabase project settings and password settings. The password defined by `sd_db_config()` should be the same as your Supabase project password. Access the [Storing Data](docs/storing-data.html) page for how to set all Supabase credentials. Then, make sure your survey runs on your local machine and can successfully link with your Supabase project table. With these confirmed, your shinyapps deployment should work without problem. + +If you still encounter an error (e.g., the page shows the app failed to start, or you see the page but it doesn't run properly), try clearing your cache. The simplest way to do so is to **reboot your computer**. It may also help if you delete previously generated files, such as the `survey.html` file if you rendered it and the `rsconnect` folder. After re-rendering, you should be able to deploy the app without error. diff --git a/faq.qmd b/faq.qmd index e01368d5..76b02a29 100644 --- a/faq.qmd +++ b/faq.qmd @@ -42,25 +42,3 @@ Also, it is important that you run your survey locally **at least once** before ## How do I make a question required? Use the `required_questions` argument in `sd_server()` to control required responses (see the [required questions](docs/server-options.html#required-questions) page for more details). - -## Why is my shinyapps deployment failing? - -First, make sure your Suppabase credentials are correctly defined, including your Supabase project settings and password settings. The password defined by `sd_db_config()` should be the same as your Supabase project password. Access the [Storing Data](docs/storing-data.html) page for how to set all Supabase credentials. Then, make sure your survey runs on your local machine and can successfully link with your Supabase project table. With these confirmed, your shinyapps deployment should work without problem. - -If you still encounter an error (e.g., the page shows the app failed to start, or you see the page but it doesn't run properly), try clearing your cache. The simplest way to do so is to **reboot your computer**. It may also help if you delete previously generated files, such as the `survey.html` file if you rendered it and the `rsconnect` folder. After re-rendering, you should be able to deploy the app without error. - -## How should I install the {surveydown} package? - -You can install the {surveydown} package from [CRAN](https://cran.r-project.org/web/packages/surveydown/index.html) or the [GitHub repo](https://github.com/surveydown-dev/surveydown/) of the package source code. Follow [our installation instructions](docs/getting-started.html#install) for either approach. - -Sometimes neither of these approaches work, often because your path is managed by some package managing system like [Anaconda](https://www.anaconda.com). In this case, a third alternative is to download the zip file of the package source code and then install it locally. - -To download the zip file, go the the [surveydown repo](https://github.com/surveydown-dev/surveydown), click on the green "Code" button and click on "Download Zip", or simplify click on [this link](https://github.com/surveydown-dev/surveydown/archive/refs/heads/main.zip). - -Unzip this repo, then open the **surveydown.Rproj** file. In your R Console panel, run this code to install: - -```{r} -# install.packages('devtools') -devtools::install(force = TRUE) -``` - diff --git a/images/r_console_rstudio.png b/images/r_console_rstudio.png new file mode 100644 index 00000000..74d22290 Binary files /dev/null and b/images/r_console_rstudio.png differ diff --git a/images/r_console_terminal.png b/images/r_console_terminal.png new file mode 100644 index 00000000..cab439bd Binary files /dev/null and b/images/r_console_terminal.png differ diff --git a/images/sd_studio.gif b/images/sd_studio.gif new file mode 100644 index 00000000..5ee2ec47 Binary files /dev/null and b/images/sd_studio.gif differ