Bug 220359 - [NEW PORT] devel/rstudio: Integrated development environment (IDE) for R
Summary: [NEW PORT] devel/rstudio: Integrated development environment (IDE) for R
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Yuri Victorovich
URL: https://reviews.freebsd.org/D13139
Keywords:
Depends on: 220319 220418
Blocks:
  Show dependency treegraph
 
Reported: 2017-06-29 16:08 UTC by Yuri Victorovich
Modified: 2017-12-02 03:33 UTC (History)
4 users (show)

See Also:


Attachments
shar (22.73 KB, text/plain)
2017-06-29 16:08 UTC, Yuri Victorovich
no flags Details
shar (22.68 KB, text/plain)
2017-06-29 16:43 UTC, Yuri Victorovich
no flags Details
shar archive (22.59 KB, text/plain)
2017-06-30 22:03 UTC, Yuri Victorovich
no flags Details
shar (22.59 KB, text/plain)
2017-07-02 03:00 UTC, Yuri Victorovich
no flags Details
shar (22.76 KB, text/plain)
2017-07-05 00:58 UTC, Yuri Victorovich
no flags Details
shar (22.66 KB, text/plain)
2017-10-27 22:09 UTC, Yuri Victorovich
no flags Details
gfortran failure log (27.03 KB, text/x-log)
2017-10-28 17:03 UTC, Yuri Victorovich
no flags Details
rstudio-link-failure.txt (11.02 KB, text/plain)
2017-10-30 16:04 UTC, Yuri Victorovich
no flags Details
shar (23.19 KB, text/plain)
2017-11-17 17:36 UTC, Yuri Victorovich
no flags Details
shar (22.91 KB, text/plain)
2017-11-17 18:31 UTC, Yuri Victorovich
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Yuri Victorovich freebsd_committer freebsd_triage 2017-06-29 16:08:06 UTC
Created attachment 183916 [details]
shar

https://www.rstudio.org

Builds in poudriere.

Caveat: Java still leaves ~/.java despite ANT_OPTS="-Duser.home=${WRKDIR}". post-build and post-stage delete them.
Comment 1 Yuri Victorovich freebsd_committer freebsd_triage 2017-06-29 16:43:23 UTC
Created attachment 183917 [details]
shar

Fixed ~/.java
Comment 2 Yuri Victorovich freebsd_committer freebsd_triage 2017-06-30 22:03:16 UTC
Created attachment 183969 [details]
shar archive
Comment 3 Rainer Hurling freebsd_committer freebsd_triage 2017-07-01 16:38:48 UTC
Building your shar archive from 2017-07-01, I get the following error on 12.0-CURRENT amd64:

/usr/bin/ld: cannot find -lRblas

My math/R was built with option ATLAS enabled instead of option RBLAS. Are there any plans for other BLAS options than the R-bundeld implementaion?
Comment 4 Yuri Victorovich freebsd_committer freebsd_triage 2017-07-01 16:52:37 UTC
I believe this is the upstream problem: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=220295

libR.pc doesn't contain all libraries that are required to link RStudio. For this reason, files/patch-src_cpp_session_CMakeLists.txt has -lRblas encoded.

I suppose RStudio port could go an extra mile and detect what BLAS implementation is linked to libR.so, but the proper way is to do this upstream.
Comment 5 Rainer Hurling freebsd_committer freebsd_triage 2017-07-01 17:00:58 UTC
(In reply to Yuri Victorovich from comment #4)

Thanks for the fast reply and the clarification.

As far as I understand, there is almost no chance to get an upstream solution from the R community in the near future. So, I would vote for a port based solution.
Comment 6 Yuri Victorovich freebsd_committer freebsd_triage 2017-07-01 17:03:12 UTC
Then the best way is math/R -based solution.
They should encode the BLAS library.

I will try to create a patch for this.
Comment 7 Yuri Victorovich freebsd_committer freebsd_triage 2017-07-01 18:43:39 UTC
Patch in bug#220418 should fix the problem with library selection.
But bug#220417 also needs to be fixed for RStudio to be able to work.
Comment 8 Yuri Victorovich freebsd_committer freebsd_triage 2017-07-02 03:00:21 UTC
Created attachment 184002 [details]
shar
Comment 9 Yuri Victorovich freebsd_committer freebsd_triage 2017-07-02 03:02:39 UTC
In order to use any BLAS library choice in R:
* Patch from bug#220418 needs to be committed
* All BLAS libraries should be switched to fortran:flang
Comment 10 Yuri Victorovich freebsd_committer freebsd_triage 2017-07-05 00:58:36 UTC
Created attachment 184063 [details]
shar

RStudio only builds on amd64 and only when FLANG=yes in R, which isn't made a default in R yet because flang is still amd64-only. BROKEN statement explains this.

But devel/rstudio works fine, and is useful, and it can be easily manually built by interested users. IMO, it can be committed in the current form with the BROKEN statement. The expectation is that flang will support i386 soon.
Comment 11 Joseph Mingrone freebsd_committer freebsd_triage 2017-10-27 13:54:44 UTC
Mk/Uses/execinfo.mk has been removed (https://reviews.freebsd.org/D11488).  I believe USES=execinfo can simply be removed from the Makefile.  The distfiles for the version in the attached patch are no longer fetchable.  Changing to PORTVERSION=1.1.383 and updating the distfile resulted in some build errors.

http://pkg.awarnach.mathstat.dal.ca/data/11amd64-default/2017-10-27_10h32m55s/logs/errors/rstudio-1.1.383.log
Comment 12 Yuri Victorovich freebsd_committer freebsd_triage 2017-10-27 15:03:27 UTC
(In reply to Joseph Mingrone from comment #11)

Ok, thanks, I will update it.
Comment 13 Yuri Victorovich freebsd_committer freebsd_triage 2017-10-27 22:09:59 UTC
Created attachment 187532 [details]
shar

* Updated to the latest version, both RStudio and dependencies
* Removed redundant USES
* Clarified "ONLY_xxx" message
* Tested with few examples - it works fine.

I think RStudio is good to be committed

(portlint produces a bogus warning, I will create a separate bug report for this.)
Comment 14 Joseph Mingrone freebsd_committer freebsd_triage 2017-10-28 01:06:18 UTC
Building with poudriere in an 11 jail still fails with the latest patch.

http://pkg.awarnach.mathstat.dal.ca/data/11amd64-default/2017-10-27_22h00m17s/logs/errors/rstudio-1.1.383.log
Comment 15 Yuri Victorovich freebsd_committer freebsd_triage 2017-10-28 03:42:59 UTC
(In reply to Joseph Mingrone from comment #14)

The core error seems to be ENFILE (Too many open files in system):
> [java] Caused by: java.nio.file.FileSystemException: /tmp/imageio19870471739360284.tmp: Too many open files

You need to increase kern.maxfiles in /boot/loader.conf
I have kern.maxfiles="25000", and it passes for me in 11.0-RELEASE-p7.
Comment 16 Tijl Coosemans freebsd_committer freebsd_triage 2017-10-28 10:49:04 UTC
It fails with gfortran because the Makefile is missing USES=fortran.  Any port that depends on a port with USES=fortran also needs USES=fortran.  Even if it doesn't contain Fortran code it still needs the *FLAGS.
Comment 17 Yuri Victorovich freebsd_committer freebsd_triage 2017-10-28 15:40:29 UTC
(In reply to Tijl Coosemans from comment #16)

Do you have the error message when it fails with gfortran, because I don't get this failure?
Comment 18 Joseph Mingrone freebsd_committer freebsd_triage 2017-10-28 15:49:44 UTC
Yuri, I believe Tijl (Tijl, please correct me if I am wrong) is responding to your statement, "RStudio only builds on amd64 and only when FLANG=yes in R".
Comment 19 Yuri Victorovich freebsd_committer freebsd_triage 2017-10-28 15:56:15 UTC
(In reply to Joseph Mingrone from comment #18)

Ah, ok, never mind. Thanks!
Comment 20 Tijl Coosemans freebsd_committer freebsd_triage 2017-10-28 16:08:31 UTC
Yes, can you do a test build with R built with gfortran and USES=fortran added to the Rstudio port Makefile?
Comment 21 Yuri Victorovich freebsd_committer freebsd_triage 2017-10-28 16:25:33 UTC
(In reply to Tijl Coosemans from comment #20)

No, this will fail. It only works when R is built with flang because of libgcc.so library conflict.
Comment 22 Tijl Coosemans freebsd_committer freebsd_triage 2017-10-28 16:32:32 UTC
Try it and show me the build error.
Comment 23 Yuri Victorovich freebsd_committer freebsd_triage 2017-10-28 17:03:44 UTC
Created attachment 187542 [details]
gfortran failure log

Please see the attached log showing how rstudio fails when math/R is built with gfortran.
Comment 24 Tijl Coosemans freebsd_committer freebsd_triage 2017-10-29 09:42:18 UTC
(In reply to Yuri Victorovich from comment #23)
Thanks.  The command is missing the right -rpath so either you forgot to add USES=fortran or the Rstudio build system doesn't respect LDFLAGS somewhere.  I'll try to reproduce it.
Comment 25 Tijl Coosemans freebsd_committer freebsd_triage 2017-10-29 14:25:45 UTC
(In reply to Yuri Victorovich from comment #23)
That log shows that ninja is being used which means you didn't add "fortran" to USES like I asked.  I tested it myself now and adding "fortran" is enough to make it work with math/R built with gfortran.
Comment 26 Yuri Victorovich freebsd_committer freebsd_triage 2017-10-29 16:13:00 UTC
(In reply to Tijl Coosemans from comment #25)

Tijl,

No matter what how do you modify the command or what USES do you add, the core problem that is the conflict between the base and gcc libgcc_s.so will still be there. gfortran requires libgcc_s.so from gcc, and C++ requires the base libgcc_s.so. 2 versions of the same library can't be mapped into the same process. This is a problem for all ports that use both fortran and C++.

Yuri
Comment 27 Yuri Victorovich freebsd_committer freebsd_triage 2017-10-30 08:10:49 UTC
Reassigned to myself.
Comment 28 Wen Heping freebsd_committer freebsd_triage 2017-10-30 08:19:09 UTC
(In reply to Yuri Victorovich from comment #27)
It's great that you get the commit bit.

wen
Comment 29 Yuri Victorovich freebsd_committer freebsd_triage 2017-10-30 08:23:37 UTC
(In reply to Wen Heping from comment #28)

Yes, thank you!
Comment 30 Tijl Coosemans freebsd_committer freebsd_triage 2017-10-30 14:42:59 UTC
(In reply to Yuri Victorovich from comment #26)
There should be no problem for clang compiled C++ code to use ports libgcc_s.  Such code only uses the _Unwind API of libgcc_s and that is the same between base and ports libgcc_s.  Rstudio isn't the first port to combine Fortran and C++.  The reason I created Mk/Uses/fortran.mk was to be able to combine clang/clang++ and gfortran.  The Fortran support that existed before that implied that gcc/g++ was used.

So what problem are you seeing when you add USES=fortran to your Makefile and build math/R with gfortran?

Congratulations with your commit bit.
Comment 31 Yuri Victorovich freebsd_committer freebsd_triage 2017-10-30 15:38:04 UTC
(In reply to Tijl Coosemans from comment #30)

> So what problem are you seeing when you add USES=fortran to your Makefile and build math/R with gfortran?

Same errors: //usr/local/lib/gcc6/libgfortran.so.3: undefined reference to `__getf2@GCC_4.6.0'
etc...


> Congratulations with your commit bit.

Thank you!
Comment 32 Tijl Coosemans freebsd_committer freebsd_triage 2017-10-30 15:41:23 UTC
(In reply to Yuri Victorovich from comment #31)
Can you provide the actual command and error messages, because here it builds just fine.
Comment 33 Yuri Victorovich freebsd_committer freebsd_triage 2017-10-30 16:04:50 UTC
Created attachment 187585 [details]
rstudio-link-failure.txt

(In reply to Tijl Coosemans from comment #32)

Attaching the failed command.
Comment 34 Tijl Coosemans freebsd_committer freebsd_triage 2017-10-30 16:10:58 UTC
(In reply to Yuri Victorovich from comment #33)
It contains this:

-L/usr/local/flang/lib -lflang -lexecinfo

Did you modify Mk/Uses/fortran.mk to make flang the default or something?
Comment 35 Yuri Victorovich freebsd_committer freebsd_triage 2017-10-30 16:30:25 UTC
(In reply to Tijl Coosemans from comment #34)

> Did you modify Mk/Uses/fortran.mk to make flang the default or something?

Ah ... yes, I had it modified.

You are right, it builds with USES=fortran.

However, it fails in the runtime with gfortran:
> "TypeError: undefined is not an object (evaluating 'window.desktopHooks.notifyRCrashed')"
Comment 36 Tijl Coosemans freebsd_committer freebsd_triage 2017-10-31 13:39:25 UTC
(In reply to Yuri Victorovich from comment #35)
I managed to get it working with this simple change:

sed -i '' 's/RHOME/R_HOME/' /usr/local/lib/rstudio/bin/r-ldpath

Without this change the script sets LD_LIBRARY_PATH to "/usr/lib:....." so any subprocess started by rstudio (e.g. rsession) loads the wrong libgcc_s.
Comment 37 Yuri Victorovich freebsd_committer freebsd_triage 2017-11-17 17:36:07 UTC
Created attachment 188078 [details]
shar

My current version of RStudio,

Question though:
Do you happen to know how to add USES only for some ARCH?

The way how it is added after .include <bsd.port.pre.mk> doesn't work.

Thanks!
Comment 38 Joseph Mingrone freebsd_committer freebsd_triage 2017-11-17 18:11:20 UTC
It seems to work here.

% sudo jexec 12835 sh
# uname -a
FreeBSD 11i386-default 11.1-RELEASE FreeBSD 11.1-RELEASE #0 r321309: Fri Jul 21 02:08:28 UTC 2017     root@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC  i386
# cd /usr/ports/devel/rstudio/
# make -VUSES
cmake:outsource desktop-file-utils pkgconfig shared-mime-info qmake:_env fortran

% s jexec 12837 sh
# uname -a
FreeBSD 11amd64-default 11.1-RELEASE FreeBSD 11.1-RELEASE #0 r321309: Fri Jul 21 02:08:28 UTC 2017     root@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC  amd64
# cd /usr/ports/devel/rstudio
# make -VUSES
cmake:outsource desktop-file-utils pkgconfig shared-mime-info qmake:_env

However, did you see the recent discussions about fortran that I copied you on?  The (misleading) subject line was 'svn commit: r452962 - head/math/libRmath'?  Also, your .Rhistory is included in the shar, and you should add a space before after the 'USES' block (before CMAKE_ARGS...) to confirm to Chapter 14 of the Porter's Handbook.
Comment 39 Joseph Mingrone freebsd_committer freebsd_triage 2017-11-17 18:22:11 UTC
The last part should have said:

you should add a space after the 'USES' block (before CMAKE_ARGS...) to conform to Chapter 14 of the Porter's Handbook.
Comment 40 Yuri Victorovich freebsd_committer freebsd_triage 2017-11-17 18:30:01 UTC
(In reply to Joseph Mingrone from comment #38)

> It seems to work here.
> # make -VUSES

Variable gets assigned, but it doesn't take effect. Try adding some non-existent USES (USES=abc fortran): it doesn't fail as it normally does.

> Also, your .Rhistory is included in the shar

Thanks! This file gets created automatically.

> you should add a space after the 'USES' block (before CMAKE_ARGS...) to conform
to Chapter 14 of the Porter's Handbook.

Thanks!

> svn commit: r452962 - head/math/libRmath

Sorry, I must have accidentally deleted it. Could you please tell me what was there?

> you should add a space after the 'USES' block (before CMAKE_ARGS...) to conform
to Chapter 14 of the Porter's Handbook.

Ok!

---

Jan Beich answered on ports@: the right way is to use .include <bsd.port.options.mk> in this case - then USES works.
Comment 41 Yuri Victorovich freebsd_committer freebsd_triage 2017-11-17 18:31:10 UTC
Created attachment 188079 [details]
shar

Now it all works.

Re-checking on i386 ...
Comment 42 Joseph Mingrone freebsd_committer freebsd_triage 2017-11-17 18:48:55 UTC
It sounds like tijl will introduce DEFAULT_VERSIONS=fortran and the default will be gfortran.
Comment 43 Yuri Victorovich freebsd_committer freebsd_triage 2017-11-17 18:59:06 UTC
(In reply to Joseph Mingrone from comment #42)

> It sounds like tijl will introduce DEFAULT_VERSIONS=fortran and the default will be gfortran.

I see. Thanks!
Comment 44 Tijl Coosemans freebsd_committer freebsd_triage 2017-11-18 13:36:06 UTC
I've made the USES=fortran changes.  math/R uses gfortran by default on all architectures now, but there's still a FLANG option.  If you want to support this option in RStudio you can do something like this:

OPTIONS_DEFINE=		FLANG

FLANG_DESC=		Use flang instead of the default Fortran compiler
FLANG_USES=		fortran:flang
FLANG_USES_OFF=		fortran
Comment 45 Yuri Victorovich freebsd_committer freebsd_triage 2017-11-18 18:26:42 UTC
(In reply to Tijl Coosemans from comment #44)

Tijl, thanks for letting me know!
Comment 46 commit-hook freebsd_committer freebsd_triage 2017-12-02 03:33:00 UTC
A commit references this bug:

Author: yuri
Date: Sat Dec  2 03:32:19 UTC 2017
New revision: 455332
URL: https://svnweb.freebsd.org/changeset/ports/455332

Log:
  New port: devel/rstudio: Integrated development environment (IDE) for R

  PR:		220359
  Approved by:	tcberner (mentor)
  Differential Revision:	https://reviews.freebsd.org/D13139

Changes:
  head/devel/Makefile
  head/devel/RStudio/
  head/devel/RStudio/Makefile
  head/devel/RStudio/distinfo
  head/devel/RStudio/files/
  head/devel/RStudio/files/global-setenv.h
  head/devel/RStudio/files/patch-CMakeGlobals.txt
  head/devel/RStudio/files/patch-CMakeLists.txt
  head/devel/RStudio/files/patch-src_cpp_CMakeLists.txt
  head/devel/RStudio/files/patch-src_cpp_core_Backtrace.cpp
  head/devel/RStudio/files/patch-src_cpp_core_CMakeLists.txt
  head/devel/RStudio/files/patch-src_cpp_core_include_core_r__util_RTokenizer.hpp
  head/devel/RStudio/files/patch-src_cpp_core_r__util_RSessionContext.cpp
  head/devel/RStudio/files/patch-src_cpp_core_system_PosixChildProcess.cpp
  head/devel/RStudio/files/patch-src_cpp_core_system_PosixSched.cpp
  head/devel/RStudio/files/patch-src_cpp_core_system_PosixSystem.cpp
  head/devel/RStudio/files/patch-src_cpp_desktop_DesktopMain.cpp
  head/devel/RStudio/files/patch-src_cpp_server_CMakeLists.txt
  head/devel/RStudio/files/patch-src_cpp_session_CMakeLists.txt
  head/devel/RStudio/files/patch-src_cpp_session_SessionHttpMethods.cpp
  head/devel/RStudio/files/patch-src_cpp_session_session-config.h.in
  head/devel/RStudio/pkg-descr