New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document() recompiles package source code, which requires a NAMESPACE #1016

Closed
cboettig opened this Issue Jan 13, 2016 · 5 comments

Comments

Projects
None yet
2 participants
@cboettig

cboettig commented Jan 13, 2016

Attempting to write a package wrapper around some existing source code. For reasons that are not obvious to me, calling devtools::document() starts the package recompiling. Moreover, this call fails if the package does not have a NAMESPACE file. If I start the package with a manually created NAMESPACE (even a blank one), then devtools::document() runs, recompiling everything, but then refuses to update my NAMESPACE file. Thus it appears impossible to have devtools create a NAMESPACE for the package.

Of course I can hack around this by starting with a NAMESPACE file with the comment

# Generated by roxygen2: do not edit by hand

but this feels wrong. Is there a more elegant work-around out of this catch-22? (Why does document() need to recompile anyhow?) Am I missing something?

@hadley

This comment has been minimized.

Member

hadley commented Jan 13, 2016

Roxygen is a run-time documentation system - it inspects the objects in the package environment, not just the source code. That means it needs to load_all() the package, which obviously it can't do without compiling any C code.

Would you mind briefly outlining a series of steps that gets you to this point? Normally the NAMESPACE doesn't matter when compiling code.

@cboettig

This comment has been minimized.

cboettig commented Jan 13, 2016

Apologies for not having a good minimal example, this could be user error from a naive attempt to wrap a C program. Anyway, if you clone https://github.com/cboettig/rappl/tree/testing and run devtools::document() you should see the error about not having a NAMESPACE.

Here's the run log I see:

devtools::document()
Updating rappl documentation
Loading rappl
Re-compiling rappl
'/usr/lib/R/bin/R' --no-site-file --no-environ --no-save --no-restore CMD  \
  INSTALL '/home/rstudio/rappl'  \
  --library='/tmp/RtmpDrJUwI/devtools_install_17fbdfe81' --no-R --no-data  \
  --no-help --no-demo --no-inst --no-docs --no-exec --no-multiarch  \
  --no-test-load --preclean 

* installing *source* package ‘rappl’ ...
rm -f ./PolicyGraph/PolicyGraph.o ./PolicyGraph/PolicyGraphGenerator.o ./Evaluator/EvaluationEngine.o ./Evaluator/EvaluatorSampleEngine.o ./Simulator/SimulationEngine.o ./MathLib/DenseVector.o ./MathLib/MathLib.o ./MathLib/SparseMatrix.o ./MathLib/SparseVector.o ./Algorithms/SARSOP/BinManager.o ./Algorithms/SARSOP/BinManagerSet.o ./Algorithms/SARSOP/Sample.o ./Algorithms/SARSOP/SampleBP.o ./Algorithms/SARSOP/SARSOP.o ./Algorithms/SARSOP/SARSOPPrune.o ./Models/MOMDP/BeliefTransitionMOMDP.o ./Models/MOMDP/ObservationProbabilities.o ./Models/MOMDP/VariableRelation.o ./Models/MOMDP/BooleanVariable.o ./Models/MOMDP/StateTransitionXY.o ./Models/MOMDP/StateTransitionY.o ./Models/MOMDP/MOMDPLite.o ./Models/MOMDP/MOMDP.o ./Models/MOMDP/VariableValue.o ./Models/MOMDP/Variable.o ./Models/MOMDP/StateTransitionXXpY.o ./Models/MOMDP/IVariable.o ./Models/MOMDP/VariableCombined.o ./Models/MOMDP/Rewards.o ./Models/MOMDP/StateTransitionX.o ./Models/MOMDP/BeliefTransitionMOMDPLite.o ./Models/MOMDP/IVariableValue.o ./OfflineSolver/GlobalResource.o ./OfflineSolver/solverUtils.o ./Bounds/AlphaPlane.o ./Bounds/AlphaPlanePool.o ./Bounds/AlphaPlanePoolSet.o ./Bounds/AlphaVectorPolicy.o ./Bounds/BackupAlphaPlaneMOMDP.o ./Bounds/BackupAlphaPlaneMOMDPLite.o ./Bounds/BackupBeliefValuePairMOMDP.o ./Bounds/BackupBeliefValuePairMOMDPLite.o ./Bounds/BeliefValuePair.o ./Bounds/BeliefValuePairPool.o ./Bounds/BeliefValuePairPoolSet.o ./Bounds/BlindLBInitializer.o ./Bounds/FastInfUBInitializer.o ./Bounds/FullObsUBInitializer.o ./Bounds/PruneAlphaPlane.o ./Bounds/PruneBeliefValuePair.o ./Bounds/xml_parse_lib.o ./Core/Actions.o ./Core/VariableContainer.o ./Core/Belief.o ./Core/BeliefCache.o ./Core/BeliefException.o ./Core/BeliefForest.o ./Core/BeliefTreeNode.o ./Core/BeliefWithState.o ./Core/MObject.o ./Core/Observations.o ./Core/States.o ./Core/UniqueBeliefHeap.o ./Parser/Cassandra/Parser.o ./Parser/Cassandra/POMDP.o ./Parser/Cassandra/pomdpCassandraWrapper.o ./Parser/ParserSelector.o ./Parser/POMDPX/FactoredPomdp.o ./Parser/POMDPX/Function.o ./Parser/POMDPX/ObsAct.o ./Parser/POMDPX/PreCEntry.o ./Parser/POMDPX/PreCMatrix.o ./Parser/POMDPX/SparseEntry.o ./Parser/POMDPX/SparseTable.o ./Parser/POMDPX/State.o ./Parser/POMDPX/StateObsAct.o ./Parser/POMDPX/tinystr.o ./Parser/POMDPX/tinyxml.o ./Parser/POMDPX/tinyxmlerror.o ./Parser/POMDPX/tinyxmlparser.o ./Utils/InfoLog.o ./Utils/md5.o ./Utils/md5wrapper.o ./Utils/CPMemUtils.o ./Utils/StatsCollector.o ./Utils/SimulationRewardCollector.o ./Parser/Cassandra/include/pomdp_spec.tab.o ./Parser/Cassandra/include/pomdp_spec.yy.o ./miniposix/getopt.o ./miniposix/getopt1.o ./miniposix/getopt_init.o ./Parser/Cassandra/decision-tree.o ./Parser/Cassandra/imm-reward.o ./Parser/Cassandra/mdpCassandra.o ./Parser/Cassandra/parse_err.o ./Parser/Cassandra/parse_hash.o ./Parser/Cassandra/sparse-matrix.o ./Controller/Controller.o   ./OfflineSolver/solver.o  ./Simulator/Simulator.o  ./Evaluator/Evaluator.o  ./PolicyGraph/PolicyGraph.o  ./PomdpConvertor/convertor.o  ./Controller/testControllerTiger.o 
rm -f libappl.a pomdpsol pomdpsim pomdpeval polgraph pomdpconvert testControllerTiger
ERROR: a 'NAMESPACE' file is required
* removing ‘/tmp/RtmpDrJUwI/devtools_install_17fbdfe81/rappl’
Error: Command failed (1)
> 

This seems to be related to the fact that I am using the Makefile from the original C program, which I understand isn't the right thing to do, so perhaps this isn't a problem once I figure out how to write the proper Makevars file in place of it, so perhaps this isn't a real issue. (I have a deal to learn still on that front). I was just surprised by the error.

@hadley

This comment has been minimized.

Member

hadley commented Jan 13, 2016

How did you create the original package? Most ways should give you a dummy/empty NAMESPACE.

@cboettig

This comment has been minimized.

cboettig commented Jan 13, 2016

I created it with devtools::setup() (actually copied a template created with setup()). This created a dummy NAMESPACE (that does not have the #Generated by roxygen2: header), and so Roxygen was refusing to overwrite that. So I deleted the NAMESPACE and wound up with the above error.

@hadley hadley closed this in 15ca9df Jan 20, 2016

@lock

This comment has been minimized.

lock bot commented Sep 18, 2018

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/

@lock lock bot locked and limited conversation to collaborators Sep 18, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.