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

Manage dependencies from GitHub Enterprise #448

Open
hector-ps opened this issue Oct 17, 2019 · 13 comments
Open

Manage dependencies from GitHub Enterprise #448

hector-ps opened this issue Oct 17, 2019 · 13 comments
Labels
feature a feature request or enhancement github

Comments

@hector-ps
Copy link

hector-ps commented Oct 17, 2019

Dependencies from GitHub can be managed by including Remotes: [remote::]repo_spec in the DESCRIPTION file. Downloading packages from GitHub Enterprise requires the argument host on install_github, that cannot be defined in the DESCRIPTION file. While I understand that the general approach for packaging and sharing R code is using public repositories, company policies usually forces the developer to use private GitHub Enterprise. Are you considering to add a way for indicating inside the DESCRIPTION file the host to use?

@cderv
Copy link
Contributor

cderv commented Oct 17, 2019

@ijlyttle How wonder how you do that with remotes and your 📦 ghentr ?
Is this possible for you ?

@ijlyttle
Copy link

ijlyttle commented Oct 17, 2019

The package maintainers can speak on this with infinitely-greater authority than I can: I think that extensibility mechanisms are something they are thinking about across r-lib, e.g. usethis, remotes, etc.

To address @cderv's point, the I can't get the ghentr idea to work with remotes, which let me to ask about a way forward and workarounds. I can summarize the workaround they have suggested to me, which work for me while the larger issues are worked out.

The central idea is to use a url:: remote. For example, the standard GitHub remote:

r-lib/usethis

Can be expressed, roughly equivalently, as:

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

Using a URL means that I don't have access to specific branches or releases, but I can point it at a repository on GitHub Enterprise. Update: I'm wrong - you can access specific branches or releases, see @jimhester's comment 👇

Hope this helps!

@cderv
Copy link
Contributor

cderv commented Oct 17, 2019

The central idea is to use a url:: remote. For example, the standard GitHub remote:

This is what I thought. I got the same idea. I use that for gitlab on my side. Not the best way.

It would be nice to have an option to tell remotes : « now we mean for github this url not github.com ». I guess it means a way to change globally the default host used in ˋinstall_github` and implicitly in ˋgithub_remoteˋ when parsing DESCRIPTION.

Thanks @ijlyttle for you thoughts.

@hector-ps
Copy link
Author

Thanks @ijlyttle and @cderv for this workaround. I will use the url:: remote until an option to tell remotes : « now we mean for github this url not github.com ». is developed. This is a really useful approach.

@jimhester
Copy link
Member

Just a small clarification, you can access releases and branches, e.g.

A specific release

https://github.com/r-lib/remotes/archive/v2.1.0.zip

A branch

https://github.com/r-lib/remotes/archive/always-install-uninstalled.zip

@hector-ps
Copy link
Author

Sorry for the inconvenience, Guys.

When I point the url:: remote to the zip url I get the following error:

Downloading package from url: https://github.example.com/organization/repo/archive/branch.zip
Error: Failed to install '******' from GitHub:
  Failed to install 'unknown package' from URL:
  zip file 'example_temp_zip_path.zip' cannot be opened
In addition: Warning message:
In utils::unzip(src, exdir = target) : error 1 in extracting from zip file

If I use install_url I get the same result, while install_github (passing the conveniend host) works as expected. How is install_url authenticating on the GitHub Enterprise? Do you think this authentication could be the source of the error?

@ijlyttle
Copy link

ijlyttle commented Oct 25, 2019

@hector-ps: I can think of a couple of possibilities:

  • Is this a private repository?
  • Perhaps something in the URL is mispelled? My go-to to get things working the first time is to "Copy Link Address":

image

@hector-ps
Copy link
Author

Hi, @ijlyttle.

It's public inside my company, but my Enterprise instance of GitHub is not public. To install the repositories using install_github I pass a personal token in the auth_token argument.

@ijlyttle
Copy link

ijlyttle commented Oct 25, 2019

Hi @hector-ps,

If it is public inside your company, you should be able to use the "Copy Link Address" value
with install_url() - that works for me...

@pawelru
Copy link

pawelru commented Oct 29, 2019

Hi @hector-ps

I managed to do it for my package on Github Enterprise. For the installation please use:

Sys.setenv("GITHUB_PAT" = "<your PAT>")
remotes::install_github("<user>/<repo>", host = "https://github.<company>.com/api/v3")
Sys.unsetenv("GITHUB_PAT")

Then for the dependency I can confirm that url:: type of remote is working. My entries in the DESCRIPTION file are as follows: url::https://github.<company>.com/<user>/<repo>/archive/<version>.zip.

Please note that it's a link to a zip file for a given released version (in particular: it's not a git zip file for a branch that is presented above). In my case that's a significant limitation because I really want to use branch names, PR and also *release thing in specifying dependency. Basically it's not possible to use e.g. development version of a package (because it's not tagged and thus not zipped).

@jimhester Is there any plans for adding github:: type of dependency for packages on Github Enterprise?

@wligtenberg
Copy link

I am also looking into making remotes work from Github Enterprise.

So far, we have been using mostly SSH keys and works using the normal git protocol.
I just need to specify this first:
options("remotes.git_credentials" = git2r::cred_ssh_key())

However, the normal git protocol does not support branches or tags.
I tried to use:
git@github.<company>.com:<username>/<repo>.git#v2 or git@github.<company>.com:<username>/<repo>.git@v2

git2r then complains that the url is wrong, which is technically correct.

I then tried to use the url protocol, but that fails with the following message:

Error: Failed to install 'unknown package' from URL:
   length(file_list) > 0 is not TRUE

I tried downloading the file with download.file and I seem to be getting some login page html. :(

So, now I have found this thread. And using the code snippet from @pawelru it works, also for branches and tags.
However, how can I then use this in a DESCRIPTION file?

Maybe we could have something like this:
github::https://github..com//@tag

Or what would work for me as well is:
git::git@github..com:/.git@tag

I am not sure which one is easiest to implement.

@jimhester jimhester added feature a feature request or enhancement github labels Apr 3, 2020
@strazto
Copy link

strazto commented Mar 8, 2021

If you're on windows and you're finding that:

# R
remotes::install_git("git@example.com:me/mypkg.git", git = "ext")

seems to fail, while

# bash
git clone git@example.com:me/mypkg.git

works, it's worth noting that, though both call the same ssh program, your shell usually looks for configs under /c/Users/username/.ssh, whilst R will look under /c/Users/username/Documents/.ssh.

This behavious confused me for a long while, and was the reason that using ssh keys to access my enterprise repos wasn't working on windows, but did work on other platforms.

@jabenninghoff
Copy link

Is this resolved by #541? I was able to use Enterprise GitHub in DESCRIPTION with:

Remotes: github@api.github.company.com::<username>/<repo>[@ref]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement github
Projects
None yet
Development

No branches or pull requests

8 participants