carpentries / sandpaper

User Interface for The Carpentries Workbench
https://carpentries.github.io/sandpaper
Other
41 stars 24 forks source link

Testing installation fails at create_lesson() #516

Closed tesaunders closed 1 year ago

tesaunders commented 1 year ago

Hi, see output below when following the Install Test.

> rmarkdown::pandoc_version()
[1] ‘3.1.1’
> tmp <- tempfile()
> sandpaper::no_package_cache()
ℹ Consent for package cache revoked. Use `use_package_cache()` to undo.
> sandpaper::create_lesson(tmp, open = FALSE)
Error in length(default) == 0 || default == "master" : 
  'length = 2' in coercion to 'logical(1)'

Output of sessionInfo():

> sessionInfo()
R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale:
[1] LC_COLLATE=English_New Zealand.utf8  LC_CTYPE=English_New Zealand.utf8    LC_MONETARY=English_New Zealand.utf8
[4] LC_NUMERIC=C                         LC_TIME=English_New Zealand.utf8    

time zone: Pacific/Auckland
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] vctrs_0.6.3       cli_3.6.1         knitr_1.43        rlang_1.1.1       xfun_0.39         processx_3.8.1    assertthat_0.2.1 
 [8] gitcreds_0.1.2    jsonlite_1.8.5    glue_1.6.2        openssl_2.0.6     askpass_1.1       htmltools_0.5.5   sys_3.4.2        
[15] ps_1.7.5          rappdirs_0.3.3    fansi_1.0.4       rmarkdown_2.22    evaluate_0.21     tibble_3.2.1      fastmap_1.1.1    
[22] lifecycle_1.0.3   httr2_0.2.3       whisker_0.4.1     compiler_4.3.1    fs_1.6.2          pkgconfig_2.0.3   rstudioapi_0.14  
[29] gh_1.4.0          digest_0.6.31     gert_1.9.3        R6_2.5.1          utf8_1.2.3        curl_5.0.1        pillar_1.9.0     
[36] credentials_2.0.1 callr_3.7.3       magrittr_2.0.3    sandpaper_0.13.1  tools_4.3.1
zkamvar commented 1 year ago

Oh this is interesting! For context, this is coming from a check that enforces that we never initialize lessons using the "master" branch. I did not account for the fact that it was possible to have two init.defaultBranch statements in git config (which is why the error says 'length = 2' in coercion to 'logical(1)'

Can you give me the output of this command? It will tell me what default branches you have listed so that I can confirm my model of the situation is correct.

cfg <- gert::git_config_global()
cfg$value[cfg$name == "init.defaultbranch"]

In the meantime, I will add a patch to fix this based on my current model and report back when it's ready.

zkamvar commented 1 year ago

I have a solution ready in #517 for you to test out.

You can install it by using either {pak} or {remotes}:

# VIA PAK -----------------------------------
# install.packages("pak")
pak::pkg_install("carpentries/sandpaper#517")

# ===== OR ======

# VIA REMOTES -------------------------------
# install.packages("remotes")
remotes::install_github("carpentries/sandpaper#517")
tesaunders commented 1 year ago

Thank you for the speedy reply! Ah yes this makes sense now. I added 'main' as a default branch:

> cfg <- gert::git_config_global()
> cfg$value[cfg$name == "init.defaultbranch"]
[1] "master" "main"  

After installing RTools:

> pak::pkg_install("carpentries/sandpaper#517")
✔ Loading metadata database ... done                                  

→ Will update 1 package.
→ Will download 1 package with unknown size.
+ sandpaper 0.13.1 → 0.13.1.9000 [bld][cmp][dl] (GitHub: c4ed1bd)
? Do you want to continue (Y/n) y
ℹ Getting 1 pkg with unknown size
✔ Cached copy of sandpaper 0.13.1.9000 (source) is the latest build
✔ No downloads needed, all packages are cached                      
ℹ Building sandpaper 0.13.1.9000
✔ Built sandpaper 0.13.1.9000 (10.3s)                                
✔ Installed sandpaper 0.13.1.9000 (github::carpentries/sandpaper@c4ed1bd) (164ms)
✔ 1 pkg + 78 deps: kept 66, upd 1 [25.1s] 

The installation now works:

> sandpaper::create_lesson(tmp, open = FALSE)
ℹ No schedule set, using Rmd files in episodes/ directory.                          
→ To remove this message, define your schedule in config.yaml or use `set_episodes()` to generate it.
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
ℹ To save this configuration, use                                                   

set_episodes(path = path, order = ep, write = TRUE)
✔ First episode created in C:/Users/Tom/AppData/Local/Temp/RtmpCel3wZ/file450826bc3fa2/episodes/introduction.Rmd
✔ Setting active project to 'C:/Users/Tom/AppData/Local/Temp/RtmpCel3wZ/file450826bc3fa2'
✔ Writing 'file450826bc3fa2.Rproj'
✔ Adding '.Rproj.user' to '.gitignore'
✔ Setting active project to '<no active project>'
ℹ Workflows up-to-date!                                                             
✔ Lesson successfully created in C:/Users/Tom/AppData/Local/Temp/RtmpCel3wZ/file450826bc3fa2
C:/Users/Tom/AppData/Local/Temp/RtmpCel3wZ/file450826bc3fa2                         
> sandpaper::build_lesson(tmp, preview = FALSE, quiet = TRUE)
> fs::dir_tree(tmp, recurse = 1)
C:\Users\Tom\AppData\Local\Temp\RtmpCel3wZ\file450826bc3fa2
├── CODE_OF_CONDUCT.md
├── config.yaml
├── CONTRIBUTING.md
├── episodes
│   ├── data
│   ├── fig
│   ├── files
│   └── introduction.Rmd
├── file450826bc3fa2.Rproj
├── index.md
├── instructors
│   └── instructor-notes.md
├── learners
│   ├── reference.md
│   └── setup.md
├── LICENSE.md
├── links.md
├── profiles
│   └── learner-profiles.md
├── README.md
└── site
    ├── built
    ├── DESCRIPTION
    ├── docs
    ├── README.md
    └── _pkgdown.yaml

Is it appropriate for me to close this now or is that something you do? (New to this)

zkamvar commented 1 year ago

Wunderbar! I will close this and will hopefully have the patch available on the universe by EOD