R-ArcGIS / r-bridge

Bridge library to connect ArcGIS and R, including arcgisbinding R library.
Apache License 2.0
118 stars 26 forks source link

arc.portal_connect() crashes #75

Closed joshualerickson closed 1 year ago

joshualerickson commented 1 year ago

Describe the bug The bug crashes R.exe when running arc.portal_connect(). Thought it might be a Rstudio bug but is isolated to R.exe. Right now the work around is to open Arc* software and sign in but would be nice to be able to do this in R (enhancement?). Thanks.

To Reproduce Steps to reproduce the behavior:

  1. Run arc.portal_connect() function.
  2. Crash R studio.

Screenshots If applicable, add screenshots to help explain your problem.

arcgisbinding info (please complete the following information):

> arc.check_product()
product: ArcGIS Pro (12.2.0.12813)
license: Advanced
version: 1.0.1.300 

arcgisbinding_1.0.1.300

R version 4.2.0 (2022-04-22 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19044)

orhuna commented 1 year ago

@joshualerickson I observed a similar behavior on R 4.2. I am not with ESRI anymore. Adding R-ArcGIS members who might provide next steps forward.

JosiahParry commented 1 year ago

Thanks @joshualerickson and @orhuna :) I'll try and repro this tomorrow!

@joshualerickson, for my edification can you elaborate a bit more on the use after arc.portal_connect() that you're aiming for? Once you've connected to a portal what is your objective?

joshualerickson commented 1 year ago

It used to be the way I could sign in to AGOL account and then interact other data. Now I just open ArcPro and sign in.

JosiahParry commented 1 year ago

Hey @joshualerickson super sorry for the delay :P

Here is a reprex from my end though I'm on a development version of Pro. Is the portal you connecting to arcgis.com? Or an enterprise one?

library(arcgisbinding)
#> *** Please call arc.check_product() to define a desktop license.

arc.check_product()
#> product: ArcGIS Pro (13.1.0.41784)
#> license: Advanced
#> version: 1.0.1.300
arc.check_portal()
#> *** Current
#>   url        : https://www.arcgis.com/
#>   version    : 10.3
#>   user       : jparry_ANGP
#>   organization   : GP Analysis - Prod Hive 1
arc.portal_connect("https://www.arcgis.com")
#> *** Current
#>   url        : https://www.arcgis.com/
#>   version    : 10.3
#>   user       : jparry_ANGP
#>   organization   : GP Analysis - Prod Hive 1

Created on 2023-02-06 with reprex v2.0.2

JosiahParry commented 1 year ago

Okay. On that note I can crash R by then running

furl <- "https://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS/rest/services/USA_Counties_Generalized_Boundaries/FeatureServer/0"
arc.open(furl)
joshualerickson commented 1 year ago

Hey @JosiahParry it seems to crash after I run arc.check_product(). I work for the USDA - Forest Service so I'm not sure if that's a enterprise account or not 🤷...

Thanks for looking into it!

image

JosiahParry commented 1 year ago

Looks like when you loaded arcgisbinding you ran into warnings. Would you be able to share what those are? Also, it looks like you're starting from a previously loaded session. Can you create a new session (session -> new session) and clear the workspace (click the broom next to Environment) and try again? I'm sure the result is likely the same but starting from a blank slate is always good

joshualerickson commented 1 year ago

Yeah looks like the same thing again... I'm not sure what the warnings were from the other project/session. FWIW, it used to work and I would just put my username and pword in and voila access to portal. I'm not sure what version it was but it started to crash whenever I would do it so I stopped using arcgisbinding all together. Then I came back and opened ArcPro and signed in and it works. But would be really nice if I didn't have to open ArcPro each time....

image

mmachir commented 1 year ago

Hi there @joshualerickson - for further testing, it'd be helpful to get two pieces of info: (1) ArcGIS Online vs. ArcGIS Enterprise and (2) licensing method.
For (1), here's how to tell which you're using: in Pro, go to the upper right corner where you sign in and click on your user name (or Not Signed In). If the url there includes "arcgis.com", that's ArcGIS Online. (If the url doesn't include arcgis.com, it's ArcGIS Enterprise.) For (2), in Pro, go to Project, then Licensing. At the top it will say either "ArcGIS Pro Named User License", "ArcGIS Pro Single Use License", or "ArcGIS Pro Concurrent Use License". So far I haven't been able to repro the crash with the combinations I've tested, but I want to make sure I hit the specific combo you're working with so we can investigate further.

joshualerickson commented 1 year ago

Hey thanks @mmachir!

(1) It looks like it's the "ArcGIS Online" method. image

(2) "ArcGIS Pro Concurrent Use License"

Let me know if there's anything else I can help with, thanks.

JosiahParry commented 1 year ago

Are you able to connect to the portal directly using arc.portal_connect()?

If you do, I suggest you don't pass in your credentials directly but rather use a .Renviron file.

For example say you have this structure of your project

myproj.Rproj
.Renviron
R/do-stuff.R

In .Renviron have the following lines

PORTAL_URL=https://www.arcgis.com/
PORTAL_USER=yourlongusername
PORTAL_SECRET=yoursupersecret

Then inside of R/do-stuff.R

you would have

library(arcgisbinding)

arc.check_product()

arc.portal_connect(
  Sys.getenv("PORTAL_URL"),
  Sys.getenv("PORTAL_USER"),
  Sys.getenv("PORTAL_SECRET")
)
joshualerickson commented 1 year ago

Thanks @JosiahParry!

Yeah this is a way better way for sure 👌

We just switch over to CAC cards so I'm not sure if I still have a user and secret that isn't my card 🤷‍♂️???

This is what happens when I run arc.portal_connect()...

image

JosiahParry commented 1 year ago

CAC cards were the bane of my existence at RStudio. It appears they have it out for me. I'm guessing there may be something going on with the proxied / saml auth there.

Totally banal suggestion here. Have you logged in and out of AGOL from Pro since swapping auth mechanisms? If not, can you try doing that?

joshualerickson commented 1 year ago

Yeah when we switched over I had to sign out and got some long digit username now.

What's interesting is that all the non-portal arcgisbinding functions work when I sign into Pro on the desktop. Somehow the bridge is making that handshake?

JosiahParry commented 1 year ago

Do you know if you get this same behavior with arcpy? Will arcpy crash if pro isn't loaded?

joshualerickson commented 1 year ago

Couldn't get Rstudio to find the interpreter to arcgispro-py3. But was able to open it in VS Code and run arcpy successfully...

image

JosiahParry commented 1 year ago

@joshualerickson can you try the new release of arcgisbinding ? The below should install v1.0.1.305

install.packages("arcgisbinding", repos="https://r.esri.com", type="win.binary")
joshualerickson commented 1 year ago

Hey @JosiahParry sorry for the late response. I'm just getting setup with a new computer so I won't be able to test until I get everything setup again but will let you know once that happens. Thanks.

joshualerickson commented 1 year ago

Alright, with new version this crash is gone; however, I am on a new version of Rstudio and R as well. image image

In addition, I don't need ArcPro open at the same time to use the bindings!

Thank you 🙏

JosiahParry commented 1 year ago

Amazing. Is it safe to close @joshualerickson ?

joshualerickson commented 1 year ago

I'd say it's good to close. Thanks again.