Skip to content

Commit

Permalink
devel/RStudio: Fix bug that RStudio-server didn't have /usr/local/bin…
Browse files Browse the repository at this point in the history
… in PATH

This was previously fixed in post-install but the previous fix
relied on the other path that changed, which eroded this fix.

The new fix adds /usr/local/bin to PATH in the C++ code.
  • Loading branch information
yurivict committed Aug 29, 2023
1 parent b1f7b51 commit 9884a43
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
12 changes: 5 additions & 7 deletions devel/RStudio/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
PORTNAME= RStudio
DISTVERSIONPREFIX= v
DISTVERSION= 2022.12.0+353
PORTREVISION= 4
PORTREVISION= 5
CATEGORIES= devel math java
MASTER_SITES= https://s3.amazonaws.com/rstudio-buildtools/dictionaries/:dictionaries \
https://s3.amazonaws.com/rstudio-buildtools/:buildtools
Expand Down Expand Up @@ -117,6 +117,10 @@ post-patch:
@${REINPLACE_CMD} -e ' \
s|<condition property="node.bin" value="../../../$${node.dir}/bin/node">|<condition property="node.bin" value="${LOCALBASE}/bin/node">|' \
${WRKSRC}/src/gwt/build.xml
# add $PREFIX/bin to PATH for the server daemon
.if ${FLAVOR:U} == server
@${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|' ${WRKSRC}/src/cpp/session/modules/SessionGit.cpp
.endif

pre-build:
@${CP} ${FILESDIR}/global-setenv.h ${WRKSRC}/src/cpp/desktop/
Expand All @@ -143,12 +147,6 @@ post-install:
# Some functions expect the pandoc symlink.
@${MKDIR} ${STAGEDIR}${PREFIX}/lib/${INSTALL_SUBDIR}/bin/pandoc
@cd ${STAGEDIR}${PREFIX}/lib/${INSTALL_SUBDIR}/bin/pandoc && ${LN} -s ../../../../bin/pandoc
# Add $LOCALBASE/bin to PATH to allow RStudio-server to run gmake (R_HOME/etc/Renviron.site is installed, see https://stat.ethz.ch/R-manual/R-devel/library/base/html/Startup.html)
.if ${FLAVOR:U} == server
#@${MKDIR} ${STAGEDIR}${LOCALBASE}/lib/R/etc
#@${ECHO} "PATH=\"${LOCALBASE}/bin:\$$PATH\"" > ${STAGEDIR}${LOCALBASE}/lib/R/etc/Renviron.site # it should be this way, but this fails: https://github.com/rstudio/rstudio/issues/9815
@${LN} -s ${LOCALBASE}/bin/${GMAKE} ${STAGEDIR}${PREFIX}/lib/rstudio-server/bin/postback/${GMAKE} # hack, should be as above, but at least gmake is in the path now
.endif
# There is a variability in .js file names due to use of random numbers, so we use the automatic plist.
@${SETENV} ${CO_ENV} ${SH} ${SCRIPTSDIR}/check-stagedir.sh makeplist | ${GREP} -v ^\/ | ${SED} -e 's|%%WWWDIR%%|www/rstudio| ; s|%%CMAKE_BUILD_TYPE%%|${CMAKE_BUILD_TYPE:tl}|' > ${TMPPLIST}

Expand Down
24 changes: 24 additions & 0 deletions devel/RStudio/files/patch-src_cpp_session_modules_SessionGit.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
- add path %%PREFIX%%/bin to PATH so that gmake and cmake executable would be found

--- src/cpp/session/modules/SessionGit.cpp.orig 2023-08-29 01:47:30 UTC
+++ src/cpp/session/modules/SessionGit.cpp
@@ -130,6 +130,9 @@ core::system::ProcessOptions procOptions()
FilePath postbackDir = session::options().rpostbackPath().getParent();
core::system::addToPath(&childEnv, postbackDir.getAbsolutePath());

+ // add $PREFIX/bin to path
+ core::system::addToPath(&childEnv, "%%PREFIX%%/bin");
+
options.workingDir = projects::projectContext().directory();

#ifdef _WIN32
@@ -3370,6 +3373,9 @@ core::Error initialize()
}

core::system::addToPath(postbackDir.getAbsolutePath());
+
+ // add $PREFIX/bin to path
+ core::system::addToPath("%%PREFIX%%/bin");

// add suspend/resume handler
addSuspendHandler(SuspendHandler(boost::bind(onSuspend, _2), onResume));

0 comments on commit 9884a43

Please sign in to comment.