Search code examples
rtravis-cidevtools

travis build failing because of an apparent circular package dependency


I have an R package A and a package B. The package B genuinely depends on A for some of its functions. The package A depends on B, but only for testing. So the package dependency is not genuinely circular.

The travis build fails for A because upon installing A it tries to install B only to find A is not installed.

How can I tell travis not to worry about B until it starts testing?

My thoughts are to:

  • Put all of B's dependencies in A, leaving B independent.
  • Leave off the dependency of A on B, and construct the test as if B didn't exist.

But both seem as drastic as abandoning unit testing.

I've mocked up an minimum reproducible example:

https://github.com/HughParsonage/AAAA

https://github.com/HughParsonage/BBBB

When I push AAAA to travis, I get:

ERROR: dependency ‘AAAA’ is not available for package ‘BBBB’

removing ‘/usr/local/lib/R/site-library/BBBB’

Error: Command failed (1)

Execution halted

My actual packages are

A: https://github.com/HughParsonage/grattan

B: https://github.com/HughParsonage/taxstats


Solution

  • I suspect you know the answer to this: Just avoid the circular dependency.

    There just was an insightful and detailed discussion about a very related situation on the r-devel list in this thread. You a look at the discussion there; several options were proposed and the original poster was somewhat convinced -- just like you here -- that the standard laws of gravity would not apply to them.

    I would just avoid the problem and put the commonalities into a new package pkgC upon which pkgA and pkgB can depend, or even just suggest it. Another simply solution (also proposed in the thread) is to just merge pkgA and pkgB.