[ESS] [External] Re: ESS confused about newest R

Kevin R. Coombes kev|n@r@coombe@ @end|ng |rom gm@||@com
Wed Jul 13 22:04:40 CEST 2022


Hi Stephen,

I can confirm that your one-character fix to the regexp works on my 
Windows system to select R-4.2.1 instead of R-4.1.0 as the newest version.

Thanks for your help,
   Kevin

On 7/13/2022 3:00 PM, Stephen Eglen wrote:
> (Martin, please see below for Query.)
>
>
> I can repeat Kevin's problem on Windows; ESS picks up R 4.1.2 rather
> than R 4.2.0 as the newest version.  Emacs fails to parse the
> date string in R 4.2.0 and so returns the date as -1.
>
> One simple fix is to remove the need to match a trailing parenthesis in
> the current regexp.  (An alternative would be to add an optional match
> for ucrt in the string, but I find regexps a pain.)
>
> So:
>
> the one line fix I propose: is to change the regexp in
> ess-r-version-date from
>
>             "R \\(version \\)?[1-9][^\n]+ (\\(2[0-9-]+\\)\\( r[0-9]+\\)?)"
>
> to
>             "R \\(version \\)?[1-9][^\n]+ (\\(2[0-9-]+\\)\\( r[0-9]+\\)?"
>
>
> If you want to test this yourself Kevin, put this at the end of your
> .emacs file, after ess has been loaded
>
>
> (setq ess-newest-R nil)
> (defun ess-r-version-date (rver)
>    "Return the date of the version of R named RVER.
> The date is returned as a date string.  If the version of R could
> not be found from the output of the RVER program, \"-1\" is
> returned."
>    (let ((date "-1")
>          (ver-string (shell-command-to-string
>                       ;; here, MS Windows (shell-command) needs a short name:
>                       (concat (if (and ess-microsoft-p
>                                        ;; silence byte compiler warns about w32-fns
>                                        (fboundp 'w32-short-file-name))
>                                   (w32-short-file-name rver)
>                                 rver)
>                               " --version"))))
>      (when (string-match
>             "R \\(version \\)?[1-9][^\n]+ (\\(2[0-9-]+\\)\\( r[0-9]+\\)?"
>             ver-string)
>        (setq date (match-string 2 ver-string)))
>      (cons date rver)))
>
> and then run
>
> M-x run-ess-r-newest
>
> For me, that now starts R 4.2.0 on WIndows.
>
> However, given the fragility of regexps, does anyone (Martin?) know why
> the ucrt now appears in versions on Windows, and whether that was
> deliberate?  ESS might well be the only program that machine reads that
> date, but still we should try to future-proof this or find out if it was
> a bug that crept in.  It looks odd to me, since UCRT seems to be short
> form for 'Universal C Runtime'.



More information about the ESS-help mailing list