timflutre / PlantBreedGame

A serious game to teach plant selective breeding.
https://sourcesup.renater.fr/plantbreedgame/
GNU Affero General Public License v3.0
8 stars 2 forks source link

"PLANTBREEDGAME_DATA_ROOT" not found in `Sys.getenv` in `global.R` #38

Closed chabrault closed 2 months ago

chabrault commented 2 months ago

Hi,

When I tried to launch the app, I got the following error: Error in ..stacktraceon..({ : Specified game data folder: does not exist. Make sure thePLANTBREEDGAME_DATA_ROOTenvironment variable is correctly set

The error arises from global.R, line 50. I pasted the output form Sys.getenv:

ALLUSERSPROFILE                                  C:\ProgramData
APPDATA                                          C:\Users\cbrault\AppData\Roaming
CLICOLOR_FORCE                                   1
CommonProgramFiles                               C:\Program Files\Common Files
CommonProgramFiles(x86)                          C:\Program Files (x86)\Common Files
CommonProgramW6432                               C:\Program Files\Common Files
COMPUTERNAME                                     UMN646001718
ComSpec                                          C:\WINDOWS\system32\cmd.exe
CURL_CA_BUNDLE                                   C:/Users/cbrault/AppData/Local/Programs/R/R-4.4.1/etc/curl-ca-bundle.crt
DISPLAY                                          :0
DriverData                                       C:\Windows\System32\Drivers\DriverData
EFC_27376                                        1
FPS_BROWSER_APP_PROFILE_STRING                   Internet Explorer
FPS_BROWSER_USER_PROFILE_STRING                  Default
GFORTRAN_STDERR_UNIT                             -1
GFORTRAN_STDOUT_UNIT                             -1
GIT_ASKPASS                                      rpostback-askpass
HOME                                             C:\Users\cbrault\Documents
HOMEDRIVE                                        C:
HOMEPATH                                         \Users\cbrault
LOCALAPPDATA                                     C:\Users\cbrault\AppData\Local
LOGONSERVER                                      \\IAM-AD-TC1
MOZ_PLUGIN_PATH                                  C:\Program Files (x86)\Foxit Software\Foxit PDF Reader\plugins\
MPLENGINE                                        tkAgg
MSYS2_ENV_CONV_EXCL                              R_ARCH
NUMBER_OF_PROCESSORS                             12
OneDrive                                         C:\Users\cbrault\OneDrive
ORIGINAL_XDG_CURRENT_DESKTOP                     undefined
OS                                               Windows_NT
PATH                                             C:\Users\cbrault\AppData\Local\Programs\Python\Python312\Scripts;C:\Users\cbrault\AppData\Local\Programs\Python\Python312;C:\rtools44\x86_64-w64-mingw32.static.posix\bin;C:\rtools44\usr\bin;C:\Users\cbrault\AppData\Local\Programs\R\R-4.4.1\bin\x64;C:\Users\cbrault\AppData\Local\Programs\R\R-4.4.1\bin\x64;C:\Program
                                                 Files\Common
                                                 Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program
                                                 Files\Microsoft VS
                                                 Code\bin;C:\Users\cbrault\AppData\Local\Programs\Python\Launcher\;C:\Users\cbrault\AppData\Local\Microsoft\WindowsApps;C:\Users\cbrault\AppData\Local\GitHubDesktop\bin;C:\Users\cbrault\AppData\Local\Programs\Git\cmd;C:\Users\cbrault\AppData\Local\Programs\Python\Python312;C:\Program
                                                 Files\RStudio\resources\app\bin\quarto\bin;C:\Program Files\RStudio\resources\app\bin\postback
PATHEXT                                          .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE                           AMD64
PROCESSOR_IDENTIFIER                             Intel64 Family 6 Model 186 Stepping 3, GenuineIntel
PROCESSOR_LEVEL                                  6
PROCESSOR_REVISION                               ba03
ProgramData                                      C:\ProgramData
ProgramFiles                                     C:\Program Files
ProgramFiles(x86)                                C:\Program Files (x86)
ProgramW6432                                     C:\Program Files
PSModulePath                                     C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
PUBLIC                                           C:\Users\Public
PYTHONIOENCODING                                 utf-8
R_ARCH                                           /x64
R_CLI_HAS_HYPERLINK_IDE_HELP                     true
R_CLI_HAS_HYPERLINK_IDE_RUN                      true
R_CLI_HAS_HYPERLINK_IDE_VIGNETTE                 true
R_COMPILED_BY                                    gcc 13.2.0
R_DOC_DIR                                        C:/Users/cbrault/AppData/Local/Programs/R/R-4.4.1/doc
R_HOME                                           C:/Users/cbrault/AppData/Local/Programs/R/R-4.4.1
R_INCLUDE_DIR                                    C:/Users/cbrault/AppData/Local/Programs/R/R-4.4.1/include
R_LIBS_SITE                                      C:/Users/cbrault/AppData/Local/Programs/R/R-4.4.1/site-library
R_LIBS_USER                                      C:\Users\cbrault\AppData\Local/R/win-library/4.4
R_PLATFORM                                       
R_RTOOLS44_PATH                                  C:\rtools44/x86_64-w64-mingw32.static.posix/bin;C:\rtools44/usr/bin
R_RUNTIME                                        ucrt
R_SHARE_DIR                                      C:/Users/cbrault/AppData/Local/Programs/R/R-4.4.1/share
R_USER                                           C:/Users/cbrault/Documents
RETICULATE_PYTHON_FALLBACK                       C:/Users/cbrault/AppData/Local/Programs/Python/Python312/python.exe
RMARKDOWN_MATHJAX_PATH                           C:/Program Files/RStudio/resources/app/resources/mathjax-27
RS_LOCAL_PEER                                    \\.\pipe\10715-rsession
RS_LOG_LEVEL                                     WARN
RS_RPOSTBACK_PATH                                C:/Program Files/RStudio/resources/app/bin/rpostback.exe
RS_SHARED_SECRET                                 d419cb97-5f67-4aaa-935d-3a2ec24e17a6
RSTUDIO                                          1
RSTUDIO_CLI_HYPERLINKS                           true
RSTUDIO_CONSOLE_COLOR                            256
RSTUDIO_CONSOLE_WIDTH                            165
RSTUDIO_DESKTOP_EXE                              C:\Program Files\RStudio\rstudio.exe
RSTUDIO_MSYS_SSH                                 C:/Program Files/RStudio/resources/app/bin/msys-ssh-1000-18
RSTUDIO_PANDOC                                   C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools
RSTUDIO_PROGRAM_MODE                             desktop
RSTUDIO_SESSION_PID                              13924
RSTUDIO_SESSION_PORT                             10715
RSTUDIO_USER_IDENTITY                            cbrault
RSTUDIO_WINUTILS                                 C:/Program Files/RStudio/resources/app/bin/winutils
RTOOLS44_HOME                                    C:\rtools44
SESSIONNAME                                      Console
SSH_ASKPASS                                      rpostback-askpass
SystemDrive                                      C:
SystemRoot                                       C:\WINDOWS
TEMP                                             C:\Users\cbrault\AppData\Local\Temp
TERM                                             xterm-256color
TMP                                              C:\Users\cbrault\AppData\Local\Temp
TZDIR                                            C:/Users/cbrault/AppData/Local/Programs/R/R-4.4.1/share/zoneinfo
UATDATA                                          C:\WINDOWS\CCM\UATData\D9F8C395-CAB8-491d-B8AC-179A1FE1BE77
USERDNSDOMAIN                                    AD.UMN.EDU
USERDOMAIN                                       AD
USERDOMAIN_ROAMINGPROFILE                        AD
USERNAME                                         cbrault
USERPROFILE                                      C:\Users\cbrault
windir                                           C:\WINDOWS
ZES_ENABLE_SYSMAN                                1

When I manually set DATA_ROOT variable, it worked.

timflutre commented 2 months ago

@juliendiot42 Can you look into this? Maybe the doc should mention this variable PLANTBREEDGAME_DATA_ROOT?

juliendiot42 commented 2 months ago

Thank you very much.

Indeed I recently added this environment variable to let user choose the location they want for the game data. However, there is no default value.

I don't know how to set environment variable on windows though.

On linux or mac it would be with (from a terminal):

export PLANTBREEDGAME_DATA_ROOT="<path/to/the/game/data>" # set this environment variable
Rscript --vanilla -e "shiny::runApp(port = as.numeric(Sys.getenv('TEST_PORT')))" # launch the app

However, when R starts, it reads a ".Renviron" file in which we can specify such environment variable (for R only). You could add this variable there with:

PLANTBREEDGAME_DATA_ROOT="./data"

I think on windows this file is located at: c:\Users\<user-name>\Documents\.Renviron

To fix that, I will add a default value to use in case the environment variable does not exist.

chabrault commented 2 months ago

I didn't have a .Renviron file initially, I created it in the default location (C:\Users\<user-name>\Documents\.Renviron). Then, I pasted your command but it didn't work when I run the game from shiny::runApp(). I changed the path to the actual data folder but it still didn't work.

But everything works fine using Docker!