Re: [ESS] Following up, success! [was RE: [R-win] Difficulty installing R packages under Windows 11 / Cygwin]

2024-01-07 Thread Robert Lerche via ESS-help
> Just to be sure: So all these changes in your patch are guaranteed to *not* 
> change the path / file-paths  anywhere *unless* our emacs & ESS run on an 
> Windows Cygwin  platform?

That is my intention.  Here is a slight "belt and suspenders" update, adding a 
specific test for Cygwin Emacs. If not, force ess-cygwin-prefix to nil.  I have 
tested this in my environment.

---

>From 9f64f41c09fed6161de841297239ad74a1c1448d Mon Sep 17 00:00:00 2001
From: Robert Lerche 
Date: Sun, 7 Jan 2024 10:01:22 -0800
Subject: [PATCH] For compatibility between Cygwin Emacs and R built for
 Windows add prefix to R initialization

---
 lisp/ess-custom.el | 6 ++
 lisp/ess-inf.el| 2 +-
 lisp/ess-r-mode.el | 2 +-
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/lisp/ess-custom.el b/lisp/ess-custom.el
index f631e04d..91d47b0e 100644
--- a/lisp/ess-custom.el
+++ b/lisp/ess-custom.el
@@ -2489,6 +2489,12 @@ Used to store the values for passing on to newly created 
buffers.")
 (defvar ess-STERM nil
   "Placeholder for dialect-specific STERM.")
 
+(defvar ess-cygwin-prefix
+  (if (not (eq system-type (quote cygwin))) nil
+(condition-case nil (nth 0 (process-lines "cygpath"  "-m" "/"))
+  (error nil)))
+  "For Windows compatibility, prefix paths passed to R with this")
+
 (make-obsolete-variable 'ess-S-loop-timeout "It is ignored." "ESS 18.10")
 (make-obsolete-variable 'ess-mode-load-hook "It is ignored." "ESS 18.10")
 (make-obsolete-variable 'ess-speedbar-use-p "It is ignored." "ESS 18.10")
diff --git a/lisp/ess-inf.el b/lisp/ess-inf.el
index 9ca3f455..9b611934 100644
--- a/lisp/ess-inf.el
+++ b/lisp/ess-inf.el
@@ -3046,7 +3046,7 @@ NO-ERROR prevents errors when this has not been 
implemented for
  path))
  (lpath (if remote
 (with-parsed-tramp-file-name path v v-localname)
-  path)))
+  (concat ess-cygwin-prefix path
 (ess-eval-linewise (format ess-setwd-command lpath))
 (ess-set-process-variable 'default-directory
   (file-name-as-directory path)))
diff --git a/lisp/ess-r-mode.el b/lisp/ess-r-mode.el
index bd902710..1517d705 100644
--- a/lisp/ess-r-mode.el
+++ b/lisp/ess-r-mode.el
@@ -1572,7 +1572,7 @@ Source the etc/ESSR/.load.R file into the R process. The
 .ess.ESSR.load function sources all of the contents of the
 etc/ESSR/R directory into the ESSR environment and attaches the
 environment to the search path."
-  (let* ((src-dir (expand-file-name "ESSR/R" ess-etc-directory))
+  (let* ((src-dir (concat ess-cygwin-prefix (expand-file-name "ESSR/R" 
ess-etc-directory)))
  (buf (ess-command (ess-r--load-ESSR-command src-dir
 (with-current-buffer buf
   (let ((msg (buffer-string)))
-- 
2.42.1

-Original Message-
From: Martin Maechler  
Sent: Friday, January 5, 2024 7:58 AM
To: Robert Lerche 
Cc: Sparapani, Rodney ; Tomas Kalibera 
; ess-help ([email protected]) 

Subject: Re: [ESS] Following up, success! [was RE: [R-win] Difficulty 
installing R packages under Windows 11 / Cygwin]

[EXTERNAL MESSAGE] Be mindful when clicking links or attachments

>>>>> Robert Lerche via ESS-help
>>>>> on Wed, 3 Jan 2024 22:58:00 + writes:

> Yes and thanks for responding.  That is I think exactly what's needed and 
I have taken a shot at implementing it.  [I'm glad my previous attached patch 
got filtered, I was a bit careless.]  Here's a summary of what I've done:
> ess-custom.el: extract prefix using cygpath, set to nil if error (i.e., 
no cygpath command indicates not in Cygwin)

Just to be sure: So all these changes in your patch are guaranteed to *not* 
change the path / file-paths  anywhere
*unless* our emacs & ESS run on an Windows Cygwin  platform?

Martin

__
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help


Re: [ESS] Following up, success! [was RE: [R-win] Difficulty installing R packages under Windows 11 / Cygwin]

2024-01-05 Thread Martin Maechler via ESS-help
> Robert Lerche via ESS-help 
> on Wed, 3 Jan 2024 22:58:00 + writes:

> Yes and thanks for responding.  That is I think exactly what's needed and 
I have taken a shot at implementing it.  [I'm glad my previous attached patch 
got filtered, I was a bit careless.]  Here's a summary of what I've done:
> ess-custom.el: extract prefix using cygpath, set to nil if error (i.e., 
no cygpath command indicates not in Cygwin)

Just to be sure: So all these changes in your patch are
guaranteed to *not* change the path / file-paths  anywhere
*unless* our emacs & ESS run on an Windows Cygwin  platform?

Martin

__
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help


Re: [ESS] Following up, success! [was RE: [R-win] Difficulty installing R packages under Windows 11 / Cygwin]

2024-01-03 Thread Robert Lerche via ESS-help
Yes and thanks for responding.  That is I think exactly what's needed and I 
have taken a shot at implementing it.  [I'm glad my previous attached patch got 
filtered, I was a bit careless.]  Here's a summary of what I've done:

ess-custom.el: extract prefix using cygpath, set to nil if error (i.e., no 
cygpath command indicates not in Cygwin)
ess-inf.el: add prefix to initial setcwd()
ess-r-mode.el: add prefix to path sent to R for initialization (I know my 
change to ess-r--load-ESSR-local is right, I'm not sure about 
ess-r--fetch-ESSR-remote)

---
diff --git a/lisp/ess-custom.el b/lisp/ess-custom.el
index f631e04d..e4db36c0 100644
--- a/lisp/ess-custom.el
+++ b/lisp/ess-custom.el
@@ -2489,6 +2489,11 @@ Used to store the values for passing on to newly created 
buffers.")
 (defvar ess-STERM nil
   "Placeholder for dialect-specific STERM.")
 
+(defvar ess-cygwin-prefix
+  (condition-case nil (nth 0 (process-lines "cygpath"  "-m" "/"))
+(error nil))
+  "For Windows compatibility, prefix paths passed to R with this")
+
 (make-obsolete-variable 'ess-S-loop-timeout "It is ignored." "ESS 18.10")
 (make-obsolete-variable 'ess-mode-load-hook "It is ignored." "ESS 18.10")
 (make-obsolete-variable 'ess-speedbar-use-p "It is ignored." "ESS 18.10")
diff --git a/lisp/ess-inf.el b/lisp/ess-inf.el
index 9ca3f455..9b611934 100644
--- a/lisp/ess-inf.el
+++ b/lisp/ess-inf.el
@@ -3046,7 +3046,7 @@ NO-ERROR prevents errors when this has not been 
implemented for
  path))
  (lpath (if remote
 (with-parsed-tramp-file-name path v v-localname)
-  path)))
+  (concat ess-cygwin-prefix path
 (ess-eval-linewise (format ess-setwd-command lpath))
 (ess-set-process-variable 'default-directory
   (file-name-as-directory path)))
diff --git a/lisp/ess-r-mode.el b/lisp/ess-r-mode.el
index bd902710..7c093763 100644
--- a/lisp/ess-r-mode.el
+++ b/lisp/ess-r-mode.el
@@ -1572,7 +1572,7 @@ Source the etc/ESSR/.load.R file into the R process. The
 .ess.ESSR.load function sources all of the contents of the
 etc/ESSR/R directory into the ESSR environment and attaches the
 environment to the search path."
-  (let* ((src-dir (expand-file-name "ESSR/R" ess-etc-directory))
+  (let* ((src-dir (concat ess-cygwin-prefix (expand-file-name "ESSR/R" 
ess-etc-directory)))
  (buf (ess-command (ess-r--load-ESSR-command src-dir
 (with-current-buffer buf
   (let ((msg (buffer-string)))
@@ -1614,7 +1614,7 @@ environment from GitHub and attaches it to the search 
path. If
 the file already exists on disk from a previous download then the
 download step is omitted. This function returns t if the ESSR
 load is successful, and nil otherwise."
-  (let ((loader (ess-file-content (expand-file-name "ESSR/LOADREMOTE" 
ess-etc-directory)))
+  (let ((loader (ess-file-content (concat ess-cygwin-prefix (expand-file-name 
"ESSR/LOADREMOTE" ess-etc-directory
 (essr (or essr-version
   ;; FIXME: Hack: on MELPA essr-version is not set
   (lm-with-file (expand-file-name "ess.el" ess-lisp-directory)

From: Sparapani, Rodney  
Sent: Wednesday, January 3, 2024 11:45 AM
To: Robert Lerche ; Dirk Eddelbuettel 
; Tomas Kalibera 
Cc: ess-help ([email protected]) 
Subject: Re: Following up, success! [was RE: [ESS] [R-win] Difficulty 
installing R packages under Windows 11 / Cygwin]

[EXTERNAL MESSAGE] Be mindful when clicking links or attachments
Hi Robert:

Looking this over.  The issue appears to be that you need a prefix.
It has been a long time since I used Cygwin.  But I assume the
prefix is something like "c:" or "/cygwin/c".  In other words, 
the root is NOT "/"; rather something like $PREFIX/  Is that the issue?
I'm trying to think of a way that we could easily adapt to this
without hacking all over the places.  Possibly, we could support
PREFIX kind of like the way configure works.  Thanks

-- 
Rodney Sparapani, Associate Professor of Biostatistics, He/Him/His
Vice President, Wisconsin Chapter of the American Statistical Association
Institute for Health and Equity, Division of Biostatistics
Medical College of Wisconsin, Milwaukee Campus

From: Robert Lerche 
Date: Tuesday, January 2, 2024 at 7:00 PM
To: Dirk Eddelbuettel , Tomas Kalibera 

Cc: Sparapani, Rodney , ess-help 
(mailto:[email protected]) 
Subject: Following up, success! [was RE: [ESS] [R-win] Difficulty installing R 
packages under Windows 11 / Cygwin]
ATTENTION: This email originated from a sender outside of MCW. Use caution when 
clicking on links or opening attachments.


It turns out it was fairly easy to make ESS work in Cygwin Emacs with R built 
for Windows.  The issue was of course path names.  I attach a pa

Re: [ESS] Following up, success! [was RE: [R-win] Difficulty installing R packages under Windows 11 / Cygwin]

2024-01-03 Thread Sparapani, Rodney via ESS-help
Hi Robert:

Looking this over.  The issue appears to be that you need a prefix.
It has been a long time since I used Cygwin.  But I assume the
prefix is something like �c:� or �/cygwin/c�.  In other words,
the root is NOT �/�; rather something like $PREFIX/  Is that the issue?
I�m trying to think of a way that we could easily adapt to this
without hacking all over the places.  Possibly, we could support
PREFIX kind of like the way configure works.  Thanks

--
Rodney Sparapani, Associate Professor of Biostatistics, He/Him/His
Vice President, Wisconsin Chapter of the American Statistical Association
Institute for Health and Equity, Division of Biostatistics
Medical College of Wisconsin, Milwaukee Campus

From: Robert Lerche 
Date: Tuesday, January 2, 2024 at 7:00 PM
To: Dirk Eddelbuettel , Tomas Kalibera 

Cc: Sparapani, Rodney , ess-help ([email protected]) 

Subject: Following up, success! [was RE: [ESS] [R-win] Difficulty installing R 
packages under Windows 11 / Cygwin]
ATTENTION: This email originated from a sender outside of MCW. Use caution when 
clicking on links or opening attachments.


It turns out it was fairly easy to make ESS work in Cygwin Emacs with R built 
for Windows.  The issue was of course path names.  I attach a patch that works 
for me.

Let me explain that I am using a company-provided and managed laptop and I have 
no choice but to run Windows. I am familiar with a number of Unix/Linux -like 
environments for Windows (Cygwin, MSYS, WSL). I have tried them all over a 
period of years. I use R primarily as a means for presenting data.  It is not 
the main thrust of my work.  Having spent considerable time making this laptop 
a comfortable working environment I am loathe to switch.

[[alternative HTML version deleted]]

__
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help