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

GIT authentication in rstudio-server not working #233

Open
behrica opened this issue Jun 21, 2024 · 8 comments
Open

GIT authentication in rstudio-server not working #233

behrica opened this issue Jun 21, 2024 · 8 comments

Comments

@behrica
Copy link

behrica commented Jun 21, 2024

I am using the rstudio feature

"ghcr.io/rocker-org/devcontainer-features/rstudio-server": {}

But I am unable to get github authentication working when using the rstudio GIT ui.
It always fails with "authentication required"
I tried all possible ways including environment vars or git helpers , but nothing worked.

Is somebody aware of instructions for a "working authentication" of the rstudio-sever devcontainer feature with GitHub.

(Git in VSCode is fully functional)

With quite some "magic" I got git push/pull working in the rstudio Terminal, but not in the UI, including setting of env vars.

The most concrete issue was, that I could not configure the rserver process with environment vars in
"/etc/rstudio/env-vars". I this a known issue ?

@eitsupi
Copy link
Member

eitsupi commented Jun 22, 2024

From what tool do you use the Feature?
What does the git config look like?

If you are using VS Code Devcontainers, this issue may be related r-lib/pak#633.

@behrica
Copy link
Author

behrica commented Jun 22, 2024

I use Codespaces and, the devcontaioner.json is this:

{
	"name": "R (rocker/r-ver base)",
	"image": "ghcr.io/rocker-org/devcontainer/r-ver:4.4",
	"features": {
		"ghcr.io/rocker-org/devcontainer-features/pandoc:1": {},
		"ghcr.io/rocker-org/devcontainer-features/r-packages:1": {
			"packages": "rmarkdown,devtools,tidyverse,r-lib/xml2,jsonlite,httr2",
			 "additionalRepositories": "CRAN = 'https://packagemanager.posit.co/cran/2024-06-10'"
		},
		"ghcr.io/rocker-org/devcontainer-features/rstudio-server": {}
	},
	"postAttachCommand": {
        "rstudio-start": "rserver"
    },
    "forwardPorts": [
        8787
    ],
    "portsAttributes": {
        "8787": {
            "label": "RStudio IDE"
        }
	},

   "remoteEnv":{
       //not working
	"GCM_CREDENTIAL_STORE": "cache"
   }
   
}

@behrica
Copy link
Author

behrica commented Jun 22, 2024

The "high level description of the issue" could as well be expressed as:

The rstudio instances started by the rstudio-feature ""ghcr.io/rocker-org/devcontainer-features/rstudio-server" does not inherit the correctly setup GIT authentication configuration from Codespaces.
Additionally I could not find documentation anywhere about this.

@behrica
Copy link
Author

behrica commented Jun 22, 2024

The "root cause" of the issues likes in the fact that when using the rstudio server together with codespaces, the source code will not be cloned by rstudio . As it is cloned already by Codespaces, which configures certain GIT authentication methods-
So when using rstudio a ".git" folder is alreday present. And I did not find a way to "tell rstudio" how to authenticate the existing and gloned repo. It does not "detect" the VSCode GIT setup or similar

@behrica
Copy link
Author

behrica commented Jun 22, 2024

I found a workaround, namely to "change" the remote url, so replacing an url like:
https://github.com/my-project

via

git remote set-url origin xxxx@https://github.com/my-project

where xxx is a github token.
After doing this, the GIT features of rstudio seems to work, but it lost the "tracking remote", so needed to set this by hand as well.

@eitsupi
Copy link
Member

eitsupi commented Jun 23, 2024

The rstudio instances started by the rstudio-feature ""ghcr.io/rocker-org/devcontainer-features/rstudio-server" does not inherit the correctly setup GIT authentication configuration from Codespaces.

I believe RStudio Server is intentionally designed not to read environment variables. For example, if you search the internet you will find the following post:
https://stackoverflow.com/questions/16867720/rstudio-server-environment-variables-not-loading

I guess what we could do here is use a lifecycle script to write the environment variables to something like Renviron before RStudio Server starts, does that make sense?
Pull Requests are welcome!

@behrica
Copy link
Author

behrica commented Jun 24, 2024

Renviron would not work I believe, as this sets it for the "rsession".
But the rstudio GIT UI tools are part of "rserver" itself, not the rsession.
I tried to set manual env-vars as documented here:
https://docs.posit.co/ide/server-pro/1.4.1722-1/server-management.html chapter 2.1.4,
but this did not have any visible effect to me.

@eitsupi
Copy link
Member

eitsupi commented Jun 24, 2024

Could you ask about the RStudio IDE in the upstream?
I believe we just have a standard setup here.

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