fs icon indicating copy to clipboard operation
fs copied to clipboard

Installation fails on Termux

Open rrodrigueznt opened this issue 2 years ago • 17 comments

Hi! Installing from source on R 4.1.0 on Termux, I get this error:

id.cc:109:17: error: use of undeclared identifier 'getpwent'; did you mean 'getgrent'?                            passwd* pwd = getpwent();                                             ^~~~~~~~                                                getgrent                                /data/data/com.termux/files/usr/include/grp.h:55:22: note: 'getgrent' declared here                             static struct group* getgrent(void) { return 0; }                            ^                                  id.cc:109:11: error: cannot initialize a variable of type 'passwd *' with an rvalue of type 'struct group *'      passwd* pwd = getpwent();                                       ^     ~~~~~~~~~~                              id.cc:113:11: error: use of undeclared identifier 'getpwent'; did you mean 'getgrent'?                              pwd = getpwent();                                             ^~~~~~~~                                                getgrent                                      /data/data/com.termux/files/usr/include/grp.h:55:22: note: 'getgrent' declared here                             static struct group* getgrent(void) { return 0; }                            ^                                  id.cc:113:11: error: incompatible pointer types assigning to 'passwd *' from 'struct group *'                       pwd = getpwent();                                             ^~~~~~~~~~                                    4 errors generated.                                     make: *** [/data/data/com.termux/files/usr/lib/R/etc/Makeconf:173: id.o] Error 1                                make: *** Waiting for unfinished jobs....               ERROR: compilation failed for package ‘fs’              * removing ‘/data/data/com.termux/files/usr/lib/R/library/fs’

Please, any idea? Thanks!

rrodrigueznt avatar Oct 03 '21 08:10 rrodrigueznt

It looks like there are a couple of patches at https://github.com/its-pointless/gcc_termux/blob/master/R-patches/rcran-fs-id.cc.patch and https://github.com/its-pointless/gcc_termux/blob/master/R-patches/rcran-fs-Makevars.patch, did you apply those?

jimhester avatar Oct 04 '21 15:10 jimhester

Working on that! Thanks!

rrodrigueznt avatar Oct 05 '21 05:10 rrodrigueznt

Working on that! Thanks!

I'm failing in my attempts of applying both patches. Here what I get:

~ $ git apply rcran-fs-Makevars.patch --verbose --ignore-whitespace
rcran-fs-Makevars.patch:5: trailing whitespace.
HOST :=
Checking patch fs/src/Makevars...
error: while searching for:
PKG_LIBS += -lkvm
endif
ifeq ($(UNAME), Linux)
OBJECTS +=  bsd/setmode.o bsd/strmode.o bsd/reallocarray.o
endif


error: patch failed: fs/src/Makevars:18
error: fs/src/Makevars: patch does not apply
~ $
~ $ git apply rcran-fs-id.cc.patch --verbose --ignore-whitespace
Checking patch fs/src/id.cc...
error: while searching for:
List users_() {
  std::vector<std::string> names;
  std::vector<int> ids;
#ifndef __WIN32
  passwd* pwd = getpwent();
  while (pwd != NULL) {
    names.push_back(pwd->pw_name);

error: patch failed: fs/src/id.cc:69
error: fs/src/id.cc: patch does not apply
~ $

I guess both patches are outdated and shouldn't work as they are without editing and updating them. Please, am I correct? I'm new to git. Please, is there anyway of getting updated patches? I'm not sure if my question has any sense. Thanks!

rrodrigueznt avatar Oct 06 '21 01:10 rrodrigueznt

I think you could look at what the patches do and then apply the edits manually to the current sources.

jimhester avatar Oct 06 '21 12:10 jimhester

i have compiled r-base 4.1.2 source code in termux for my phone today. how to fix such issue? Thanks.

> install.packages("fs")
trying URL 'https://mirrors.bfsu.edu.cn/CRAN/src/contrib/fs_1.5.0.tar.gz'
Content type 'application/octet-stream' length 796244 bytes (777 KB)
==================================================
downloaded 777 KB

* installing *source* package ‘fs’ ...
** package ‘fs’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c dir.cc -o dir.o
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c error.cc -o error.o
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c file.cc -o file.o
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c fs.cc -o fs.o
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c getmode.cc -o getmode.o
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c id.cc -o id.o
id.cc:109:17: error: use of undeclared identifier 'getpwent'; did you mean 'getgrent'?
  passwd* pwd = getpwent();
                ^~~~~~~~
                getgrent
/data/data/com.termux/files/usr/include/grp.h:55:22: note: 'getgrent' declared here
static struct group* getgrent(void) { return 0; }
                     ^
id.cc:109:11: error: cannot initialize a variable of type 'passwd *' with an rvalue of type 'struct group *'
  passwd* pwd = getpwent();
          ^     ~~~~~~~~~~
id.cc:113:11: error: use of undeclared identifier 'getpwent'; did you mean 'getgrent'?
    pwd = getpwent();
          ^~~~~~~~
          getgrent
/data/data/com.termux/files/usr/include/grp.h:55:22: note: 'getgrent' declared here
static struct group* getgrent(void) { return 0; }
                     ^
id.cc:113:11: error: incompatible pointer types assigning to 'passwd *' from 'struct group *'
    pwd = getpwent();
          ^~~~~~~~~~
4 errors generated.
make: *** [/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/etc/Makeconf:173: id.o] Error 1
ERROR: compilation failed for package ‘fs’
* removing ‘/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/library/fs’

The downloaded source packages are in
        ‘/data/data/com.termux/files/usr/tmp/RtmpadY3y2/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("fs") :
  installation of package ‘fs’ had non-zero exit status

leechaowen avatar Nov 10 '21 09:11 leechaowen

It looks like there are a couple of patches at https://github.com/its-pointless/gcc_termux/blob/master/R-patches/rcran-fs-id.cc.patch and https://github.com/its-pointless/gcc_termux/blob/master/R-patches/rcran-fs-Makevars.patch, did you apply those?

how to use these patches? i have no knowledge about how to run patches. i think it's better update fs for termux. Could you mind take some time update it ? Thanks .

leechaowen avatar Nov 15 '21 02:11 leechaowen

I don't have termux, does libuv compile on termux?

I can consider patches to make fs compile on termux.

gaborcsardi avatar Dec 08 '21 13:12 gaborcsardi

I don't have termux, does libuv compile on termux?

I can consider patches to make fs compile on termux.

Thanks your support. i run pkg install libuv in termux, show below.

~ $ pkg install libuv
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libuv is already the newest version (1.42.0-1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
~ $

leechaowen avatar Dec 09 '21 03:12 leechaowen

Hi! @gaborcsardi, @jimhester, it seems that the change introduced by https://github.com/its-pointless/gcc_termux/blob/master/R-patches/rcran-fs-id.cc.patch is simple and easy to introduce at line 108 of the current version of id.cc in https://github.com/r-lib/fs/blob/main/src/id.cc. I guess I should fork the project, edit the file, and submit changes to the original repository with pull requests. Please, am I right? Thanks!

rrodrigueznt avatar Dec 14 '21 19:12 rrodrigueznt

Yeah, please do that. Thanks!

gaborcsardi avatar Dec 14 '21 20:12 gaborcsardi

Yeah, please do that. Thanks!

Done, I think! The message about getpwent() has gone. And using this Makevars:

https://github.com/rrodrigueznt/fs/blob/8e60e9e84fc244d9060f53b8d15cb4628d5751c3/src/Makevars

Here what I get now:

~ $ R CMD INSTALL fs --preclean
* installing to library ‘/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/library’
* installing *source* package ‘fs’ ...
** using staged installation
** libs
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c dir.cc -o dir.o
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c error.cc -o error.o
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c file.cc -o file.o
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c fs.cc -o fs.o
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c getmode.cc -o getmode.o
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c id.cc -o id.o
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c init.cc -o init.o
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c link.cc -o link.o
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c path.cc -o path.o
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c utils.cc -o utils.o
g++ -std=gnu++14 -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c unix/getmode.cc -o unix/getmode.o
gcc -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c bsd/setmode.c -o bsd/setmode.o
gcc -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c bsd/strmode.c -o bsd/strmode.o
gcc -I"/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/include" -DNDEBUG -I./libuv-1.38.1/include -I. -pthread  -I/usr/local/include   -fpic  -g -O2  -c bsd/reallocarray.c -o bsd/reallocarray.o
g++ -std=gnu++14 -shared -L/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/lib -L/usr/local/lib -o fs.so dir.o error.o file.o fs.o getmode.o id.o init.o link.o path.o utils.o unix/getmode.o bsd/setmode.o bsd/strmode.o bsd/reallocarray.o ./libuv-1.38.1/.libs/libuv.a -pthread -lbthread -L/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/lib -lR
installing to /data/data/com.termux/files/usr/local/R-4.1.2/lib/R/library/00LOCK-fs/00new/fs/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘fs’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/library/00LOCK-fs/00new/fs/libs/fs.so':
  dlopen failed: cannot locate symbol "uv__pthread_sigmask" referenced by "/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/library/00LOCK-fs/00new/fs/libs/fs.so"...
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/data/data/com.termux/files/usr/local/R-4.1.2/lib/R/library/fs’
~ $

I don't find information about uv__pthread_sigmask.

Please, any idea? Thanks!

rrodrigueznt avatar Dec 15 '21 17:12 rrodrigueznt

pthread is lacking on Termux, see here: https://github.com/r-lib/cli/issues/358#issuecomment-932428057 and the comments below.

gaborcsardi avatar Dec 15 '21 18:12 gaborcsardi

Still working hard to understand where I am lost, I founded this pthread-sigmask.patch

rrodrigueznt avatar Dec 17 '21 07:12 rrodrigueznt

pthread is lacking on Termux, see here: r-lib/cli#358 (comment) and the comments below.

I'm still lost. I'm afraid that I've no skills enough to understand why you are pointing me to my own comments in a different issue, and you say that pthread is lacking on Termux.

In Termux I find:

~ $ ls ../usr/lib/libpthr*                           
../usr/lib/libpthread.so
~ $ ls ../usr/include/pthread*
../usr/include/pthread.h
~ $

Please, does it mean that pthread is available on Termux? Also, here what I get when I try to list the symbols available in libpthread.so:

~ $ nm -gD ../usr/lib/libpthread.so
nm: ../usr/lib/libpthread.so: file format not recognized
~ $

However, I'm able to list them for any other installed library. Please, does it make any sense to you? Any further help will be truly appreciated! Thanks!

rrodrigueznt avatar Dec 18 '21 19:12 rrodrigueznt

Because libpthread is missing some functions on termux, that are provided by libbthread. Maybe this is why uv__pthread_sigmask is missing for you. But it is just a guess, I don't have a termux system, so I can't actually try any of this, sorry.

gaborcsardi avatar Dec 18 '21 21:12 gaborcsardi

someone has the right patches, the mentioned before do not work for me?

kurokirasama avatar May 28 '22 02:05 kurokirasama

compile the libuv-1.44.2 manually should work. Although it is an ugly fix.

  • download the R package and extract it;

  • patch whatever the above threads told;

  • Compile libuv manunally

rm -rf fs/src/libuv-1.44.2`
cd fs/src
wget https://codeload.github.com/libuv/libuv/tar.gz/refs/tags/v1.44.2
tar vxf v1.44.2
cd libuv-1.44.2
mkdir .libs
cd .libs
cmake ..
make
cp -rf libuv* /data/data/com.termux/files/usr/lib
  • Change srv/Makevars
UNAME := $(shell uname)

LIBUV := libuv-1.44.2

PKG_LIBS = ./$(LIBUV)/.libs/libuv.so -pthread

SOURCES = $(wildcard *.cc unix/*.cc)
OBJECTS = $(SOURCES:.cc=.o)

ifeq ($(UNAME), SunOS)
PKG_LIBS += -lkstat -lsendfile -lsocket -lxnet
OBJECTS +=  bsd/setmode.o bsd/strmode.o bsd/reallocarray.o
endif
ifeq ($(UNAME), FreeBSD)
PKG_LIBS += -lkvm
endif
ifeq ($(UNAME), OpenBSD)
PKG_LIBS += -lkvm
endif
ifneq ($(filter $(UNAME), Linux AIX OS400),)
OBJECTS +=  bsd/setmode.o bsd/strmode.o bsd/reallocarray.o
endif

PKG_CPPFLAGS = -I./$(LIBUV)/include -I. -pthread

all: $(SHLIB)

$(SHLIB): $(LIBUV)/.libs/libuv.so

.PHONY: shlib-clean clean

# shlib-clean: clean

clean:
	$(MAKE) --directory=$(LIBUV) distclean
	rm -f $(OBJECTS)
  • INSTALL R package

In the folder the fs package locates

R CMD INSTALL fs

yfyang86 avatar Mar 23 '24 09:03 yfyang86