Skip to content

Conversation

@AmanKashyap0807
Copy link

Closes #1292

Fix fread clipboard handling on Windows using readClipboard(), add test (#2366), and update NEWS.

Changed files :

  • R/fread.R : Added logic to detect clipboard inputs on Windows, reading it by using readClipboard(), handle errors and process clipboard content as a temporary file for parsing.
  • inst/tests/tests.Rraw : Added test 2366 for clipboard functionality.
  • Updated NEWS.md with a brief entry under BUG FIXES.

To keep the scope of issue #1292, I only solved it for Windows. I'd be happy to submit another PR for macOS and Linux later.

Reproduction:

# Write tab delimited data to clipboard
writeLines("a\tb\n1\t4\n2\t5\n3\t6\n", "clipboard")

# read.delim works
read.delim("clipboard-128")
# [1] read.delim.clipboard.128.
# <0 rows> (or 0-length row.names)
# Warning message:
# In read.table(file = file, header = header, sep = sep, quote = quote,  :
#   incomplete final line found by readTableHeader on 'clipboard'

# fread fails
library(data.table)
fread("clipboard-128")
# Error in fread("clipboard-128") : 
#   File 'clipboard-128' does not exist or is non-readable. getwd()=='D:/OpenSource/data.table'

fread() does not recognize "clipboard" / "clipboard-128" as clipboard input on Windows. Due to the long period since the issue was reported, there might have been some changes in fread() over time, which is why the error message differs now, but the core problem is the same, clipboard input is not detected.

Environment:

  • OS: Windows
  • R: 4.5.2

Please let me know if any changes are needed.

@codecov
Copy link

codecov bot commented Feb 9, 2026

Codecov Report

❌ Patch coverage is 5.88235% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.93%. Comparing base (1bd88cb) to head (c68136d).

Files with missing lines Patch % Lines
R/fread.R 5.88% 16 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7640      +/-   ##
==========================================
- Coverage   99.02%   98.93%   -0.10%     
==========================================
  Files          87       87              
  Lines       16896    16913      +17     
==========================================
+ Hits        16732    16733       +1     
- Misses        164      180      +16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AmanKashyap0807
Copy link
Author

Hi @MichaelChirico,

I’ve synced the branch with master.
The atime check is still hitting an 'invalid reference' error, which I suspect might be a CI issue with external forks. Also, the Codecov failure is likely due to my changes being Windows-specific while the CI runs on Linux.

Let me know if there’s anything else I should do on my end to help resolve these!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fread from "clipboard" or "clipboard-128" (on Windows) fails

1 participant