usethis::use_course() ... zip file is downloaded, but get error

I would love to take advantage of usethis::use_course(), but I keep getting the following error:

> usethis::use_course(shortURL, destdir = getwd())
 Downloaded: 1.26 MB  (100%)
βœ” Downloaded ZIP file to 'C:/Users/ajf/OneDrive/Teaching/FSAN830 - Spring2019/testUseThisDownload/2TnwCYe'
Error in if (length(unique_top) > 1 || !is_directory) { : 
  missing value where TRUE/FALSE needed

Here is reproducible code:

# longer URL:
# https://github.com/flyaflya/lotr-tidy/raw/master/rFilesForDataVizClass.zip
shortURL = "https://bit.ly/2TnwCYe"
usethis::use_course(shortURL, destdir = getwd())

Any help/guidance is greatly appreciated. I would love to use this feature all the time.

The use_course function needs you to link to the .zip for the repository, and not a .zip inside of your repo.

This will work:

shortURL = "https://bit.ly/2EvWpEb"
usethis::use_course(shortURL, destdir = getwd())

The shortURL points to https://github.com/flyaflya/lotr-tidy/archive/master.zip

Hope that helps!

3 Likes

Here are more details on how to use from the docs:

GitHub:

Click on the repo's "Clone or download" button, to reveal a "Download ZIP" button. Capture this URL, which will have this form:

https://github.com/r-lib/usethis/archive/master.zip

This download link (or a shortlink that points to it) is suitable as input for download_zip() . After one or more redirections, this link will eventually lead to a download URL. Here's an alternative link that also leads to ZIP download, albeit with a different filenaming scheme:

https://api.github.com/repos/r-lib/usethis/zipball/master

1 Like

Thanks everyone, this is a great community and the responsiveness is outstanding!

As soon as I link to the whole repository, it works. I got thrown by the documentation where it says:

Function developed with DropBox and GitHub in mind, but should work for ZIP files generally.

If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.