rstudio / packrat

Packrat is a dependency management system for R
http://rstudio.github.io/packrat/
402 stars 90 forks source link

XQuartz launching when packrat init #308

Open AmeliaMN opened 8 years ago

AmeliaMN commented 8 years ago

@jmcphers said the lock file might make it easier to reproduce this issue, so here it is:

PackratFormat: 1.4
PackratVersion: 0.4.7.1
RVersion: 3.3.0
Repos: CRAN=https://cran.rstudio.com/

Package: BH
Source: CRAN
Version: 1.60.0-2
Hash: be2967bcff307e561d9ba17faf03205c

Package: DBI
Source: CRAN
Version: 0.4-1
Hash: 6524d5c5d30ff74084ac028eeb19eb1b

Package: R6
Source: CRAN
Version: 2.1.2
Hash: c515e41c73294952cbb33ee1c1be5a2d

Package: Rcpp
Source: CRAN
Version: 0.12.5
Hash: 625a95cb4ef523a77ad02e140b715db6

Package: assertthat
Source: CRAN
Version: 0.1
Hash: 0afb92b59b02593c70ff8046700ba9d3

Package: base64enc
Source: CRAN
Version: 0.1-3
Hash: c590d29e555926af053055e23ee79efb

Package: bitops
Source: CRAN
Version: 1.0-6
Hash: 67d0775189fd0041d95abca618c5c07e

Package: caTools
Source: CRAN
Version: 1.17.1
Hash: 97cb6f6293cd18d17df77a6383cc6763
Requires: bitops

Package: digest
Source: CRAN
Version: 0.6.9
Hash: fd55d5a024f160fc001a5ece1e27782d

Package: dplyr
Source: github
Version: 0.4.3.9001
Hash: 4cccd1168d2bfb961cc8398dacee6eb7
Requires: BH, DBI, R6, Rcpp, assertthat, lazyeval, magrittr, tibble
GithubRepo: dplyr
GithubUsername: hadley
GithubRef: master
GithubSha1: b21fc8fa513d8488373f06e0097d18353b7e5e58

Package: evaluate
Source: CRAN
Version: 0.8
Hash: aac00bd789bac10970b50e3b7e0cab04
Requires: stringr

Package: formatR
Source: CRAN
Version: 1.2.1
Hash: 54c730c712edd6087972ecf99bf87c55

Package: highr
Source: CRAN
Version: 0.5.1
Hash: 114ef5abcf58bebbf6ac083b9cacbbd8

Package: htmltools
Source: CRAN
Version: 0.3
Hash: 7ccc01f4d22d73d0d9b0d2a7781e7ff6
Requires: Rcpp, digest

Package: jsonlite
Source: CRAN
Version: 0.9.21
Hash: 4715435f79ce983ec7e041f6be4742f4

Package: knitr
Source: CRAN
Version: 1.13
Hash: 8d686cbee88c93b735281a22b2ca59dd
Requires: digest, formatR, highr, yaml, markdown, stringr, evaluate

Package: lazyeval
Source: CRAN
Version: 0.2.0
Hash: 3d6e7608e65bbf5cb170dab1e3c9ed8b

Package: magrittr
Source: CRAN
Version: 1.5
Hash: bdc4d48c3135e8f3b399536ddf160df4

Package: markdown
Source: CRAN
Version: 0.7.7
Hash: fea2343a1119d61b0cc5c0a950d103a3
Requires: mime

Package: mime
Source: CRAN
Version: 0.4
Hash: b08c52dae92a0a11e64a4deea032ec33

Package: packrat
Source: CRAN
Version: 0.4.7-1
Hash: 16ca16d36eb18d1d16113606ecc5c400

Package: readxl
Source: CRAN
Version: 0.1.1
Hash: 92417d60a200a0f92fc8c4697105c3ff
Requires: Rcpp

Package: rmarkdown
Source: github
Version: 0.9.6.8
Hash: 0ef962f5004b2397ba9ec948ce42065b
Requires: base64enc, jsonlite, yaml, caTools, htmltools, evaluate, knitr
GithubRepo: rmarkdown
GithubUsername: rstudio
GithubRef: master
GithubSha1: a39fd8014269820f1e0e0a57d7e3805c8af27d01

Package: stringi
Source: CRAN
Version: 1.0-1
Hash: cf342bc407bd5daec77ed1009d5244e1

Package: stringr
Source: CRAN
Version: 1.0.0
Hash: 2676dd5f88890910962b733b0f9540e1
Requires: magrittr, stringi

Package: tibble
Source: CRAN
Version: 1.0
Hash: 135bebe37e899e9ebabcfdf74cb86ade
Requires: Rcpp, assertthat, lazyeval

Package: yaml
Source: CRAN
Version: 2.1.13
Hash: 4854ccabebc225e8a7309fb4a74980de
kevinushey commented 8 years ago

I tried initializing a packrat project using this lockfile, and then opening the project in RStudio, but did not see an X11 window opened. Can you provide more information?

jmcphers commented 8 years ago

@AmeliaMN was seeing XQuartz open up for no good reason while running RStudio; we eventually realized it was a side effect of packrat init and were able to get it to repro outside RStudio just by running packrat::init on the project directory in RGui.

I'd initially thought it was due to one of the packages above (and it probably is) but just doing a library() on each, one-by-one, didn't cause the X11 window to open. Something else happening on init is triggering it.

This used to be a problem with an old version of colorspace, so I suspect a similar mechanism is responsible here:

https://stackoverflow.com/questions/28952128/loading-ggplot2-colorspace-actually-opens-up-x11

kevinushey commented 8 years ago

One potential culprit -- for autocompletion results, RStudio will launch an R process in the background and load packages discovered in the current project + open R scripts (with a library() call). It's possible that one of those launched R processes was loading a package (perhaps colorspace) and causing an X11 window to open when that package was loaded.

AmeliaMN commented 8 years ago

Hmm, I don't know how to troubleshoot this further. Let me know any information that would be helpful, and/or I can bring my laptop past the booth at JSM.

pgensler commented 8 years ago

I just tried to add packrat (.4.7-1 on CRAN) to my new project in rstudio, and right when I restarted my r session, XQuartz pops up. Below is what my output is, and my sessioninfo: Let me know if there is any way I can help with this issue. I am using RStudio 0.99.1294

Update: I tried using the dev version of packrat 0.4.7-23, and it still seems like the issue may have been fixed. I'll keep you updated on anything I run into

 packrat::init()
Initializing packrat project in directory:
- "~/Desktop/Global Superstore Analysis"

Adding these packages to packrat:
            _        
    packrat   0.4.7-1

Fetching sources for packrat (0.4.7-1) ... OK (CRAN current)
Snapshot written to '/Users/petergensler/Desktop/Global Superstore Analysis/packrat/packrat.lock'
Installing packrat (0.4.7-1) ... 
    OK (downloaded binary)
Initialization complete!

Restarting R session...

> sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.6 (El Capitan)

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] packrat_0.4.7-1 dplyr_0.5.0    

loaded via a namespace (and not attached):
[1] magrittr_1.5   R6_2.1.3       assertthat_0.1 DBI_0.5        tools_3.3.1    tibble_1.2    
[7] Rcpp_0.12.6   
kevinushey commented 8 years ago

Interesting, thanks. One other data point -- do you see this only within RStudio, or do you see it within a plain R session as well?

pgensler commented 8 years ago

I have not tried it in R yet. I will let you know if anything odd happens.

pgensler commented 8 years ago

Tried installing the dev version of packrat as well as the CRAN version in R 3.3.1, and XQuartz was fine, so I'm guessing it has something to do with RStudio(maybe something with notebooks..?)? I'm not really sure what dependencies have the XQuartz/X11 stuff in RStudio, so I really don't know where to start debugging an issue like this. Let me know if there is any other way I can help.

kevinushey commented 8 years ago

One possibility would be to try debugging the functions that are commonly used to open an X11 window, e.g.

debug(x11)
debug(X11)
debug(dev.new)

and then trying to run the packrat code that causes an X11 device to be opened; this might pause the R session in the code that's opening a graphics device, and then we could see who the ultimate culprit is re: opening an X11 graphics device.

AmeliaMN commented 8 years ago

I tried

debug(x11)
debug(X11)
debug(dev.new)

and wasn't able to catch anything. However, updating to the dev version of packrat seems to have fixed the issue for me.

kevinushey commented 8 years ago

Great to hear! It's unfortunate we still don't know the underlying cause, but I'll take that as a win anyhow...

sophiebeiers commented 6 years ago

I, too, am having this issue. XQuartz only started opening whenever I open RStudio about a month ago and I don't believe I'm using any new or strange packages. I downloaded the dev version of packrat but that didn't make a difference for me. Are there any updates or other fixes that have worked for anyone? Thank you!

ankane commented 6 years ago

fwiw, also seeing this with packrat::init() in an empty directory from the R console with a fresh install of R on Mac.

Warning message:
In doTryCatch(return(expr), name, parentenv, handler) :
  unable to load shared object '/Library/Frameworks/R.framework/Resources/modules//R_X11.so':
  dlopen(/Library/Frameworks/R.framework/Resources/modules//R_X11.so, 6): Library not loaded: /opt/X11/lib/libSM.6.dylib
  Referenced from: /Library/Frameworks/R.framework/Resources/modules//R_X11.so
  Reason: image not found

Packrat: 0.5.0 R: 3.5.1 Mac: Mojave

kevinushey commented 6 years ago

You likely need to reinstall XQuartz: https://www.xquartz.org/

ankane commented 6 years ago

Yeah, that fixed the warning, but thought it was odd that packrat::init() tried to use X11/XQuartz.

kevinushey commented 6 years ago

My best guess is that Packrat loaded the namespace of a package which uses X11 during init.

ankane commented 6 years ago

Hmm, happens when I run the init in an empty directory, so maybe one of the libraries Packrat depends on, like tools or utils 🤷‍♂️

yihui commented 4 years ago

I have also experienced this for a long time (perhaps one or two years) in one of my projects, and finally bothered to google for this mystery. I still don't know what the cause was, but I deleted the .Rproj.user directory in the project, and XQuartz no longer automatically launches when I open that RStudio project. I think this issue is irrelevant to packrat, because I didn't use it in that project. A certain R package might have triggered XQuartz, and RStudio remembered it somehow.

kevinushey commented 4 years ago

FWIW I recall rgl being one of the culprits in terms of "packages that automatically open an XQuartz window when loaded".

ffancheng commented 3 years ago

I recently had this issue and fixed it by deleting the R project related files, *.Rproj and .Rproj.user. I had a script using the rgl package, which is the only thing related to XQuartz I know.