I am trying to play around with Shiny and simply attempted to run the basic out-of-the-box example. No dice.
I attempted to Google the Issue but everything appears to address issues when running it on an external server.
Maybe I am mistaken, but I assumed that this app would run in my browser using localhost.
Here is what I did:
install.packages("shiny")
library(shiny)
runExample("01_hello")
Here is the error:
> runExample("01_hello")
Listening on port 8100
Error in startServer("0.0.0.0", port, httpuvCallbacks) :
Failed to create server
and for completeness sake, here is my session Info:
> sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-apple-darwin10.8.0 (64-bit)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] shiny_0.7.0
loaded via a namespace (and not attached):
[1] bitops_1.0-5 caTools_1.14 digest_0.6.3 httpuv_1.1.0 RJSONIO_1.0-3 tools_3.0.1 xtable_1.7-1
This error could be because of blocked port.
I was running shiny server on port 3259. I killed the server for some reason and when i was trying to start it again i saw this error.
Error in startServer("0.0.0.0", port, httpuvCallbacks) :
Failed to create server
Calls: runApp -> startAppDir -> startApp -> startServer
To resolve you can first find the process which is blocking your port
First use netstat to view the process blocing your port
netstat -anp|grep :3259[[:blank:]]
and then kill that process
#Hadley's last comment to re-install shiny and httpuv did the trick.
devtools::install_github(c("shiny", "httpuv"), "rstudio")
Actually with re-install you just stopped httpuv server in a difficult way.
what you need to do is only stopServer the current running Server. What happens here is httpuv server is started but it did not stopped for some reason. now that you try to re-run your shiny app you cannot start it again, because it is already started and then you get the mentioned error.
to start your program in this case you can just run service in a loop, you don't need to start server again:
while (TRUE) {
.Call("httpuv_run", PACKAGE = "httpuv", 250)
Sys.sleep(0.001)
}
Though you also can stop previous server and start it again using:
stopServer(server)
however in this case you need to know where server variable is stored.
Related
I have developed a package that I want to share with my colleagues at work.
I have a network drive in which I created the local repository structure that looks like this:
MyRepo
\__bin
\__windows
\__contrib
\__src
\__contrib
All folders are empty.
So I built my package with RStudio on Windows using the "Build/More/Build source package" menu, which created a tar.gz file.
Then I tried:
drat::insertPackage("../myPkg_0.0.0.9000.tar.gz",
repodir = "file://networkdrive/path/to/MyRepo",
action = "prune")
But this gives me an error:
Error: Directory file://networkdrive/path/to/MyRepo not found
Which is strange because file.exists(//networkdrive/path/to/MyRepo) returns true.
OK, then I tried:
drat::insertPackage("../myPkg_0.0.0.9000.tar.gz",
repodir = "//networkdrive/path/to/MyRepo",
action = "prune")
Without the file: in the repository path and I get another error:
tar (child): "//networkdrive/path/to/MyRepo/src/contrib/myPkg_0.0.0.9000.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
/usr/bin/tar: Child returned status 2
/usr/bin/tar: myPkg/DESCRIPTION: Not found in archive
/usr/bin/tar: Exiting with failure status due to previous errors
reading DESCRIPTION for package ‘myPkg’ failed with message:
cannot open the connection
But when I go in the "//networkdrive/path/to/MyRepo/src/contrib" folder, I can definitely see the myPkg_0.0.0.9000.tar.gz file that has been copied despite the error message.
Can anyone help?
> sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=French_France.1252 LC_CTYPE=French_France.1252 LC_MONETARY=French_France.1252 LC_NUMERIC=C LC_TIME=French_France.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] drat_0.1.2 tools_3.3.3 git2r_0.18.0
I know this is old, but my colleague just came across the same problem and found this post. I believe the issue may be the lack of a trailing slash in your directory name. I have been able to recreate the error with a mapped network drive. I can resolve the issue by using "H:/MyRepo/" instead of "H:/MyRepo".
I haven't tried it with the "file://" format, but I wanted to include my answer in case someone else comes across this question.
Ok, so after some research, here is my conclusions.
It cannot be done
It's not Drat's fault
The reason why it does not work is that the tools::write_PACKAGES function does not work on network drives. Period.
I manually copied my package on the network drive, then ran setwd() to its location and executed write_PACKAGES(".", type="source") and I got the same error.
So to make this work, I just left my package.tar.gz file on a local drive, ran the tools::write_PACKAGES command locally and then moved the files to the network drive.
Adding the network drive to my repository list using options(repos = c(MyRepo = "file://networkdrive/path/to/MyRepo/")) works: RStudio and available.packages find my package.
It's not completely satisfactory, but I think it's the only way today.
I was having this problem as well and finally got to the bottom of it today.
For me, the problem was not isolated to just network locations but also occurred on C: drive. The root cause was the version of tar.exe being used to unpack the existing packages in the package directory. Calls to utils::untar are made in the tools::write_PACKAGES function.
The documentation for utils::untar explains that on Windows, external tar.exe is tried first. Sure enough, I had a version installed with Git which when used with default arguments fails when a colon is in the file name. I was able to force utils::untar to use to use the RBuildTools version of tar.exe instead by setting the environment variable TAR to "internal".
drat::insertPackage now works.
When I run a Shiny App either an example or my own it starts a new window, freezes and then aborts. It tries to listening to a local port then starts a new session.
Details of my system:
My R version: 3.1.3 on MacOS Maverick
other attached packages:
[1] shiny_0.12.0 Rcpp_0.11.6
loaded via a namespace (and not attached):
[1] digest_0.6.8 htmltools_0.2.6 httpuv_1.3.2 mime_0.3 R6_2.0.1
[6] tools_3.1.3 xtable_1.7-4
What I tried so far:
From different internet forums I found a lot of suggestions:
I reinstalled Rstudio.
I updated all the packages
Tried this: install.packages(c("Rcpp", "httpuv", "shiny"))
Loaded Rcpp and httpuv separately
tried to run like this runApp('app1',host="127.0.0.1",port = 3894)
// tried other ports as well.
But nothing works.
(Please note that, I don't know whether it's relevant but GoogleVis Demo worked on my RStudio.)
#roboticman
My recommendation is first to test and confirm R is correctly setup on your machine. We can then move to harness a Shiny demonstration application and confirm if that works.
https://technophobe01.shinyapps.io/WorldBank/
First step:
Can you please run the following command via R, this should download and install shiny and its dependencies...
> install.packages("shiny", dependencies = TRUE)
If things work after this, great. If not, well, then let's check your R configuration:
Validate R Install
To check your configuration, my recommendation is you launch R on your machine and run the following tests and post back the output.
> R
> sessionInfo()
Sys.setenv(LC_COLLATE = "C", LC_TIME = "C", LANGUAGE = "en")
library("tools")
testInstalledBasic("both")
testInstalledPackages(scope = "base")
testInstalledPackages(scope = "recommended")
testInstalledBasic("internet")
Once you post the output of the above command set, we can move to work through the example 'World Bank', and see if we can determine the problem.
Take care
Try this:
library(shiny)
runExample("01_hello", host = "0.0.0.0", port = 9999).
runApp will also work:
shiny::runApp(host = "127.0.0.1", port = 9999)
I am trying to read an Excel file that is stored on a corporate intranet SharePoint site, and am doing so using the 'gdata' package from within R Studio run on a Linux server using Shiny Server.
I had good results reading the file from within a MS Windows environment using gdata, but cannot seem to get things to work when running the script on the Linux server. This was based on the info from:
http://r.789695.n4.nabble.com/trying-to-import-xls-or-xlsx-files-td3620580.html
I did modify the R script for the path to Perl on the Linux server (vs. the path to perl.exe on Windows), and this seems to work ok.
The file url is
"http://sharepoint2/ops/quality/metricspc/Metric OptIn List/temporary SPC Metric Opt-In List.xlsm"
Here is the R code:
# R read MS Excel xlsm file from SharePoint
# method using gdata - seems to work with SharePoint
# NOTE: requires 'perl' installed
#
# example from
# http://r.789695.n4.nabble.com/trying-to-import-xls-or-xlsx-files-td3620580.html
library(gdata)
fileurl =
# see fileurl above this code section - did this due to SO error message about not having 'sharepoint2' in the url
d.optin.init2 <- read.xls(fileurl,
sheet = "OPT-IN LIST",
perl = "/usr/bin/perl")
##### END CODE #####
The original (Windows-based) script used perl = "C:\\Perl64\\bin\\perl.exe"
Here is the error message that results (when run from Linux using R Studio on Shiny Server):
d.optin.init2 <- read.xls(fileurl,
+ sheet = "OPT-IN LIST",
+ perl = "/usr/bin/perl")
trying URL 'http://sharepoint2/ops/quality/metricspc/Metric OptIn List/temporary SPC Metric Opt-In List.xlsm'
Error in download.file(xls, tf, mode = "wb") :
cannot open URL 'http://sharepoint2/ops/quality/metricspc/Metric OptIn List/temporary SPC Metric Opt-In List.xlsm'
In addition: Warning message:
In download.file(xls, tf, mode = "wb") :
cannot open: HTTP status was '400 Bad Request'
Error in file.exists(tfn) : invalid 'file' argument
The path to the file (on SharePoint) is a URL (shown in the code), so I thought that the route between the Linux server and MS SharePoint might be straightforward. But since this does work for me with Windows but does not yet work for me with Linux, I wonder what I may have missed?
Thank you in advance for any insight that might be offered.
(I haven't attached the Excel file because I wasn't sure that it would help with this question.)
Best regards,
Cliff
Output from sessionInfo
sessionInfo()
R version 3.1.0 (2014-04-10)
Platform: x86_64-redhat-linux-gnu (64-bit)
locale:
1 C
attached base packages:
1 stats graphics grDevices utils datasets methods base
other attached packages:
1 gdata_2.13.3 qcc_2.5
loaded via a namespace (and not attached):
1 MASS_7.3-31 gtools_3.4.1 tools_3.1.0
Acting on the suggestions provided by hrbrmstr and also Greg, I tried both wget and also curl from the Linux command line.
wget results
curl results
I can work with our IT folks to resolve. If anyone can help me to refine the questions I might ask of them based on these results, I would welcome this input.
Thanks again to those who took the time to respond.
MORE FOLLOW-UP
#Gregory R. Warnes
I was able to use wget with this command line from the Linux server:
wget --http-user=myusername --http-passwd=mypassword (place fileurl here)
This seemed to access the file, bridging the divide between Linux server and Windows SharePoint.
Now to figure out how to include this AD authentication in the gdata R script.
The error message indicates that R's download.file() code was not able to access the URL.
To debug the issue, try accessing that URL from the Linux server from the shell command line, for example:
If wget is installed:
> wget http://sharepoint2/ops/quality/metricspc/Metric OptIn List/temporary SPC Metric Opt-In List.xlsm
or if curl is installed:
> curl http://sharepoint2/ops/quality/metricspc/Metric OptIn List/temporary SPC Metric Opt-In List.xlsm
If wget and/or curl generates an error, then you have a server configuration issue.
If wget and/or curl succeed then the problem may be with R's download.file().
-Greg
I'm running R through the Terminal in a Mac OSX Snow Leopard system.
I get this error message when trying to use View():
Error in .External2(C_dataviewer, x, title) : invalid device In
addition: Warning messages: 1: In View(a) : locale not supported by
Xlib: some X ops will operate in C locale 2: In View(a) : X cannot set
locale modifiers 3: In View(a) : unable to create fontset
--fixed-medium-r----120------
And this error message when trying to use edit():
Error in .External2(C_dataentry, datalist, modes) : invalid device In
addition: Warning messages: 1: In edit.data.frame(a) : locale not
supported by Xlib: some X ops will operate in C locale 2: In
edit.data.frame(a) : X cannot set locale modifiers 3: In
edit.data.frame(a) : unable to create fontset
--fixed-medium-r----120------
I can't find information about this particular problem. What can I do to fix this?
sessionInfo() returns:
R version 3.0.1 (2013-05-16)
Platform: x86_64-apple-darwin10.8.0 (64-bit)
locale:
[1] C/UTF-8/C/C/C/C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
The problem might be your locale settings. Run command 'locale' from terminal and see if there are any lines with something else but 'C' locale. For example, in my case output is like this:
macbook:foo user$ locale
LANG=
LC_COLLATE="C"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=
Easiest way to solve this is to set the locale to be C for just the R process ie. run R from terminal session with command 'LC_CTYPE=C R' instead of just 'R'. At least on OS/X 10.6.8 this gets rid of the error messages and allows R to display the edit window.
The cause for my problem: View(dataset) in the rchunk where we load up data.
I had it here because I loaded in data like data <-read_excel("name")
And had View there because I copied and pasted it from my console, but it's not needed.
Experienced this with RStudio Server. I just had to restart R (Ctrl/Cmd + Shift + F10) to get rid of the error.
It was possibly caused by updating some packages.
if you download the xquart, I think you need to restart your Mac to activate its work.
I had the same problem just a few minutes ago and I restart my Mac, now it works.
I had the same error in RStudio. I'm not certain if this would be the same for using R via the Terminal, but for RStudio users who get this message using the jagsUI package masks the View function which triggers this warning. See this question
Easiest workaround seems to be to call detach("package:jagsUI", unload = TRUE) once you have finished using JAGS.
Check potential conflicts between functions by calling conflicts(detail=TRUE) (Taken from this answer for finding which functions are masked in R).
I solved the problem by moving R installation directory out of disk C. Thanks Joris for the great suggestions! I think the R core team should also take this as a bug and do something against the protecting mechanism of windows xp.
Dear Community:
While using the BIOMOD packages in R, I always get the following problem:
Error in xzfile(file, "wb", compression = 9) : cannot open the connection
In addition: Warning message:
In xzfile(file, "wb", compression = 9) :
cannot initialize lzma encoder, error 5
It was said by the author of the package and also in the help file of "save" that the problem should be caused by lack of permission to write. However, as I am logging in as administative account and have assess to all operations, I have no idea what the problem is. Can anybody help me out? I really need to run the package now. Thanks in advance~
Sincerely,
Marco
Below is the illustration in the help file of "save":
The most common reason for failure is lack of write permission in
the current directory. For 'save.image' and for saving at the end
of a session this will shown by messages like
Error in gzfile(file, "wb") : unable to open connection
In addition: Warning message:
In gzfile(file, "wb") :
cannot open compressed file '.RDataTmp',
probable reason 'Permission denied'
The defaults were changed to use compressed saves for 'save' in
2.3.0 and for 'save.image' in 2.4.0. Any recent version of R can
read compressed save files, and a compressed file can be
uncompressed (by 'gzip -d') for use with very old versions of R.*
Sorry for the ommision of the information:
Here is the sessionInfo():
> sessionInfo()
R version 2.12.2 (2011-02-25)
Platform: i386-pc-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=Chinese_People's Republic of China.936
[2] LC_CTYPE=Chinese_People's Republic of China.936
[3] LC_MONETARY=Chinese_People's Republic of China.936
[4] LC_NUMERIC=C
[5] LC_TIME=Chinese_People's Republic of China.936
attached base packages:
[1] splines stats graphics grDevices utils datasets methods
[8] base
other attached packages:
[1] BIOMOD_1.1-6.8 foreign_0.8-42 gam_1.04
[4] randomForest_4.6-2 mda_0.4-1 class_7.3-3
[7] gbm_1.6-3.1 lattice_0.19-17 MASS_7.3-11
[10] Design_2.3-0 Hmisc_3.8-3 survival_2.36-5
[13] rpart_3.1-48 nnet_7.3-1 ade4_1.4-16
[16] rgdal_0.6-33 dismo_0.5-19 rJava_0.9-0
[19] raster_1.7-47 sp_0.9-78
loaded via a namespace (and not attached):
[1] cluster_1.13.3 grid_2.12.2 tools_2.12.2
Now I found that the problem come form the lzma encoder in doing "save":
> x<-runif(100)
> save(x, file = "F:/test.gzip", compress='gzip')
> save(x, file = "F:/test.xz", compress='xz')
Error in xzfile(file, "wb", compression = 9) : cannot open the connection
>
I had a similar issue when trying to project to a new scenario (a tables containing columns corresponding to the predictor variables) after having run the modeling procedure using 8 models.
The first table (approx 250,000 rows) ran fine, and I was able to save the results as a .csv file. However the second one (approx 380,000 rows) resulted in the above error message, and some of the files were not written to the project folder.
I have since cut all the tables down to a maximum of 260,000 rows and I no longer recieve the error message. It was a bit of a pain doing it in multiple runs, but once I had written the script once, I just used find and replace in MS Word to change it for each run.