r-lib / devtools

Tools to make an R developer's life easier
https://devtools.r-lib.org
Other
2.39k stars 758 forks source link

devtools::install_github v2.0.1 error with static library #2001

Closed andreasakarlsson closed 5 years ago

andreasakarlsson commented 5 years ago

Upgrading devtools to version 2.0.1 causes devtools::install_github to render an error when compiling our microsimulation package. Reverting back to devtools 1.13.6 fixes this error.

https://github.com/mclements/microsimulation/issues/1#issuecomment-466884247

ar: ../inst/lib/libmicrosimulation.a: No such file or directory 
Makevars:12: recipe for target 'staticLibrary' failed 
make: *** [staticLibrary] Error 1 
ERROR: compilation failed for package ‘microsimulation’

Our microsimulation package uses a static library with the following Makevars:

PKG_CXXFLAGS = -I. -DVERSION=\"1.7.6\" -I../inst/include
PKG_CFLAGS = -I.

SOURCES = $(wildcard *.c */*.c */*/*.c)

OBJECTS = microsimulation.o cervical.o person-r.o calibperson-r.o simple-example.o simple-example2.o  illness-death.o ssim.o RngStream.o $(SOURCES:.c=.o)

all: $(SHLIB) staticLibrary

staticLibrary: $(SHLIB)
           $(AR) cr ../inst/lib/libmicrosimulation.a $(OBJECTS)
               $(RANLIB) ../inst/lib/libmicrosimulation.a

Is this a devtools bug or do we need to change how we use devtools?

Thank you! //Andreas

jimhester commented 5 years ago

You can use devtools::install_github("mclements/microsimulation", build = FALSE) to avoid building the package before installation, which fixes the issue.

However you could also modify your Makevars file to point to ../lib/ rather than ../inst/lib, the latter is only present in the un-built package. You might also have to setup a symlink from inst/lib to lib so that load_all() works if you do this.

In any case this is working as expected, so I don't think anything needs to change in devtools.

lock[bot] commented 4 years ago

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/