Using nloptr package on rconnect


I’m trying to publish an app that uses the nloptr package ( to the company rconnect server. The app works on my machine and I was also able to publish it to rconnect prior to adding the optimization feature.

Now when I try to publish the app, the status hangs on “Installing nloptr (1.0.4) …” seemingly indefinitely.

It appears the package requires an external library so I’m not really sure how to go about deploying the app with this feature intact.
Does anyone know if it is possible to run this package/packages that require external libraries in a shiny app on rconnect?
If so, is there a way I can install the library on the server? (I have publisher access but not admin.) Do I need IT to install it?

In case it’s not possible, any suggestions for a similar nonlinear optimization package that doesn’t require an external library are more than welcome (and will be passed along to my teammate who wrote the functions I’m trying to call)



I recently had that problem too, trying to install that package on a client shiny server. If you’re on Ubuntu, this is what I had to install as a req for the package:

sudo apt-get install libnlopt-dev


Hi @maura, there are other Linux dependencies that would be good to install so that other R packages work when deployed in an app, here’s the section in the RStudio Connect Admin guide listing some suggested packages: It’s worth noting that the specific nloptr dependency is not listed, so it may be that the supplemental Linux packages were already installed by your IT team.


So, I’ve gotten an admin to install the nlopt library on the server, but now I’m getting another error and still cant deploy…

Wondering if anyone has seen this and knows how to fix it?
(apologies for pasting the full deploy log here- it looks like its only partially working…)


2017/10/23 15:50:03.852038953 Installing nloptr (1.0.4) ... 
2017/10/23 15:50:06.567448828 Warning message:
2017/10/23 15:50:06.567546307 In packrat::restore(overwrite.dirty = TRUE, prompt = FALSE, restart = FALSE) :
2017/10/23 15:50:06.567572161   The most recent snapshot was generated using R version 3.3.2
2017/10/23 15:50:06.562353182 [1] "Command failed (1)\n\nFailed to run system command:\n\n\t'/usr/lib/R/bin/R' --vanilla CMD INSTALL '/tmp/RtmpFdu0Ue/nloptr' --library='/opt/rstudio-connect/mnt/app/packrat/lib/x86_64-pc-linux-gnu/3.2.3' --install-tests --no-docs --no-multiarch --no-demo \n\nThe command failed with output:\n* installing *source* package 'nloptr' ...\n** package 'nloptr' successfully unpacked and MD5 sums checked\nchecking for g++... g++\nchecking whether the C++ compiler works... yes\nchecking for C++ compiler default output file name... a.out\nchecking for suffix of executables... \nchecking whether we are cross compiling... no\nchecking for suffix of object files... o\nchecking whether we are using the GNU C++ compiler... yes\nchecking whether g++ accepts -g... yes\nchecking how to run the C++ preprocessor... g++ -E\nchecking whether we are using the GNU C++ compiler... (cached) yes\nchecking whether g++ accepts -g... (cached) yes\nchecking for pkg-config... no\nconfi... <truncated>
opt header file.\nchecking for grep that handles long lines and -e... /bin/grep\nchecking for egrep... /bin/grep -E\nchecking for ANSI C header files... yes\nchecking for sys/types.h... yes\nchecking for sys/stat.h... yes\nchecking for stdlib.h... yes\nchecking for string.h... yes\nchecking for memory.h... yes\nchecking for strings.h... yes\nchecking for inttypes.h... yes\nchecking for stdint.h... yes\nchecking for unistd.h... yes\nchecking nlopt.h usability... yes\nchecking nlopt.h presence... yes\nchecking for nlopt.h... yes\nconfigure: Suitable NLopt library found.\nconfigure: creating ./config.status\nconfig.status: creating src/Makevars\n** libs\ng++ -I/usr/share/R/include -DNDEBUG      -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c dummy.cpp -o dummy.o\ngcc -std=gnu99 -I/usr/share/R/include -DNDEBUG      -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c nlo... <truncated>
shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o dummy.o nloptr.o -L/usr/lib/R/lib -lR\ninstalling to /opt/rstudio-connect/mnt/app/packrat/lib/x86_64-pc-linux-gnu/3.2.3/nloptr/libs\n** R\n** inst\n** tests\n** preparing package for lazy loading\n** help\n*** installing help indices\n** building package indices\n** installing vignettes\n** testing if installed package can be loaded\nError in dyn.load(file, DLLpath = DLLpath, ...) : \n  unable to load shared object '/opt/rstudio-connect/mnt/app/packrat/lib/x86_64-pc-linux-gnu/3.2.3/nloptr/libs/':\n  /opt/rstudio-connect/mnt/app/packrat/lib/x86_64-pc-linux-gnu/3.2.3/nloptr/libs/ undefined symbol: nlopt_set_lower_bounds\nError: loading failed\nExecution halted\nERROR: loading failed\n* removing '/opt/rstudio-connect/mnt/app/packrat/lib/x86_64-pc-linux-gnu/3.2.3/nloptr'"
2017/10/23 15:50:06.563067112 Error: Command failed (1)
2017/10/23 15:50:06.563076900 
2017/10/23 15:50:06.563086261 Failed to run system command:
2017/10/23 15:50:06.563087928 
2017/10/23 15:50:06.563092213 	'/usr/lib/R/bin/R' --vanilla CMD INSTALL '/tmp/RtmpFdu0Ue/nloptr' --library='/opt/rstudio-connect/mnt/app/packrat/lib/x86_64-pc-linux-gnu/3.2.3' --install-tests --no-docs --no-multiarch --no-demo 
2017/10/23 15:50:06.563100685 
2017/10/23 15:50:06.563104944 The command failed with output:
2017/10/23 15:50:06.563106460 * installing *source* package 'nloptr' ...
2017/10/23 15:50:06.563111001 ** package 'nloptr' successfully unpacked and MD5 sums checked
2017/10/23 15:50:06.563112593 checking for g++... g++
2017/10/23 15:50:06.563116802 checking whether the C++ compiler works... yes
2017/10/23 15:50:06.563118389 checking for C++ compiler default output file name... a.out
2017/10/23 15:50:06.563124599 checking for suffix of executables... 
2017/10/23 15:50:06.563126299 checking whether we are cross compiling... no
2017/10/23 15:50:06.563130044 checking for suffix of object files... o
2017/10/23 15:50:06.563131584 checking whether we are using the GNU C++ compiler... yes
2017/10/23 15:50:06.563157640 checking whether g++ accepts -g... yes
2017/10/23 15:50:06.563159808 checking how to run the C++ preprocessor... g++ -E
2017/10/23 15:50:06.563164880 checking whether we are using the GNU C++ compiler... (cached) yes
2017/10/23 15:50:06.563167155 checking whether g++ accepts -g... (cached) yes
2017/10/23 15:50:06.563171929 checking for pkg-config... no
2017/10/23 15:50:06.563173817 configure: Now testing for NLopt header file.
2017/10/23 15:50:06.563178669 checking for grep that handles long lines and -e... /bin/grep
2017/10/23 15:50:06.563182450 checking for egrep... /bin/grep -E
2017/10/23 15:50:06.563186227 checking for ANSI C header files... yes
2017/10/23 15:50:06.563187939 checking for sys/types.h... yes
2017/10/23 15:50:06.563191230 checking for sys/stat.h... yes
2017/10/23 15:50:06.563192510 checking for stdlib.h... yes
2017/10/23 15:50:06.563196167 checking for string.h... yes
2017/10/23 15:50:06.563197556 checking for memory.h... yes
2017/10/23 15:50:06.563201178 checking for strings.h... yes
2017/10/23 15:50:06.563202499 checking for inttypes.h... yes
2017/10/23 15:50:06.563211028 checking for stdint.h... yes
2017/10/23 15:50:06.563212506 checking for unistd.h... yes
2017/10/23 15:50:06.563215763 checking nlopt.h usability... yes
2017/10/23 15:50:06.563217109 checking nlopt.h presence... yes
2017/10/23 15:50:06.563220364 checking for nlopt.h... yes
2017/10/23 15:50:06.563221546 configure: Suitable NLopt library found.
2017/10/23 15:50:06.563224783 configure: creating ./config.status
2017/10/23 15:50:06.563226238 config.status: creating src/Makevars
2017/10/23 15:50:06.563229598 ** libs
2017/10/23 15:50:06.563231004 g++ -I/usr/share/R/include -DNDEBUG      -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c dummy.cpp -o dummy.o
2017/10/23 15:50:06.563235580 gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG      -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c nloptr.c -o nloptr.o
2017/10/23 15:50:06.563244872 g++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o dummy.o nloptr.o -L/usr/lib/R/lib -lR
2017/10/23 15:50:06.563251494 installing to /opt/rstudio-connect/mnt/app/packrat/lib/x86_64-pc-linux-gnu/3.2.3/nloptr/libs
2017/10/23 15:50:06.563253019 ** R
2017/10/23 15:50:06.563256253 ** inst
2017/10/23 15:50:06.563257439 ** tests
2017/10/23 15:50:06.563260462 ** preparing package for lazy loading
2017/10/23 15:50:06.563261863 ** help
2017/10/23 15:50:06.563269711 *** installing help indices
2017/10/23 15:50:06.563271161 ** building package indices
2017/10/23 15:50:06.563274396 ** installing vignettes
2017/10/23 15:50:06.563275513 ** testing if installed package can be loaded
2017/10/23 15:50:06.563278754 Error in dyn.load(file, DLLpath = DLLpath, ...) : 
2017/10/23 15:50:06.563279932   unable to load shared object '/opt/rstudio-connect/mnt/app/packrat/lib/x86_64-pc-linux-gnu/3.2.3/nloptr/libs/':
2017/10/23 15:50:06.563283172   /opt/rstudio-connect/mnt/app/packrat/lib/x86_64-pc-linux-gnu/3.2.3/nloptr/libs/ undefined symbol: nlopt_set_lower_bounds
2017/10/23 15:50:06.563287436 Error: loading failed
2017/10/23 15:50:06.563291028 Execution halted
2017/10/23 15:50:06.563292215 ERROR: loading failed
2017/10/23 15:50:06.563295273 * removing '/opt/rstudio-connect/mnt/app/packrat/lib/x86_64-pc-linux-gnu/3.2.3/nloptr'
2017/10/23 15:50:06.563299344