You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
If a file (or its containing directory) is symlinked, then it can be opened in two RStudio tabs #12616
Click each of these in turn--two tabs open in RStudio
Alternatively:
mkdir A
mkdir B
cd A
mkdir C
cd ../B
ln -s ../A/C
Dans-P4-MacBook-Pro:B dgealow$ cd C
Dans-P4-MacBook-Pro:C dgealow$ echo hello > file.txt
Then, in the RStudio file browser, open both A/C/file.txt and B/C/file.txt,
Describe the problem in detail
RStudio usually will not allow opening a single file in two tabs. Symlinks (of either a file itself or a directory that contains it) bypass this restriction, allowing a state in which the same file is open twice. This state is prone to errors, since unsaved edits to one tab will not appear in the other tab. If edits are made in both tabs they will overwrite each other. In a small toy example, it's easy to see what's going on, but for a large script in a big project it's easy not to realize what's happening until you've already overwritten your own work.
Describe the behavior you expected
Prevent re-opening of a file that is already open via an equivalent symlinked path. (Or allow for simultaneous synchronized editing in multiple tabs a la VSCode, but that's obviously a much bigger request.)
@dvg-p4 Thank you for raising this! I can readily reproduce this in RStudio Desktop 2022.07.2+576 and RStudio Server 2022.12.0+353. I'll mark it for review as part of our ongoing development of RStudio.
IMHO, we should allow this, and instead improve the way we detect whether a file has changed on disk (for the case where a single file has been opened from different potential links)
See #14297 for another example of problems due to path normalizatiion issues. In that case, related to long vs. short filenames on Windows. Often triggered when a path is under the user's profile and their account name has non-ascii characters.
If both the file and the symlink live within the current project, then the project file monitor is able to detect changes on the filesystem and update the tab's contents when either one of the files is changed.
If you're currently editing a symlink, then the edits to the original file won't appear until the tab hosting the original file is opened.
Some potential ways forward:
If we detect that a file is a symlink, use a file monitor to detect changes on the resolved path for the file, so that we can detect and respond to changes.
Prompt the user when opening a symlink for editing, and ask whether they want to edit using the symlink file path, or the resolved file path.
Resolve symlinks by default when opening them for editing. (Perhaps with this behavior behind a user preference if necessary.)
In case it proves helpful in some way, Electron's ShowOpenDialog[Sync] API has this option on macOS:
noResolveAliases macOS - Disable the automatic alias (symlink) path resolution. Selected aliases will now return the alias path instead of their target path.
Activity
ronblum commentedon Jan 24, 2023
@dvg-p4 Thank you for raising this! I can readily reproduce this in RStudio Desktop 2022.07.2+576 and RStudio Server 2022.12.0+353. I'll mark it for review as part of our ongoing development of RStudio.
CGMossa commentedon Feb 13, 2023
This is also happening when using the

browser()tag; See thisCGMossa commentedon Feb 13, 2023
I see now that this might be unrelated, or it not. See issue #12702 for how this is happening.
github-actions commentedon Aug 13, 2023
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs, per https://github.com/rstudio/rstudio/wiki/Issue-Grooming. Thank you for your contributions.
github-actions commentedon Aug 27, 2023
This issue has been automatically closed due to inactivity.
dvg-p4 commentedon Aug 28, 2023
Should this be re-opened?
CGMossa commentedon Aug 28, 2023
Possibly.
kevinushey commentedon Aug 28, 2023
IMHO, we should allow this, and instead improve the way we detect whether a file has changed on disk (for the case where a single file has been opened from different potential links)
3 remaining items
dvg-p4 commentedon Mar 27, 2024
IIRC this can also happen with
~/filevs/home/[me]/file, particularly when clicking on a line in testthat outputgtritchie commentedon May 1, 2024
See #14297 for another example of problems due to path normalizatiion issues. In that case, related to long vs. short filenames on Windows. Often triggered when a path is under the user's profile and their account name has non-ascii characters.
kevinushey commentedon May 28, 2024
Some other observations:
Some potential ways forward:
gtritchie commentedon Jun 3, 2024
In case it proves helpful in some way, Electron's ShowOpenDialog[Sync] API has this option on macOS:
noResolveAliasesmacOS - Disable the automatic alias (symlink) path resolution. Selected aliases will now return the alias path instead of their target path.gtritchie commentedon Oct 29, 2024
Too late in this release to mess with this, so once again bumping it to the next.