Closed gabrieldes closed 5 years ago
@gabrieldes I also saw this. It happens because the PATH
, that your OS uses to find the different programs installed on your system. The aws
executable is located at:
$ which aws
/Library/Frameworks/Python.framework/Versions/3.6/bin/aws
If you start R from the command line (or you start RStudio from the command line, by doing open my-project.RProj
)
> Sys.getenv("PATH")
[1] "/Users/filip/.rbenv/shims:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
If you start RStudio from the launch pad:
> Sys.getenv("PATH")
[1] "/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin"
In the first case, /Library/Frameworks/Python.framework/Versions/3.6/bin
is part of PATH
, so the aws
executable can be found. In the second case, it isn't, so aws
can't be found.
I thought the below steps would fix it, and they do, but they mess up other parts of running R, making it impossible to install packages for example.
To fix things, first figure out where your aws
binary is located (for me it's installed with Python 3.6):
$ which aws
/Library/Frameworks/Python.framework/Versions/3.6/bin/aws
Add an .Renviron
file to your root directory (~/.Renviron
), that adds the bin
folder where aws
is located to the PATH
:
PATH=/Library/Frameworks/Python.framework/Versions/3.6/bin:$PATH
If you now restart Rstudio from launch pad, it should work:
> Sys.getenv("PATH")
[1] "/Library/Frameworks/Python.framework/Versions/3.6/bin:$PATH:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
> system2("aws", args = "--version") # check if aws can be used
aws-cli/1.14.32 Python/3.6.4 Darwin/17.3.0 botocore/1.8.36
@gabrieldes As mentioned in the previous comment, I thought it was fixed, but it severely tripped other aspects up. I'll have to spend more time on the side to figure this out. Until then, you can work around it by opening RStudio from the command line, by doing the open my-project.RProj
command I mentioned.
@filipsch opening RStudio from the command line worked. Thx
@gabrieldes I looked some more; it should be fixed if you make ~/.Renviron
contain:
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
The actual location of the aws
executable can be a different folder, so update accordingly if necessary. Please close if this fixes it; thanks!
I just fell over this too. Maybe worth adding a section to the README installation instructions like:
To ensure that R can find and use aws
, you need to add its directory to the PATH environment variable. In the terminal, type
awsfile=$(which aws)
awsdir=$(dirname $awsfile)
printf 'PATH=$PATH:%s' "$awsdir" >> ~/.Renviron
Probably worth the package giving a warning if it can't find aws
when it loads.
.onLoad <- function(libname, pkgname){
assertive.reflection::assert_r_can_find_tools("aws", severity = "warning")
}
@richierocks I thought the https://github.com/datacamp/dbconnectr#use-in-rstudio section does that. Feel free to do a PR with any changes that you suggest.
@filipsch Oh, right. I hadn't read that far! Maybe just swap the order of things since you have to do that before you try running anything.
I don't seem to have permission to create a new branch. Happy to do a PR if I can have permission.
@richierocks you should have access now
I think we can safely close this.
I get the following error:
When running this command in RStudio:
get_databases()
It seems @martijnsublime has the same issue. Something worth noting as well is if I run the same command in an R session in my terminal, it works.
I tried reproducing this on Anthony's computer, but it works on his. The only difference I've identified is that he runs R version 3.4.2 and I run R version 3.4.3.