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
I obtained a "Marker line is unspecified or invalidNA" error when using lintr with caching. I managed to find out what is causing this problem. It is reproducible using these steps:
Create two packages, "A" and "B", that have the identically-named files "tests/testthat.R". Let us assume that "A/tests/testthat.R" and "B/tests/testthat.R" are identical, except that "A/tests/testthat.R" has some trailing newlines.
In package A, run expect_lint_free(cache=TRUE). This runs fine, yields a few lints because of the trailing newlines, and generates a "~/.R/lintr_cache/testthat.R" file.
In package B, run expect_lint_free(cache=TRUE). This operation crashes with "Marker line is unspecified or invalidNA". I imagine this is because lintr sees the "~/.R/lintr_cache/testthat.R" file and wrongly assumes that it belongs to package B. Since there are some lints at line numbers after last line of file "B/tests/testthat.R", mayhem ensues...
My conclusion is that the cache should differentiate files belonging to different packages. This is important because many packages use the same names, e.g. "testthat.R" or "zzz.R".
But the problem is probably not limited to identically-named files between packages. When I create a file "A/R/more/testthat.R", issue a clear_cache() and re-run expect_lint_free(cache=TRUE), there is a single "~/.R/lintr_cache/testthat.R" file, meaning that the two "testthat.R" files in package A were likely cached in the same location, one of them overwriting the other.
A straightforward solution would be to create a subfolder for each package, and further subfolders mimicking the folder structure of the respective packages, i.e.
Source file
Cache file
A/tests/testthat.R
~/.R/lintr_cache/A/tests/testthat.R
A/R/more/testthat.R
~/.R/lintr_cache/A/R/more/testthat.R
B/tests/testthat.R
~/.R/lintr_cache/B/tests/testthat.R
Cheers,
Florent
The text was updated successfully, but these errors were encountered:
Hi Jim,
I obtained a "Marker line is unspecified or invalidNA" error when using lintr with caching. I managed to find out what is causing this problem. It is reproducible using these steps:
expect_lint_free(cache=TRUE)
. This runs fine, yields a few lints because of the trailing newlines, and generates a "~/.R/lintr_cache/testthat.R" file.expect_lint_free(cache=TRUE)
. This operation crashes with "Marker line is unspecified or invalidNA". I imagine this is because lintr sees the "~/.R/lintr_cache/testthat.R" file and wrongly assumes that it belongs to package B. Since there are some lints at line numbers after last line of file "B/tests/testthat.R", mayhem ensues...My conclusion is that the cache should differentiate files belonging to different packages. This is important because many packages use the same names, e.g. "testthat.R" or "zzz.R".
But the problem is probably not limited to identically-named files between packages. When I create a file "A/R/more/testthat.R", issue a
clear_cache()
and re-runexpect_lint_free(cache=TRUE)
, there is a single "~/.R/lintr_cache/testthat.R" file, meaning that the two "testthat.R" files in package A were likely cached in the same location, one of them overwriting the other.A straightforward solution would be to create a subfolder for each package, and further subfolders mimicking the folder structure of the respective packages, i.e.
Cheers,
Florent
The text was updated successfully, but these errors were encountered: