fs icon indicating copy to clipboard operation
fs copied to clipboard

strmode not found in cygwin

Open DEQjpowell opened this issue 4 years ago • 6 comments

I see at the end of

https://github.com/r-lib/fs/issues/145

that a fix for “conflicting types for 'strmode'” was checked in at

https://github.com/r-lib/fs/commit/18f93ac411d3dfbd076dfb65017970f7c06324f3

and it appears to be committed into 1.5.0. So what I expect:

install.packages(“fs”)

installs fs correctly on Cygwin. What I get instead:

: Selection: 75 : trying URL 'https://ftp.osuosl.org/pub/cran/src/contrib/fs_1.5.0.tar.gz' : Content type 'application/x-gzip' length 796244 bytes (777 KB) : ================================================== : downloaded 777 KB … : /tmp/RtmpekZitb/R.INSTALL594291a2fb2/fs/src/unix/getmode.cc:32:(.text+0x77): : relocation truncated to fit: R_X86_64_PC32 against undefined symbol : `strmode' : : collect2: error: ld returned 1 exit status : make: *** [/usr/lib/R/share/make/shlib.mk:6: fs.dll] Error 1 : ERROR: compilation failed for package ‘fs’ : * removing ‘/usr/lib/R/site-library/fs’

Can you help? This has been blocking me from using R on Cygwin for many moons.

Thank you,

  • JP

Background:

: : : setmode isn't a standard library function; it's a libbsd : function. That's only the same thing on BSD-derived systems like OS X, : which that man page is from. Pass the -lbsd argument to get the linker : to find it on Linux. (https://stackoverflow.com/questions/15608116/gnu-undefined-reference-to-setmode)

I also tried this:

: install.packages('fs',repos='http://cran.us.r-project.org')

James Powell, Ph.D. Candidate NRS3 MOVES Modeler, Air Technical Services Oregon Department of Environmental Quality 700 NE Multnomah St. Suite 600, Portland OR 97212 Phone: 503-235-3679 Email: James.Powell (at) deq.state.or.us Pronouns: him/his

DEQjpowell avatar May 03 '21 23:05 DEQjpowell

I'm also having this exact issue as well. Basically everywhere I try to install fs I am failing at this point (see: https://github.com/r-lib/fs/issues/338)

jordanFC avatar Jul 12 '21 17:07 jordanFC

Get source code of 'fs' from CRAN $ wget -P /tmp http://lib.stat.cmu.edu/R/CRAN/src/contrib/fs_1.5.0.tar.gz

Extract the source

$ cd /tmp
$ tar zxvf fs_1.5.0.tar.gz

Edit /tmp/fs/src/Makevars to replace

ifeq ($(UNAME), Linux)
OBJECTS +=  bsd/setmode.o bsd/strmode.o bsd/reallocarray.o
endif

with

UNIX := $(if $(filter $(UNAME), Linux AIX OS400),UNIX)
CYGWIN := $(if $(findstring CYGWIN, $(shell echo $(UNAME) | \
                tr '[\:lower\:]', '[\:upper\:]')),UNIX)

ifeq ($(or $(UNIX), $(CYGWIN)),UNIX)
OBJECTS += bsd/setmode.o bsd/strmode.o bsd/reallocarray.o
endif

Build manually and install

$ cd /tmp
$ R CMD install fs

user3477071 avatar Nov 19 '21 03:11 user3477071

cygwin is not a platform that we support out of the box, but if you have a patch I will consider it.

gaborcsardi avatar Dec 08 '21 13:12 gaborcsardi

This patch fixes the Cygwin problem (tested fs 1.5.2). It just adds the check for CYGWIN in uname after the Linux and friends check fails. It is the very last check in Makevars before the rules.

diff --git a/src/Makevars b/src/Makevars
index a1915d7c..d087cf59 100644
--- a/src/Makevars
+++ b/src/Makevars
@@ -17,7 +17,11 @@ endif
 ifeq ($(UNAME), OpenBSD)
 PKG_LIBS += -lkvm
 endif
-ifneq ($(filter $(UNAME), Linux AIX OS400),)
+
+CYGWIN := $(findstring CYGWIN, $(shell echo $(UNAME) | \
+	    tr '[:lower:]' '[:upper:]'))
+
+ifneq ($(or $(filter $(UNAME), Linux AIX OS400), $(CYGWIN)),)
 OBJECTS +=  bsd/setmode.o bsd/strmode.o bsd/reallocarray.o
 endif

georgedemmy avatar Jun 16 '22 20:06 georgedemmy

@georgedemmy Thanks! Would you like to submit a PR? (No pressure. :))

gaborcsardi avatar Jun 17 '22 07:06 gaborcsardi

Done!

georgedemmy avatar Jun 20 '22 18:06 georgedemmy