Open ergz opened 1 year ago
Can you share an error traceback()
?
I am using the addin shortcut I mapped to Alt+Shift+L
(as recommended by lintr)
> lintr:::addin_lint()
Error in iconv(lines, from = encoding, to = "UTF-8") :
invalid 'from' argument
> traceback()
5: iconv(lines, from = encoding, to = "UTF-8")
4: read_lines(filename)
3: get_lines(filename, text)
2: lintr::lint(filename$path, linters = linters)
1: lintr:::addin_lint()
Can you try tracing to see what encoding is being picked up?
trace(lintr:::read_lines, at = 1, quote(message("encoding=", encoding)))
Ran this on my open R session and got this
> lintr:::addin_lint()
Tracing read_lines(filename) step 1
encoding=NA
Error in iconv(lines, from = encoding, to = "UTF-8") :
invalid 'from' argument
So I restarted and it started working fine
> lintr:::addin_lint()
Tracing read_lines(filename) step 1
encoding=UTF-8
I decided to copy over the lintr example here: https://lintr.r-lib.org/articles/lintr.html#lintr-file-example but forgot to add an empty line so it correctly warned me about malformed file, I fixed it and ran the linter and error message reappeared.
> lintr:::addin_lint()
Tracing read_lines(filename) step 1
encoding=NA
Error in iconv(lines, from = encoding, to = "UTF-8") :
invalid 'from' argument
It seem that the encoding gets lost if the previous lintr run was stopped due to malformed lintr file, after restart it works fine, but I can make it error out over and over again if it first errors out due to a malformed lintr file.
Thanks, that's very useful info.
@ergz would you mind trying to reproduce the error with either the latest CRAN release or the current main
?
When using a .lintr file in Rstudio, using the the addin
lintr:::addin_lint()
works the first time, but trying to again fails with the following error message:My .lintr file is the one generated by:
lintr::use_lintr()
I've updated to the latest on CRAN, and then updated to the latest on github but am experiencing the same error. I also tried changing the line ending from CRLF to LF but same error happens.
System Info: OS: Windows 11 IDE: Rstudio RStudio 2023.06.1+524 "Mountain Hydrangea" Release (547dcf861cac0253a8abb52c135e44e02ba407a1, 2023-07-07)