Skip to content
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

Windows - Validating local repository, not as easy as it sounds #146

Open
Seb-FS-Axpo opened this issue Oct 23, 2024 · 2 comments
Open

Windows - Validating local repository, not as easy as it sounds #146

Seb-FS-Axpo opened this issue Oct 23, 2024 · 2 comments

Comments

@Seb-FS-Axpo
Copy link

Seb-FS-Axpo commented Oct 23, 2024

Hi.

I am trying to use drat to expose private packages into our organization internal GitHub.

I am working on Windows and I had a "nice time" trying to validate the repository created locally but finally I managed.

I am raising this for your own amusement and also as this could be nice to maybe document so that the next guy don't waste hours like I did while trying to test the local repository ^_^

On Drat git repo session

drat::insertPackage("c:/fullpath/using/forward/slashes/package.tar.gz", 
repodir = getOption("dratRepo", "c:/forward/slashed/path/git/docs"))
# source package added as expected, in src\contrib and index created

drat::insertPackage("c:/fullpath/using/forward/slashes/package.zip", 
repodir = getOption("dratRepo", "c:/forward/slashed/path/git/docs"))
# binary package added as expected, in bin\windows\contrib\4.2 and index created

Using separate R session,

Using forward slashes path with verbose flag set [FAILURE]

# using forward slashes path
install.packages("mypackage", repos = "c:/Users/myuser/source/work/r/drat-repo/git/docs", verbose = TRUE)
# fails with output
Installing package intoC:/Users/myuser/source/work/r/fresh/renv/library/R-4.2/x86_64-w64-mingw32’
(aslibis unspecified)
Warning: unable to access index for repository c:/Users/myuser/source/work/r/drat-repo/git/docs/src/contrib:
  cannot open URL 'c:/Users/myuser/source/work/r/drat-repo/git/docs/src/contrib/PACKAGES'
Warning: unable to access index for repository c:/Users/myuser/source/work/r/drat-repo/git/docs/bin/windows/contrib/4.2:
  cannot open URL 'c:/Users/myuser/source/work/r/drat-repo/git/docs/bin/windows/contrib/4.2/PACKAGES'
Warning message:
packagemypackageis not available for this version of R

A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages 

Then using backward slashes path and verbose flag set [FAILURE]

# using forward slashes path
install.packages("mypackage", repos = "c:\\Users\\myuser\\source\\work\\r\\drat-repo\\git\\docs", verbose = TRUE)
# fails with output
Installing package intoC:/Users/myuser/source/work/r/fresh/renv/library/R-4.2/x86_64-w64-mingw32’
(aslibis unspecified)
Warning: unable to access index for repository c:\Users\myuser\source\work\r\drat-repo\git\docs/src/contrib:
  cannot open URL 'c:\Users\myuser\source\work\r\drat-repo\git\docs/src/contrib/PACKAGES'
Warning: unable to access index for repository c:\Users\myuser\source\work\r\drat-repo\git\docs/bin/windows/contrib/4.2:
  cannot open URL 'c:\Users\myuser\source\work\r\drat-repo\git\docs/bin/windows/contrib/4.2/PACKAGES'
Warning message:
packagemypackageis not available for this version of R

A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages 

More or less same output but we can see that output warnings contains path with backward slashes

Then, using backward slashes path and the file: prefix, still with verbose flag set [SUCCESS but without dependencies]

# using forward slashes path
install.packages("mypackage", repos = "file:c:\\Users\\myuser\\source\\work\\r\\drat-repo\\git\\docs", verbose = TRUE)
# succeeds
Installing package intoC:/Users/myuser/source/work/r/fresh/renv/library/R-4.2/x86_64-w64-mingw32’
(aslibis unspecified)
Warning: dependencies (...) are not available
packagemypackagesuccessfully unpacked and MD5 sums checked

Then cherry on the cake, using any of the 3 previous path formats and verbose flag not set like

install.packages("mypackage", repos = "c:/Users/myuser/source/work/r/drat-repo/git/docs")
install.packages("mypackage", repos = "c:\\Users\\myuser\\source\\work\\r\\drat-repo\\git\\docs")
install.packages("mypackage", repos = "file:c:\\Users\\myuser\\source\\work\\r\\drat-repo\\git\\docs")

All goes well, including install of dependencies [PARTY TIME]

In case this would interest you as well, while trying to use pak with any of the paths it fails :(

 pak::repo_add(localRepo = "c:/Users/myuser/source/work/r/drat-repo/git/docs")
 pak::pkg_install("mypackage")
 # fails
 Error:                                                                     
! error in pak subprocess
Caused by error: 
! Could not solve package dependencies:
* mypackage: Can't find package called mypackage.

Thanks already for reading this quite long post ^_^

@eddelbuettel
Copy link
Owner

Interesting. I think when you want a file path you actually must prefix it with file:// as you did (and I am unsure about the slashes). This comes from R, and possibly the Windows C library. We can possibly experiment a little more, and I think this is mostly a documentation issue. Thanks for posting!

@Seb-FS-Axpo
Copy link
Author

No worries, thanks for your prompt feedback.
That's most likely not a drat issue per say, but I thought it could be interesting for you to know, play with and document.
I was quite disappointed by this VERBOSE flag side effect and almost as much by pak which is usually quite handy.

Please close this ticket when you think it is right.

I have another issue related to GitHub permissions that I am not able to figure out, so I'll create another ticket to keep both asides :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants