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

Possible issue with sso_credential_process on Windows #640

Closed
karen5780 opened this issue Jun 30, 2023 · 11 comments
Closed

Possible issue with sso_credential_process on Windows #640

karen5780 opened this issue Jun 30, 2023 · 11 comments
Labels
bug 🐞 Something isn't working

Comments

@karen5780
Copy link

Hi - I'm not a developer and am not really sure what I'm doing. As in I created a github account just now to make this post. But I've run into a possible bug that I think has an easy fix.

I'm running R 4.2.2 on Windows 10 and am using paws 0.2.0 to get AWS S3 data. The code I'm using (pasted below) works for me, and some but not all of the other users.

I've narrowed the issue to within sso_credential_process():
root <- ifelse(Sys.info()[[1]] == "Windows", Sys.getenv("HOMEPATH"), "~")
sso_cache <- file.path(root, ".aws", "sso", "cache", json_file)
if (!file.exists(sso_cache))

R is not finding the sso_cache file for some of my fellow users with only the HOMEPATH variable being specified. I don't know enough about how to figure out what file.exists is doing behind the scenes, but for them, the HOMEDRIVE also needs to be specified. As in, the root assignment line root <- ifelse(Sys.info()[[1]] == "Windows", paste0(Sys.getenv("HOMEDRIVE"), Sys.getenv("HOMEPATH"), "~") fixes the problem.

FYI, here's the code I'm using to read in from S3 with SSO.

library(paws)
config_path <- paste(Root_Folder,"config", sep = "/")
sso_profile <- "profile-name"
Sys.setenv(AWS_CONFIG_FILE = config_path,
AWS_PROFILE = sso_profile)
system(paste("aws sso login --profile", sso_profile))
s3 <- paws::s3(config = list(region = "ca-central-1"))
file <- s3$get_object(Bucket = bucket_name, Key = "File.csv")

@DyfanJones
Copy link
Member

Ah thanks for this. I dont have windows computer to test this out fully. I will raise a PR. Are you or colleagues able to test this out for me?

@karen5780
Copy link
Author

karen5780 commented Jun 30, 2023 via email

@DyfanJones
Copy link
Member

@DyfanJones
Copy link
Member

@karen5780 Please try:

remotes::install_github("dyfanjones/paws/paws.common", ref = "sso_win_path")

It is basically the solution you proposed

@DyfanJones DyfanJones added the bug 🐞 Something isn't working label Jun 30, 2023
@karen5780
Copy link
Author

Hi - I'm unfortunately probably not a good person to test this as I don't know much about R. When running the line, I got the following message: Package paws.common has compiled code, but no suitable compiler(s) were found. Installation will likely fail. And it did fail.

I don't have RTools and have no idea how to install anything that doesn't have a binary. Also FYI, this may perhaps be an issue with another package as I got messages prompted me to update other packages. I couldn't update jsonlite to 1.8.7 from 1.8.5 or digest from 0.6.32 from 0.6.31 as the binaries weren't available.

If you have any quick suggestions as to how I can test this out, I'd be happy to try.

@karen5780
Copy link
Author

I don't know enough about Windows either to know anything about the environment variables. It's my first time ever explicitly looking at either HOMEPATH or HOMEDRIVE - and only got HOMEDRIVE from a google search. I'm just an actuary who's proud of herself for getting this far. :)

@DyfanJones
Copy link
Member

DyfanJones commented Jun 30, 2023

No worries I believe I can build the binary for you :)

paws.common_0.5.8.zip

paws_common_download_path <- "paws.common_0.5.8.zip"
install.packages(paws_common_download_path , repos = NULL)

If you want to install Rtools for building R packages from source, heres the link to Rtools for 4.2 version of R :)

Website link: https://cran.r-project.org/bin/windows/Rtools/rtools42/rtools.html
Rtools42 exe: https://cran.r-project.org/bin/windows/Rtools/rtools42/files/rtools42-5355-5357.exe

@karen5780
Copy link
Author

Hi @DyfanJones, this works for me, thanks! I'll check on Tuesday to see if it works for my coworker - tomorrow is a stat holiday for us in Canada. I imagine this should work.

One thing that seems a little strange to me is how the root variable looks on my computer.
Sys.getenv("HOMEDRIVE") lists "C:" for me and Sys.getenv("HOMEPATH") is "\Users\username". Using file.path to paste them together gives "C:/\Users\username" - I thought this would be one slash too many, but it's fine with file.exists().

@karen5780
Copy link
Author

Hi @DyfanJones, this worked for my coworker as well. The production version didn't work for her, so I believe the fix worked. Thanks!

@DyfanJones
Copy link
Member

@karen5780 That is great news. paws.common 0.5.8 will be getting released to the cran shortly.

@DyfanJones
Copy link
Member

Paws.common 0.5.8 has been released to the cran. I will close this ticket. Please re-open if problem persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants