5

I want to use lintr to check R-files in emacs. According to https://github.com/jimhester/lintr#emacs

lintr is fully integrated into flycheck when using ESS. See the installalation documentation for those packages for more information.

So per http://ess.r-project.org/index.php?Section=download I installed ess(version 17.11-2) via sudo apt-get install ess (I'm on ubuntu), and for flycheck I installed flycheck via MELPA.

Upon restart ESS is loaded automatically when opening an *.R file, for flycheck I type M-x flycheck (for simplicity, I didn't put the usepackage line in init.el)

On M-x flycheck-buffer nothing happened and M-x flycheck-verify-checker said that the library wasn't present, so I installed lintr as install.packages("lintr") in an R shell.

Now M-x flycheck-verify-checker r-lintr is all green:

 r-lintr
   - major mode:    `ess-mode' supported
   - may enable:    yes
   - predicate:     t
   - executable:    Found at /usr/bin/R
   - lintr library: present

Flycheck can use this syntax checker for this buffer.

With M-x flycheck-buffer you can see that it is working (there"s an * next to FlyC in the status bar) but ulimately nothing is found, while in an R shell lintr::lint("myfile.R") finds a lot!

Versions:
GNU Emacs 25.2.2
Ubuntu 18.04.3 LTS

Progress:

Philopolis' answer:

1) flycheck is now loaded automatically, but still errors are not found

2) the ess in Melpa is Incompatible because it depends on julia-mode-0.3 (not available) I'll look into that, Unable to install ESS package seems promising.
I've added Melpa stable and installed ess, but to no avail: While in other languages flycheck complains about trivial stuff like to many/view spaces, in R superfluous parenthesis go unnoticed.

user2740
  • 539
  • 1
  • 5
  • 10
  • julia-mode, which is an ESS dependency, removed their stable tags a while back so you'll have to install it from MELPA, not MELPA-stable. – Alex Oct 09 '19 at 13:16

2 Answers2

3

Run C-c ! C-c for r-lintr and check the output. In my case, I discovered that flycheck was not finding the /home/user/.R/lintr_cache directory -- the problem went away once I created it.

ppanko
  • 146
  • 4
0

I also had trouble making Flycheck work with ESS. I don't know if this will work for you but here are some tips that solved the problems for me:

1) Disable Flymake (at least for ESS), since it seems that Flycheck and Flymake can trigger some odd conflicts. Add the following lines in your init file:

(require 'ess-site) ;; load ESS
(setq ess-use-flymake nil) ;; disable Flymake

While you are in your init file, you could also add the following lines to enable Flycheck globally :

(require 'flycheck)
(global-flycheck-mode t)

2) If Flycheck still does not work, try to install the latest version of ESS from MELPA. Installing ESS from my distro repo (I was on openSuse Leap) resulted in a lot of problems I didn't have anymore when I switched to the ESS versions from Melpa (or even Melpa-stable, which was just as old).

Philopolis
  • 1,094
  • 8
  • 14