termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
13.08k stars 3k forks source link

Package Request: R (r-base) #250

Open tomtom opened 8 years ago

tomtom commented 8 years ago

Several users of GnuRoot Debian reported that R works on arm. Currently there is no other way to run R on Android.

its-pointless commented 7 years ago

Which arch you using im doing updates eight now? aarch64 or arm?

xraynaud commented 7 years ago

Thanks for your quick reaction. My phone is aarch64.

its-pointless commented 7 years ago

Damn dude you are the first person iv encountered with aarch64 still using android 5.1 in ages. I will find a solution tommorow. There is a funny hack you can use to get around this by preloading octave libs since it uses the libgnu during build so it has mempcpy.

xraynaud commented 7 years ago

I m on 5.0... the phone is rooted and I have to unroot it to upgrade. Last time I tried I nearly bricked it so I'm keeping 5.0...

its-pointless commented 7 years ago

if you could download R_aarch64_and_5.1_fixv1.zip and replace the R binary /data/data/com.termux/files/usr/lib/R/bin/exec/R and tell me if it works?

xraynaud commented 7 years ago

It works! Thank you very much. Should I pin the package to block updates or will you include the patch in the package? Thanks again.

rfaridi commented 7 years ago

@its-pointless, Hello, first thanks a lot for porting R in termux. I was able to run R but could not install Rcpp. I dont know how to apply patch. I know I could do "patch < patchfile" but no idea which folder to run. I would highly appreciate any help. @namdnguyen, how did u solve Rcpp problem? Can u please help?

rfaridi commented 7 years ago

Never mind, I finally could run the patch but its Hunk 1 FAILED at 33/33. I downloaded the Rcpp package from R with download.package command. What should I do now?

rfaridi commented 7 years ago

I have solved Rcpp and stringi problems. But could not install bindrcpp which is a dependency of dplyr. Any thoughtS?

rfaridi commented 7 years ago

Okay, after some trial and tribulation bindrcpp and dplyr is out of the way. But got stuck at installing the package "curl". It says configuration failed for package 'curl'. How to fix that?

rfaridi commented 7 years ago

It says "Configuration failed because libcurl was not found". But I tried curl google.com, it just worked fine.

Grimler91 commented 7 years ago

@rfaridi do you have libcurl-dev installed? pkg install libcurl-dev

rfaridi commented 7 years ago

@its-pointless @wickx @namdnguyen Do you know whether its possible to install all the packages in tidyverse? I got just stuck at "curl" package. Please help if possible.

its-pointless commented 7 years ago

Install libcurl-dev in termux then try installing curl in R ... should work

Sent from my Htc HTC 2PS6200 using FastHub

rfaridi commented 7 years ago

@Grimler91 @its-pointless , thanks guys, it works!

rfaridi commented 7 years ago

Now ran into openssl and xml2. For openssl, I tried to install libssl-dev but it was not found. For xml2, I installed libxml2-dev but it still did not work. Any ideas? @Grimler91 @its-pointless

Grimler91 commented 7 years ago

@rfaridi Well apt search openssl finds the package openssl-dev so that's probably a good bet. For libxml2 you may have to do a symlink as in this issue: #1142.

rfaridi commented 7 years ago

@Grimler91 , thanks openssl working now but still stuck with xml2. Did the symlink, installed all the related packges mentioned in the thread but still no go :-( , anyone had any luck with this?

Grimler91 commented 7 years ago

@rfaridi What error do you get? Post/upload the log

rfaridi commented 7 years ago

The error output is pretty short:

sh: ./configure: No such file or directory ERROR: configuration failed for package 'xml2'

Grimler91 commented 7 years ago

@rfaridi Can't really debug that. Try finding which lines of code that generates it.

rfaridi commented 7 years ago

Anyone was able to run R code in neovim, with nvim-r plugin? I could not send codes from script to console, nvimcom installation failed. Anyone tried that? @its-pointless @Grimler91 @namdnguyen

coolmate6 commented 7 years ago

I am getting errors when trying to install.packages ("XML") within R on android. It does not seem to be a dependency or package error. Can anyone help ?

usr/include/libandroid-support -fpic -g -O2 -c xpath.c -o xpath.o xpath.c:37:41: warning: passing 'const xmlChar ' (aka 'const unsigned char ') to parameter of type 'const char *' converts between pointers to integer types with different sign [-Wpointer-sign] ...ScalarString(mkCharCE(el->name, encod... ^~~~

/Rdefines.h:155:57: note: expanded from macro 'SET_NAMES' ...Rf_setAttrib(x, R_NamesSymbol, n) ^ /data/data/com.termux/files/usr/lib/R/include/Rinternals.h:938:30: note: passing argument to parameter here SEXP Rf_mkCharCE(const char *, cetype_t); ^ 1 warning generated. gcc -shared -lpng -ljpeg -ltiff -lcurl -lpcre -landroid-support -landroid-glob -lm -lgfortran -lopenblas -lgnuiconv -llzma -o XML.so DocParse.o EventParse.o ExpatParse.o HTMLParse.o NodeGC.o RSDTD.o RUtils.o Rcatalog.o Utils.o XMLEventParse.o XMLHashTree.o XMLTree.o fixNS.o libxmlFeatures.o schema.o xmlsecurity.o xpath.o -L/data/data/com.termux/files/usr/lib -lxml2 -lz -L/data/data/com.termux/files/usr/lib -llzma -liconv -lm -lz -lxml2 -L/data/data/com.termux/files/usr/lib -lxmlsec1-openssl -lxmlsec1 -lz -llzma -liconv -lxslt -lxml2 -lm -lssl -lcrypto /data/data/com.termux/files/usr/bin/ld: cannot find -lgfortran
clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)
make: ** [/data/data/com.termux/files/usr/lib/R/share/make/shlib.mk:6: XML.so] Error 1 ERROR: compilation failed for package ‘XML’ removing ‘/usr/lib/R/library/XML’ The downloaded source packages are in ‘/data/data/com.termux/files/

its-pointless commented 7 years ago

do you have libgfortran4 not installed? is the libgfortran.so symlink in $PREFIX/lib missing?

coolmate6 commented 7 years ago

Yes i have libgfortran4 installed. In my lib directory i see : libgfortran.so.3 libgfortran.so.4.0.0 libgfortran.so.3.0.0 libgfortran.spec libgfortran.so.4

You are right there is no symlink in $PREFIX/lib in my system. Can you advise which version of the libgfortran i should create a symlink with ?

Tks.

its-pointless commented 7 years ago

with libfortran.so.4.0.0

coolmate6 commented 7 years ago

Excellent and thank you very much. All working now. Cheers.

starlinq commented 6 years ago

After installing r-cran package and trying to run as R, got the following message: CANNOT LINK EXECUTABLE "/data/data/com.termux/files/usr/lib/R/bin/exec/R": library "libopenblas.so" not found Aborted Any ideas?

Grimler91 commented 6 years ago

@starlinq I'm guess that installing openblas will help since libopenblas.so seem to be missing.

SDRausty commented 6 years ago

pacman -S r installs R in Arch Linux in Termux PRoot. R installs with a small r, not a capital one (r-3.4.2-3 installs at present to be precise). See https://sdrausty.github.io/TermuxArch/ for more information about how to install Arch Linux in Termux. Use a capital R to run it:

screenshot_2017-11-19-17-27-46

starlinq commented 6 years ago

Thank you for the responses. I have solved the issue with command: pkg install openblas

It is amazing, now I can run R version 3.4.2. I am using a capital letter in command line: R

screenshot

bhree commented 6 years ago

I can even install IRkernel and have R run on jupyter notebook. Previously I had problem with unavailability of X11 but after last upgrade everything works fine. Thanks to the developers.

kendonB commented 6 years ago

@rfaridi what did you do to get bindrcpp to work?

anupamsingh81 commented 6 years ago

R installs with relevant instructions in pointless.repo..apt-transport not available But on running there is seg-fault with invalid permissions

Arch64 with 5.1.1

its-pointless commented 6 years ago

Invalid permissions? Whats the exact error? Are you running in another directory not your home dir? i will remove https apt stuff from instuctions and scripts as its not longer needed.

anupamsingh81 commented 6 years ago

Here is the console output when I start R..Have done install 3-4 times with same result.. I am on 5.1.1 64bit,

R version 3.4.3 (2017-11-30) -- "Kite-Eating Tree" Copyright (C) 2017 The R Foundation for Statistical Computing Platform: aarch64-unknown-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R.

caught segfault address 0x7f8b05abc8, cause 'invalid permissions'

Traceback: 1: .select_device() 2: fun(libname, pkgname) 3: doTryCatch(return(expr), name, parentenv, handler) 4: tryCatchOne(expr, names, parentenv, handlers1L) 5: tryCatchList(expr, classes, parentenv, handlers) 6: tryCatch(fun(libname, pkgname), error = identity) 7: runHook(".onLoad", env, package.lib, package) 8: loadNamespace(package, lib.loc) 9: doTryCatch(return(expr), name, parentenv, handler) 10: tryCatchOne(expr, names, parentenv, handlers1L) 11: tryCatchList(expr, classes, parentenv, handlers) 12: tryCatch({ attr(package, "LibPath") <- which.lib.loc ns <- loadNamespace(package, lib.loc) env <- attachNamespace(ns, pos = pos, deps)}, error = function(e) { P <- if (!is.null(cc <- conditionCall(e))) paste(" in", deparse(cc)[1L]) else "" msg <- gettextf("package or namespace load failed for %s%s:\n %s", sQuote(package), P, conditionMessage(e)) if (logical.return) message(paste("Error:", msg), domain = NA) else stop(msg, call. = FALSE, domain = NA)}) 13: library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, warn.conflicts = warn.conflicts, quietly = quietly) 14: doTryCatch(return(expr), name, parentenv, handler) 15: tryCatchOne(expr, names, parentenv, handlers1L) 16: tryCatchList(expr, classes, parentenv, handlers) 17: tryCatch(library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, warn.conflicts = warn.conflicts, quietly = quietly), error = function(e) e) 18: require(pkg, quietly = TRUE, warn.conflicts = FALSE, character.only = TRUE) 19: .First.sys()

Possible actions: 1: abort (with core dump, if enabled) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace

its-pointless commented 6 years ago

iv tried quickly reproducing on a android 5 rom and can't im going to have a closer look. But android 5 libc behavior can often have bugs specific to that rom for a specific manufactored device. For instance if a command line entered is too long it trunicates only using 100 characters sometimes less. Most android 5 roms aren't affected to that degree but some are. I can't gurantee i can fix it even if i can find the cause.

starlinq commented 6 years ago

After recent updates I cannot run R $ R CANNOT LINK EXECUTABLE "/data/data/com.termux/files/usr/lib/R/bin/exec/R": cannot locate symbol "__muldc3" referenced by "/data/data/com.termux/files/usr/lib/R/bin/exec/R"... Aborted

starlinq commented 6 years ago

Found a solution in another thread:

export LD_PRELOAD=/system/lib/libcompiler_rt.so

david-macleod commented 6 years ago

I can install R using the instructions provided, but am struggling to install ANY additional packages. For example

install.packages('zoo')

Results in

sh: make: not found
ERROR: compilation failed for package 'zoo'

Any help would be appreciated.

its-pointless commented 6 years ago

you need to install make? I provide zoo package via apt anyway. As well rcpp, stringi and rquantlib.

On 3 Apr. 2018 10:39 pm, "david-macleod" notifications@github.com wrote:

I can install R using the instructions provided, but am struggling to install ANY additional packages. For example

install.packages('zoo')

Results in

sh: make: not found ERROR: compilation failed for package 'zoo'

Any help would be appreciated.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/termux/termux-packages/issues/250#issuecomment-378235265, or mute the thread https://github.com/notifications/unsubscribe-auth/AP-Ot8gekkxN3xl0-dX_a_0BCFVKdsPLks5tk22HgaJpZM4IXFrE .

david-macleod commented 6 years ago

So simple! Thank you

YvesAD commented 6 years ago

Hello, Here is the error I have when trying to run R in termux

$ R CANNOT LINK EXECUTABLE "/data/data/com.termux/files/usr/lib/R/bin/exec/R": cannot locate symbol "catgets" referenced by "/data/data/com.termux/files/usr/lib/R/bin/exec/R"... Aborted $

I followed the instructions regarding the libs, reinstalled termux two times already... Here is the output from temux-info

$ termux-info
Updatable packages: All packages up to date
System information: Linux localhost 3.10.84-13024869 #1 SMP PREEMPT Tue Feb 6 16:13:51 KST 2018 aarch64 Android
Termux-packages arch: aarch64
Android version: 7.0
Device manufacturer: samsung
Device model: SM-T719
$

Thanks for your work. I am very enthousiast about having a R working on my tablet. Yours Yves D

its-pointless commented 6 years ago

Fixed. Im compiling using omp. Omp that llvm uses uses nl unicode etc. To use with android which doesn't have that android made a nlstubbs.cpp so it would work. Because im using android 8 on this tue libc.so has getcats which is a unicode nl function. So instead of linking the stubbs it linked the real thing from my libc.so on phone. To fix i just linked libomp.a with the whole archive so the stubbs is used instead and R is not linked catgets undefined.

YvesAD commented 6 years ago

WoW, that was quick! It is working now. Just had to do a "pkg upgrade".

Thanks a lot. I am physicist mostly teaching math nowadays. I wanted my pupils to be able to do some serious stats on their phones or tablets Thanks to you it will be fun next week! Yours

Yves Delhaye

BenjaminWolfe commented 6 years ago

In R, when I try install.packages('rnormt'), I get the following:

I don't know Linux well, but I've followed all the recommendations I could find. (That might be my problem! Maybe I followed conflicting instructions. :D)

I've got the following in $PREFIX/lib:

libgfortran.so libgfortran.so.3 libgfortran.so.3.0.0 libgfortran.so.4 libgfortran.so.4.0.0

Someone mentioned heading into $PREFIX/bin and copying gfortran-6 to gfortran, but there's no gfortran-6 (or anything looking like gfortran) in $PREFIX/bin.

Any pointers on what to try next? My overall goal was to get tidyverse on my phone (Android One Moto X4), and when it failed I'd decided to walk through the failed dependencies one by one. This one's stumped me.

its-pointless commented 6 years ago

Its not finding the fortran compiler. Simple solution is to use the scripts i added to setup different compilers the command setupclang-gfort-7 This will add a symlink from gfortran-7 to gfortran It will then find that command when you use R.

scm-unimelb commented 6 years ago

I have the latest R (3.4.4?) running in termux. I would love to use the 'rtichoke' R console, but it fails to 'find R shared library' (libR.so). I believe this requires building with ./configure --enable-R-shlib before make, and it is a common problem with R Studio users. Is this possible with R for termux?

dm319 commented 6 years ago

Huge thank you to its-pointless. You are helping to spread gnu/linux goodness to all these arm devices!

I have just successfully installed R with library(tidyverse). I added your repository, 'apt install r-base' and then 'apt install gcc-6' and then used the setupgcc6 command to allow installation of library(mnormt).

I copied these instructions for installing stringi/icudata from here, manually downloading the zip file:

@Dieter.Wilhelm The INSTALL documentation for stringi states: If you decide to use our ICU4C bundle then, by default, the ICU data library will be downloaded from one of our mirror servers. However, if you have already downloaded a version of icudt*.zip suitable for your platform (big/little endian), you may wish to install the package by calling: install.packages("stringi", configure.vars="ICUDT_DIR=") You can then put the already downloaded zip wherever you'd like and refer to it in – danh Oct 17 '17 at 19:11

There is probably a better way to do it, but it worked.

I've also installed neovim, vim-plug and the excellent nvim-R plugin. If you haven't come across it, it is a bit like RStudio for vim.

Now R (and Julia) are pretty much in my pocket. This is terrific and kinda unbelievable! Thanks again!

A pic for inspiration / motivation:

imgp8593_smalld

ConorIA commented 6 years ago

If it is of use to anyone who stumbles upon this thread, I've prepared a write-up for a full install of the tidyverse and Nvim-R https://conr.ca/post/installing-r-on-android-via-termux/