emacs-ess / ESS

Emacs Speaks Statistics: ESS
https://ess.r-project.org/
GNU General Public License v3.0
622 stars 162 forks source link

Flymake warning same as issue 883 #1238

Open teotenn opened 1 year ago

teotenn commented 1 year ago

I posted the following in the issue #883 but then I realized it is closed already so, I decided to open a new one. I am having same issue as other people had but I'm not able to solve it with the detailes expossed in the discussion.

I am having the same problems described in the issue. The one about not finding the init file was solved using (remove-hook 'flymake-diagnostic-functions 'flymake-proc-legacy-flymake) in my emacs init file. But I still receive the following warning:

Warning [ess-r-flymake  *ess-r-flymake*]:  Error in cat("@@warning: @@", e) : 
  argument 2 (type ’list’) cannot be handled by ’cat’
Calls: esslint ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous> -> cat
In addition: Warning message:
In file(con, "r") :
  cannot open file ’x <- data.frame(x=1:10, y=letters[1:10])’: Invalid argument
Execution halted
 Disable showing Disable logging

The part of cannot open file is always the first line of the R script I try to check. I have this one set for test, but I tried opening other scripts and the only difference is that one line.

What is even more weird is that, in my linux laptop I can use flymake with ess without problems, but this problem appears on windows only. I have the same version of flymake in both (1.2.2) and same Emacs and ESS too.

I also tryied creating the ~/R/lintr_cache but nothing changes. Here is my config file.

(setq tt/lintr-linters
      "lintr::linters_with_defaults(
         line_length_linter = line_length_linter(120)
       )"
 )

(use-package flymake
  :if (eq system-type 'windows-nt)
  :config
  (remove-hook 'flymake-diagnostic-functions 'flymake-proc-legacy-flymake))

(use-package ess
  :if (eq system-type 'windows-nt)
  :init
  (setq inferior-ess-r-program "C:/Users/teodorm3/Bin/R-4.2.1/bin/R.exe"))

(use-package ess
  :init
  (setq ess-style 'RStudio)
  :config
  (setq ess-r-flymake-linters tt/lintr-linters)
  (setq ess-eval-visibly-p t) ; ESS process (print all)
  (setq ess-ask-for-ess-directory nil)
  ;; R console hook
  (defun my-inferior-ess-init ()
    (setq-local ansi-color-for-comint-mode 'filter)
    (define-key inferior-ess-mode-map [\C-up]
      'comint-previous-matching-input-from-input)
    (define-key inferior-ess-mode-map [\C-down]
      'comint-next-matching-input-from-input)
    (define-key inferior-ess-mode-map [\C-x \t]
      'comint-dynamic-complete-filename))
  (add-hook 'inferior-ess-mode-hook 'my-inferior-ess-init)
  ;; Syntax highlight
  (setq ess-R-font-lock-keywords
      '((ess-R-fl-keyword:keywords . t)
    (ess-R-fl-keyword:constants . t)
    (ess-R-fl-keyword:modifiers . t)
    (ess-R-fl-keyword:fun-defs . t)
    (ess-R-fl-keyword:assign-ops . t)
    (ess-R-fl-keyword:%op% . t)
    (ess-fl-keyword:fun-calls . t)
    (ess-fl-keyword:numbers . t)
    (ess-fl-keyword:operators)
    (ess-fl-keyword:delimiters)
    (ess-fl-keyword:=)
    (ess-R-fl-keyword:F&T . t)))
  )

Originally posted by @teotenn in https://github.com/emacs-ess/ESS/issues/883#issuecomment-1406832854

teotenn commented 1 year ago

UPDATE

Since I read a lot the recommendation of having ~/R/lintr_cache which I tried to place in varios locations, my latest attempt was to identify the path of lintr's cache. I found it under C:\Users\<username>\AppData\Local\R\cache\R\lintr. I tried creating there the specific folder lintr_cache or also in some parent dirs, but nothing changed. In my Linux machine, where flymake works without a problems, the cache folder ir R/lintr so, same naming.

QUESTION Is this warning really related to the cache directory? The warning message is totally useless in this case and it is hard to debug. If you don't know how to solve the problem, can somebody give me at least some example how could I debug the function ess-r-flymake?

rileysg commented 1 year ago

What happens if you try making a folder ~/.R/lintr_cache? The missing . might be causing an issue.