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

Error in file(con, "w") : cannot open the connection #20

Closed
xfim opened this issue Mar 23, 2016 · 7 comments
Closed

Error in file(con, "w") : cannot open the connection #20

xfim opened this issue Mar 23, 2016 · 7 comments

Comments

@xfim
Copy link
Contributor

@xfim xfim commented Mar 23, 2016

Hi,

I've just tried DataExplorer and have followed the minimal example:

library(DataExplorer)
GenerateReport(iris)

It seems that the knitr part runs OK, but then it stops at the end with error:

Error in file(con, "w") : cannot open the connection
In addition: Warning message:
In file(con, "w") :  cannot open file 'report.knit.md': Permission denied

I have also tried the diamonds example with the same result.

Any hint on what may happen?

Thank you,

> sessionInfo()
R version 3.2.4 (2016-03-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Gentoo/Linux

locale:
 [1] LC_CTYPE=ca_AD.UTF8        LC_NUMERIC=C               LC_TIME=ca_AD.UTF8         LC_COLLATE=C               LC_MONETARY=ca_AD.UTF8     LC_MESSAGES=ca_AD.UTF8     LC_PAPER=ca_AD.UTF8
 [8] LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=ca_AD.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] ggplot2_2.1.0      DataExplorer_0.2.4 vimcom_1.2-6       setwidth_1.0-4     colorout_1.0-3

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.3      knitr_1.12.3     magrittr_1.5     munsell_0.4.3    colorspace_1.2-6 stringr_1.0.0    plyr_1.8.3       tools_3.2.4      grid_3.2.4       data.table_1.9.6 gtable_0.2.0     htmltools_0.3.5
[13] yaml_2.1.13      digest_0.6.9     gridExtra_2.2.1  reshape2_1.4.1   formatR_1.3      evaluate_0.8.3   rmarkdown_0.9.5  labeling_0.3     stringi_1.0-1    scales_0.4.0     chron_2.3-47
>
@boxuancui
Copy link
Owner

@boxuancui boxuancui commented Mar 23, 2016

According to your error message, I think this is the cause: In file(con, "w") : cannot open file 'report.knit.md': Permission denied.

You are probably in a directory that you do not have write permission. Please check the file/directory permission in your getwd(), e.g.,

  1. Run getwd() in R.
  2. In your Linux shell, type cd $YOUR_GETWD_DIRECTORY && ls -l.
  3. Make sure you have at least -rw-r--r--, or chmod -r 644 $YOUR_GETWD_DIRECTORY.

Alternatively, as suggested in this SO post, you may set the working directory in your R session and do it from somewhere you have write permission.

@boxuancui
Copy link
Owner

@boxuancui boxuancui commented Mar 23, 2016

In addition, I see you are running DataExplorer_0.2.4. I fixed a number of bugs in the new version, so it is advised to use the latest version on master branch.

library(devtools)
install_github("boxuancui/DataExplorer")
@xfim
Copy link
Contributor Author

@xfim xfim commented Mar 24, 2016

Thank you for your suggestions, @boxuancui . But I don't think that a pure permission issue is going on here. I'm in fact in my home directory ($HOME), where I have write permissions. In addition, the knitr part works until the end, which means that a directory "report_files" is created (which if it was a permission issue would not work).
Then, if I run it with su permissions it works.
Using the development version doesn't solve it neither.

@boxuancui
Copy link
Owner

@boxuancui boxuancui commented Mar 24, 2016

So is there a report.html file generated in your home directory? If so, when you manually open it, does it render in your browser?

@xfim
Copy link
Contributor Author

@xfim xfim commented Mar 25, 2016

When running with su permission, it does appear the report. But when being a regular user, it does not. But let me stress it out again that when being regular user the "report_files" directory is created. So probably it has to do whith the temporal place where the md file is stored or knitted.

@xfim
Copy link
Contributor Author

@xfim xfim commented Mar 30, 2016

Hi again,

Another weird signal: The development version works if I clone the git repository and run load_all("DataExplorer") from the local machine, but it does not work when installing it via library(devtools); install_github("boxuancui/DataExplorer", force = TRUE).

So I am sure quite certain that we can discard anything related to permissions.

@xfim
Copy link
Contributor Author

@xfim xfim commented Mar 30, 2016

OK, I think I have found the error. I've used inotify to check which files are touched in the filesystem when GenerateReport() run. And it turns out that when looking at the package installation directory it does the following:

./rmd_template/report.knit.md CREATE
./rmd_template/report.utf8.md CREATE
./rmd_template/report.knit.md DELETE
./rmd_template/report.utf8.md DELETE

The problem is when the R packages are not in a library writable by the user, which is not uncommon. Then GenerateReport() creates and deletes two files.

I think that the more reasonable solution is to generate the files in the working directory.

@xfim xfim closed this Mar 30, 2016
@boxuancui boxuancui added this to the 0.2.6 milestone Mar 30, 2016
boxuancui added a commit that referenced this issue Mar 30, 2016
Adds intermediates_dir argument to render() for #20
boxuancui added a commit that referenced this issue Mar 30, 2016
@boxuancui boxuancui modified the milestone: 0.2.6 May 7, 2016
shenyang1981 pushed a commit to shenyang1981/scRNABatchQC that referenced this issue Jan 6, 2020
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.