rstudio / rstudio/rstudio

"weird" issue-- XQuartz running when a .R file containing {weird} code is opened in RStudio

Open
#18,402 0 comments 0 reactions 0 assignees View on GitHub
bug macos
Dominant language
Java
Stars
5.1k
Forks
1.2k
PR merge metrics
PR metrics pending

Description

I'm not sure where to put this, or even if it's really an issue. But I've been having an unexpected behavior on my Mac in the past few days and I think I've traced it back to the `weird` package and RStudio's code diagnostics engine. (Major caveat here: I used Claude to help me debug this, so it could be a hallucination! But the behavior seems consistent with the idea.) Initially, I started writing this on @robjhyndman's https://github.com/robjhyndman/weird/ package, but the more I think about it I think it's a bug/unexpected behavior from RStudio.

I have a `.R` file with some code I've been tinkering on. I don't have Source on save checked at the top. In that `.R` file is some code that uses `weird`. I'm not actually calling `library(weird)`, just using the `::` to get a function or two I need. For example,

```
weird::hampel_anomalies(LakeHuron, bandwidth = 2)
```

As a minimal reproducible example, put just this line in a .R file. As soon as this file is opened in RStudio, XQuartz pops open on my computer. If I quit XQuartz while I am in a Project, my R session will be aborted. (This doesn't happen if I don't have an active Project open.)

### System details

RStudio Edition : Desktop
RStudio Version : 2026.07.1+147 (2026.07.1+147)
OS Version : Mac OS Sequoia 15.6
R Version : 4.4.1

### Steps to reproduce the problem

Create a .R file that contains the line

```
weird::hampel_anomalies(LakeHuron, bandwidth = 2)
```

(or, any other code that calls something from `weird`). Save it. (Or don't, I think it happens just by writing the code and not executing it.)

Open this file.

### Describe the problem in detail

When you open the file, XQuartz pops open. If you have an active RStudio Project and then quit XQuartz, the R session experiences a fatal error and terminates. If you don't have an active RStudio Project, XQuartz still opens when you open the file, but when you quit XQuartz the fatal error doesn't happen. If I open the file in the standard R GUI, XQuartz does not open.

Here's what Claude had to say about it:

"RStudio parses R scripts in the background for diagnostics/autocomplete (checking function calls, arguments, etc.). When it sees a library(weird) call in your script — even completely unexecuted — its diagnostics engine will silently call getNamespace("weird") to resolve what functions are available, so it can check your code against them. That single call cascades: weird imports from aplpack, which imports tcltk, and loading tcltk's namespace on your system launches XQuartz — all without a single line of your script actually running."

### Describe the behavior you expected

I would expect XQuartz not to open, or at least not to open until I had run some code that might trigger it.

- [x] I have read the guide for [submitting good bug reports](https://github.com/rstudio/rstudio/wiki/Writing-Good-Bug-Reports).
- [x] I have installed the latest version of RStudio, and confirmed that the issue still persists.
- [x] If I am reporting an RStudio crash, I have included a [diagnostics report](https://support.posit.co/hc/en-us/articles/200321257-Running-a-Diagnostics-Report).

[diagnostics-report.txt](https://github.com/user-attachments/files/30553787/diagnostics-report.txt) Not sure if this is actually relevant here, because it's just the R session that aborts.

- [x] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

Contributor guide

Open the contributing guide

Research direction

Start with the minimal .R file containing weird::hampel_anomalies(LakeHuron, bandwidth = 2), then compare opening it in RStudio with opening it in the standard R GUI. Trace RStudio's background diagnostics or autocomplete handling of the weird namespace and compare the project and non-project cases. Done means opening the file does not launch XQuartz, and quitting XQuartz does not abort the project R session.

Written by the indexing model from the issue text.

Assessment

Tech stack
macos, r
Domain
desktop, developer-experience
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.