Fortran compilation issue with shiny app

Dear RStudio Community,

I just tried create a shinyapp using a package of my own, on github, which includes Fortran code. The Fortran code has modules. It seems that it cannot compile properly because of the module. A tricky thing is that the order in which the compilation goes matters as the module must be compiled before further source files dependent on the modules are compiled. I got around this by making the name of the module alphabetically the first one.

Is it the case that the compilation is not happening sequentially when installing through shinyapp? And is there any way around this?

I'm using the latest Shiny package and have a Windows 10 set. Further details including error messages below.

Many thanks,
Mike

Be sure to include:

  • Cite any error or warning messages, and where you receive them.
    Here are the warnings and errors
> rsconnect::deployApp('scripts')

[2020-05-03T08:20:10.272676944+0000] Building R package: NicheMapR (2.0.0)
/mnt/packages/build /mnt
Warning in untar2(tarfile, files, list, exdir, restore_times) :
  skipping pax global extended headers
* installing to library ‘/opt/R/3.6.1/lib/R/library’
* installing *source* package ‘NicheMapR’ ...
** using staged installation
** libs
make: Entering directory '/tmp/Rtmp4xhidC/R.INSTALLfe2168e013/mrke-NicheMapR-037efa2/src'
gfortran  -fpic  -g -O2  -c AACOMMONDAT.f -o AACOMMONDAT.o
gfortran  -fpic  -g -O2  -c ABOVEGROUND.f -o ABOVEGROUND.o
gfortran  -fpic  -g -O2  -c ADJREC.f -o ADJREC.o
gfortran  -fpic  -g -O2  -c BELOWGROUND.f -o BELOWGROUND.o
BELOWGROUND.f:22:9:

       USE AACOMMONDAT
         1
Fatal Error: Can't open module file ‘aacommondat.mod’ for reading at (1): No such file or directory
ABOVEGROUND.f:22:9:

       USE AACOMMONDAT
         1
Fatal Error: Can't open module file ‘aacommondat.mod’ for reading at (1): No such file or directory
compilation terminated.
compilation terminated.
/opt/R/3.6.1/lib/R/etc/Makeconf:190: recipe for target 'ABOVEGROUND.o' failed
make: *** [ABOVEGROUND.o] Error 1
make: *** Waiting for unfinished jobs....
/opt/R/3.6.1/lib/R/etc/Makeconf:190: recipe for target 'BELOWGROUND.o' failed
make: *** [BELOWGROUND.o] Error 1
make: Leaving directory '/tmp/Rtmp4xhidC/R.INSTALLfe2168e013/mrke-NicheMapR-037efa2/src'
make: Entering directory '/tmp/Rtmp4xhidC/R.INSTALLfe2168e013/mrke-NicheMapR-037efa2/src'
make: Leaving directory '/tmp/Rtmp4xhidC/R.INSTALLfe2168e013/mrke-NicheMapR-037efa2/src'
ERROR: compilation failed for package ‘NicheMapR’
* removing ‘/opt/R/3.6.1/lib/R/library/NicheMapR’
################################# End Task Log ################################# 
Error: Unhandled Exception: Child Task 725241837 failed: Error building image: Error building NicheMapR (2.0.0). Build exited with non-zero status: 1

- Cite output of "rsconnect::appDependencies()"
       package  version source
1           BH 1.69.0-1   CRAN
2    NicheMapR    2.0.0 github
3           R6    2.4.0   CRAN
4      RNetCDF    2.1-1   CRAN
5         Rcpp  1.0.4.6   CRAN
6       crayon    1.3.4   CRAN
7      deSolve     1.28   CRAN
8       digest   0.6.22   CRAN
9      fastmap    1.0.1   CRAN
10    geonames    0.999   CRAN
11   htmltools    0.4.0   CRAN
12      httpuv    1.5.2   CRAN
13    jsonlite      1.6   CRAN
14       later    1.0.0   CRAN
15     lattice  0.20-38   CRAN
16    magrittr      1.5   CRAN
17        mime      0.7   CRAN
18       ncdf4     1.17   CRAN
19    promises    1.1.0   CRAN
20      raster    3.1-5   CRAN
21       rjson   0.2.20   CRAN
22       rlang    0.4.1   CRAN
23       shiny  1.4.0.2   CRAN
24 sourcetools    0.1.7   CRAN
25          sp    1.4-1   CRAN
26      xtable    1.8-4   CRAN

- Provide your shiny app's application URL/id.
https://nichemapr.shinyapps.io/scripts/

shinyapps.io uses -j 4 with make, so the compilations are happening in parallel.
I don't know much about R package authoring, but I would look for a way to express the dependencies so that make does the correct ordering.

1 Like

That's very helpful to know Josh. I'll look into whether I can somehow change this at my package end but if anyone has any ideas please let me know - R seems to have its own mysterious approach to compiling such that it is not easy to control it (but at the same time, generally requiring little input from the user).

All the best,
Mike

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.