Running portable R Shiny with Electron is based on https://github.com/COVAIL/electron-quick-start. This application uses electron-packager for packaging.
Learn how an Electron app works with Electron Quick Start Guide.
Node.js (which comes with npm)
# Go to the application directory
cd daniocell_shiny_electron
# Install dependent packages
npm install
- Download zip of R-Portable-Mac 4.2.3 from https://github.com/selkamand/r-portable-mac
- Unpack zip, move into repo directory, rename to "R-Portable-Mac"
- Download presto from https://github.com/immunogenomics/presto and unzip
# Example from parent directory
cd ..
# Download R Portable
wget https://github.com/selkamand/r-portable-mac/archive/refs/tags/R-4.2.3-patch2.tar.gz
tar -xzf ./R-4.2.3-patch2.tar.gz
mv ./r-portable-mac-R-4.2.3-patch2 ./daniocell_shiny_electron/R-Portable-Mac
rm R-4.2.3-patch2.tar.gz
# Download Presto
wget https://github.com/immunogenomics/presto/archive/refs/heads/master.zip
unzip ./master.zip- Make sure Rtools is installed: https://cran.r-project.org/bin/windows/Rtools/
- Add C:\rtools42\usr\bin to your PATH so
makecan be found. - Download zip of R-Portable-Windows 4.2.3 from https://github.com/selkamand/r-portable-windows
- Unpack zip, move into repo directory, rename to "R-Portable-Win"
# Example from parent directory
cd ..
# Download R Portable
curl https://github.com/selkamand/r-portable-windows/releases/download/R-4.2.3/r-portable-windows-R-4.2.3.zip -o R-4.2.3.zip
Expand-Archive .\R-4.2.3.zip -destination .\daniocell_shiny_electron\
Move-Item -Path .\r-portable-windows-R-4.2.3 -Destination .\daniocell_shiny_electron\R-Portable-Win
# Download Presto
curl https://github.com/immunogenomics/presto/archive/refs/heads/master.zip -o presto-master.zip
Expand-Archive .\presto-master.zip -destination .Start R from within the R-Portable-* directory unzipped.
# For Windows, use R-Portable-Win
cd daniocell_shiny_electron/R-Portable-Mac
# Start R from R portable script
./bin/RInstall R packages within R Portable
install.packages(c("shiny", "shinyWidgets", "shinyjs", "shinyhttr", "DT", "bslib", "bsicons", "dplyr", "reshape2", "ggplot2", "scales", "gridExtra", "colorspace", "httr", "Matrix", "bigsparser", "data.table", "tidyr", "purrr", "RcppArmadillo", "ggrepel", "svglite", "shinyFiles"), repos = "http://cran.us.r-project.org", type = "binary", dependencies = c("Depends", "Imports"))
install.packages("../../presto-master", repos=NULL, type = "source")
install.packages(c("ggplot2", "bslib"), repos = "http://cran.us.r-project.org", type = "source", dependencies = c("Depends", "Imports"))If using an arm64-based Mac (i.e., Apple silicon, M1, etc.), if arm64 compilers are listed in a ~/.R/Makevars file, they may cause an "incompatible architecture" error to occur when building presto.
- Run your R portable, check the value of
R_PLATFORMwithSys.getenv("R_PLATFORM"), copy the value. - Create an empty file to override Makevars for that platform, e.g.
touch ~/.R/Makevars-x86_64-apple-darwin17.0. - Go back to R and rebuild presto:
install.packages("../../presto-master", repos=NULL, type = "source", INSTALL_opts = "--preclean").
cd daniocell_shiny_electron
npm run start-mac
cd daniocell_shiny_electron
npm run start-windows
To build an executable, use npm run , followed by the package command for the OS and architecture.
package-mac64package-macintelpackage-win32package-win64package-winarmpackage-linux
cd daniocell_shiny_electron
npm run package-macintel
This will place the packaged application as a subdirectory of daniocell_shiny_electron/packages with the naming convention DaniocellDesktop-<platform>-<arch>.
- Make sure to include the necessary entitlements (i.e. what your signed code is supposed to be allowed to do)
- Get the SHA-1 Fingerprint for your Developer Certificate:
- Right click on the certificate in Keychain, pick Get Info, scroll to bottom, copy the 40-character SHA-1 fingerprint, delete all spaces.
export DEBUG=electron-osx-sign*
npx electron-osx-sign DaniocellDesktopMacArm64/DaniocellDesktop-darwin-arm64/DaniocellDesktop.app --identity=[Certificate SHA-1 Fingerprint]Cannot submit the .app bundle directly. Make a zip file. (Must use ditto, regular zip does not respect some permissions.)
/usr/bin/ditto -c -k --keepParent DaniocellDesktop.app DaniocellDesktop-Mac-AppleSilicon.zipxcrun notarytool submit DaniocellDesktop-Mac-AppleSilicon.zip --force --verbose --apple-id [your AppleID] --password [App-specific Password] --team-id [Your Team ID (In parentheses behind your name in your signing certificate)]xcrun notarytool info [Submission ID] --apple-id [your appleID ] --password [app-specific password] --team-id [Team ID]
xcrun notarytool log [Submission ID] --apple-id [your appleID ] --password [app-specific password] --team-id [Team ID] DaniocellDesktop-notarization-log.jsonhttps://developer.apple.com/documentation/security/resolving-common-notarization-issues
Then staple certificate directly to the .app bundle and re-zip for distribution
xcrun stapler staple "DaniocellDesktop.app"
/usr/bin/ditto -c -k --keepParent DaniocellDesktop.app DaniocellDesktop-Mac-AppleSilicon-Dist.zip