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

problem with .get_curl #26

Closed
restonslacker opened this issue Jun 17, 2015 · 8 comments
Closed

problem with .get_curl #26

restonslacker opened this issue Jun 17, 2015 · 8 comments

Comments

@restonslacker
Copy link
Contributor

@restonslacker restonslacker commented Jun 17, 2015

when trying to use pbPost() i get the following error:
Error in if (curl == "") stop(paste("No curl binary registered. ", "Install curl, and restart R and reload package")

however, curl is installed and running Sys.which("curl") returns

> Sys.which("curl")
           curl 
"/usr/bin/curl" 

I'm running R 3.2.0 on Redhat.

@eddelbuettel
Copy link
Owner

@eddelbuettel eddelbuettel commented Jun 18, 2015

Please debug locally. There is nothing I can do for you here without a minimally reproducible example as I too have curl in /usr/bin/ and that works just fine and has since day one ...

One idea would be to compare what /bin/sh points to, or to inquire why the test in the first statement of .onAttach() fails:

curl <- Sys.which("curl")
@restonslacker
Copy link
Contributor Author

@restonslacker restonslacker commented Jun 18, 2015

Ahh! i think I've found some insight into the issue. The following block works (or should once i solve the CA cert issue):

library("RPushbullet")
pbPost("note","test","test test", email="me@mydomain.org", apikey="<my very very secret key>")

However, I was taking a shortcut:

RPushbullet::pbPost("note","test","test test", email="me@mydomain.org", apikey="<my very very secret key>")

In this case, .pkgenv has never been initialized. This explains why the test for curl<- Sys.which("curl") seemed to pass (it was never getting called) but the test in .getCurl fails (because the value for curl was never set so of course the value for .pkgenv$curl is empty).

Perhaps adding an additional check in .getcurl() either to see if the package is loaded or something like

if(curl=="" && (curl <- Sys.which("curl"))==""){
   stop("...")
}

would work?

@eddelbuettel
Copy link
Owner

@eddelbuettel eddelbuettel commented Jun 18, 2015

Fair point. I'll make that change. And/or check if the package was never attached, or change the logic to maybe call '.initialize()` in that case.

@restonslacker
Copy link
Contributor Author

@restonslacker restonslacker commented Jan 23, 2017

what about:

pbPost <- function(<snip>){
  if (! ("RPushbullet" %in% loadedNamespaces()){
    RPushbullet:::.parseResourceFile()
  }
...
}

strictly speaking, this is unnecessary if the call to pbPost() has an email= specified as the destination (after #30), but if someone tries to use recipients= it will fail without a block like this one.

@eddelbuettel
Copy link
Owner

@eddelbuettel eddelbuettel commented Jan 23, 2017

From the looks that was a dance around sourcing the config file when the package was not attached.

Do you feel strongly about removing it? Should not do too much damage.

@restonslacker
Copy link
Contributor Author

@restonslacker restonslacker commented Jan 23, 2017

I have not committed this block of code yet. Thinking about it a bit more, I'm okay if we don't use it and close this issue. As it stands now with #30, a call to RPushbullet::pbPost() will work if email= or channel= is specified, but not if recipients= is specified. This makes some sense as generally recipients= will be a number or a device name which are indexes or keys into a list. It is probably better to require the package to be loaded in that case.

@eddelbuettel
Copy link
Owner

@eddelbuettel eddelbuettel commented Jan 23, 2017

I have that issue with other packages too. Stateful data in a per-package environment requires .onAttach() which requires loading the package. It may be possible to farm the work out into a helper function called from both .onLoad() and .onAttach(). That way direct use via :: without loading should work.

But then again these are hairsplitting decisions. Let's get the bigger things right first and use the curl package. We can then see what is happening...

@eddelbuettel
Copy link
Owner

@eddelbuettel eddelbuettel commented Jan 27, 2017

I think I now now know what do to (thanks for some hints from an R Core member reviewing a paper draft having similar code).

eddelbuettel added a commit that referenced this issue Jan 28, 2017
updated initialization (closes #26)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.