KentonWhite / ProjectTemplate

A template utility for R projects that provides a skeletal project.
http://projecttemplate.net
GNU General Public License v3.0
623 stars 159 forks source link

Check and install missing packages on load.project() #259

Closed sdrakulich closed 6 years ago

sdrakulich commented 6 years ago

Report an Issue / Request a Feature

I'm submitting a (Check one with "x") :


Issue Severity Classification -

(Check one with "x") :

Expected Behavior

A repository I move between systems works seamlessly when load.project() is executed.

Current Behavior

It fails to load packages the other system does not have installed.

Version Information

Latest version

Possible Solution

I would if I wasn't a complete beginner. Haven't touched the innards of a function yet. That being said, I found this and felt it should be fairly straightforward to implement. I might try myself! The package is called "pacman". Explained here.

Hugovdberg commented 6 years ago

pacman was explicitly not included in this project, and load.project should indeed install the missing packages. For me it works fine, but it appears some people are experiencing this issue (see for example #213 and #216). Since we cannot replicate the situation this is very hard to debug. There is already a function that tries to load the package, and if that fails installs it (much like pacman does, but without adding the dependency on an external package).

Do you get any error when you call load.project on a system that hasn't got the necessary packages installed? Also, could you paste the contents of your config/global.dcf file?

Hugovdberg commented 6 years ago

Hmm, I just noticed that all warnings generated inside require.package are currently hidden. Perhaps @KentonWhite can shine a light on why he coded it that way, it might be that it obscures the problem @sdrakulich experiences.

sdrakulich commented 6 years ago

First, I apologize for not using search.

Now that that's out of the way, I think I know what the problem is. The way I'm executing, there is no default repository set. If I could pass that argument globally to just default to the CRAN one, that should make this work under my infrastructure (Atom-editor with R-enabled functionality through jupyter lab).

Hugovdberg commented 6 years ago

Ah, but you don't get the request to select a repository? And do you get that request when manually installing a package? Because if that request is somehow hidden as an effect of using require.package as a wrapper around install.packages then we should try and fix that of course.

sdrakulich commented 6 years ago

Can I just reply to the email? Anyways, this is the error I get. I'm missing the last package in my load sequence.

Project name: XXX

Loading project configuration Autoloading packages Loading package: <> Loading package: beepr Loading required package: beepr Error in contrib.url(repos, "source"): trying to use CRAN without setting a mirror Traceback:

  1. load.project()
  2. .load.libraries(config, my.project.info)
  3. require.package(package.to.load)
  4. install.packages(package.name)
  5. contrib.url(repos, "source")
  6. stop("trying to use CRAN without setting a mirror")

On Sat, May 5, 2018 at 11:06 AM, Hugo van den Berg <notifications@github.com

wrote:

Ah, but you don't get the request to select a repository? And do you get that request when manually installing a package? Because if that request is somehow hidden as an effect of using require.package as a wrapper around install.packages then we should try and fix that of course.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/KentonWhite/ProjectTemplate/issues/259#issuecomment-386811873, or mute the thread https://github.com/notifications/unsubscribe-auth/AAKtbhjVWsyxXy3G0RYdzHRF55lNbMusks5tvcAOgaJpZM4TzgmI .

KentonWhite commented 6 years ago

We can unquiet warnings in require.package. It was added to minimize the amount of information when installing packages. It may be helpful for debugging. I'll make a quick PR.

KentonWhite commented 6 years ago

Warnings are unquieted in require.package.

@sdrakulich can you reinstall ProjectTemplate from GitHub using install_github('KentonWhite/ProjectTemplate'), rerun your project and repost the errors and warnings please.

Hugovdberg commented 6 years ago

@sdrakulich Could you please tell us if the error still occurs and what warnings you see after installing the latest version from github?

KentonWhite commented 6 years ago

Haven't heard that the error still persists. Closing for now. If this error still is happening please reopen.