Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning message: In readLines(filename) : incomplete final line found on 'test.R' #327

Closed
Agent-Sesame opened this issue Jun 14, 2018 · 7 comments

Comments

@Agent-Sesame
Copy link

Getting above error message when linting a very simple chunk of code.

`runtimetool <- function(x) {

start_time <- Sys.time()
Sys.sleep(x)
end_time <- Sys.time()
time_taken <- end_time - start_time
return(time_taken)

}`

@jimhester
Copy link
Member

The file is missing a newline at the end of the file. If you are running RStudio you can turn on an option to ensure it always saves files with a trailing newline.
screen shot 2018-06-14 at 1 26 28 pm

@Agent-Sesame
Copy link
Author

Thanks, that worked. Sorry for reporting such a minor thing~

@jimhester
Copy link
Member

No worries, it is a little confusing, unfortunately the error message is coming from readLines() in this case, so there isn't a lot we can do in lintr

@gitmexanism
Copy link

Hello!
Have the same problem, but turning on the option didn't help(

Full message is:

Warning message:
In readLines(con <- gzfile(tmp)): incomplete final line found on 'C:\Users\User\AppData\Local\Temp\RtmpWyvSp7\file2e042d652733'

@russHyde
Copy link
Collaborator

russHyde commented Apr 7, 2020

@gitmexanism I think that option only appends to files that have been modified since they were last saved. Could you add a newline and retry linting it, please.

@AraujoH
Copy link

AraujoH commented Jan 29, 2021

If you use readr::read_lines(), that missing newline won'be be an issue.

@AshesITR
Copy link
Collaborator

Since #562 we actually catch this warning. One could create a terminal_newline_linter from this information if deemed useful?

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

No branches or pull requests

6 participants