git: b0c3cea12dba - main - devel/RStudio: Add COPILOT option; Fix fetch; Fix WITH_QUATRO option

From: Yuri Victorovich <yuri_at_FreeBSD.org>
Date: Thu, 04 Dec 2025 22:56:59 UTC
The branch main has been updated by yuri:

URL: https://cgit.FreeBSD.org/ports/commit/?id=b0c3cea12dba669ae4ebadf171d6e7bf5cf9fbc5

commit b0c3cea12dba669ae4ebadf171d6e7bf5cf9fbc5
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2025-12-04 22:48:47 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2025-12-04 22:56:48 +0000

    devel/RStudio: Add COPILOT option; Fix fetch; Fix WITH_QUATRO option
    
    - the custom fetch was fetching files without adding them to distinfo
    - the COPILOT option relies on the binary installed by misc/github-copilot-language-server
    - WITH_QUATRO used wrong cmake option name
    - also: distinfo is moved to distinfo.{flavor}
---
 devel/RStudio/Makefile                             | 45 +++++++----
 devel/RStudio/{distinfo => distinfo.desktop}       |  4 +
 .../files/patch-src_cpp_session_CMakeLists.txt     | 90 ++++++++++++++++------
 ...pp_session_include_session_SessionConstants.hpp | 14 ++++
 devel/RStudio/pkg-message                          | 12 +++
 5 files changed, 123 insertions(+), 42 deletions(-)

diff --git a/devel/RStudio/Makefile b/devel/RStudio/Makefile
index a6fca5bd68f3..804ed24948b6 100644
--- a/devel/RStudio/Makefile
+++ b/devel/RStudio/Makefile
@@ -4,6 +4,7 @@
 PORTNAME=	RStudio
 DISTVERSIONPREFIX=	v
 DISTVERSION=	2025.09.2+418
+PORTREVISION=	1
 CATEGORIES=	devel math java
 MASTER_SITES=	https://s3.amazonaws.com/rstudio-buildtools/dictionaries/:dictionaries \
 		https://rstudio-buildtools.s3.amazonaws.com/rstudio-buildtools/:gin \
@@ -24,7 +25,7 @@ WWW=		https://www.rstudio.com/ \
 LICENSE=	AGPLv3
 LICENSE_FILE=	${WRKSRC}/COPYING
 
-BROKEN_i386=	[ERROR] line 101: failed to resolve 'org.rstudio.studio.client.workbench.views.vcs.common.diff.LineActionButtonRenderer.GrayResources' via deferred binding
+BROKEN_i386=	fails to resolve 'org.rstudio.studio.client.workbench.views.vcs.common.diff.LineActionButtonRenderer.GrayResources' via deferred binding
 
 BUILD_DEPENDS=	ant:devel/apache-ant \
 		${LOCALBASE}/include/sys/sysinfo.h:devel/libsysinfo \
@@ -49,6 +50,7 @@ RUN_DEPENDS=	quarto:textproc/quarto
 FLAVORS=	desktop server
 FLAVOR?=	${FLAVORS:[1]}
 server_PKGNAMESUFFIX=	-server
+server_BROKEN=		does not build with the latest RStudio version, needs to be fixed
 
 USES=		cmake fortran java:build localbase:ldflags pgsql pkgconfig sqlite ssl
 JAVA_VERSION=	17 # Build requires Java 17 target
@@ -77,8 +79,7 @@ CMAKE_ON=	RSTUDIO_USE_SYSTEM_YAML_CPP \
 		RSTUDIO_USE_SYSTEM_WEBSOCKETPP \
 		RSTUDIO_USE_SYSTEM_TL_EXPECTED \
 		RSTUDIO_INSTALL_FREEDESKTOP
-CMAKE_OFF=	RSTUDIO_ENABLE_COPILOT \
-		BUILD_TESTING \
+CMAKE_OFF=	BUILD_TESTING \
 		RSTUDIO_UNIT_TESTS_ENABLED
 MAKE_ENV=	HOME=${WRKDIR} \
 		JAVA_HOME=${JAVA_HOME} \
@@ -108,15 +109,17 @@ MAKE_ENV+=	ELECTRON_SKIP_BINARY_DOWNLOAD=1 \
 LDFLAGS+=	-linotify
 INSTALL_SUBDIR=	${PORTNAME:tl}
 EXECUTABLE=	${PORTNAME:tl}
-# npm dependencies are pre-fetched during do-fetch phase
+# npm dependencies are pre-fetched during post-fetch phase
 NPM_DISTDIR=	${DISTDIR}/${PORTNAME}
 NPM_TARBALL=	${PORTNAME}-desktop-node_modules-${DISTVERSION}${EXTRACT_SUFX}
 # quarto/panmirror dependencies (uses yarn workspaces)
 QUARTO_TARBALL=	${PORTNAME}-quarto-node_modules-${DISTVERSION}${EXTRACT_SUFX}
+# Add npm tarballs to DISTFILES for checksum verification
+DISTFILES+=	${PORTNAME}/${NPM_TARBALL}:prefetch \
+		${PORTNAME}/${QUARTO_TARBALL}:prefetch
 .endif
 
 .if ${FLAVOR:U} == server
-BROKEN=		doesn't build with the latest RSTudio version, needs to be fixed
 COMMENT+=	(web UI version)
 CMAKE_ARGS+=	-DRSTUDIO_TARGET=Server
 LDFLAGS+=	-linotify
@@ -127,8 +130,12 @@ SUB_LIST=	USER=${USER}
 USE_RC_SUBR=	${PORTNAME:tl}-server
 .endif
 
-OPTIONS_DEFINE=		WITH_QUARTO
-OPTIONS_DEFAULT=	WITH_QUARTO
+OPTIONS_DEFINE=		COPILOT WITH_QUARTO
+OPTIONS_DEFAULT=	COPILOT WITH_QUARTO
+
+COPILOT_DESC=		Build with Copilot support
+COPILOT_CMAKE_BOOL=	RSTUDIO_ENABLE_COPILOT
+COPILOT_RUN_DEPENDS=	copilot-language-server:misc/github-copilot-language-server
 
 WITH_QUARTO_DESC=	Build with support for Quarto
 WITH_QUARTO_CMAKE_BOOL=	QUARTO_ENABLED
@@ -139,29 +146,29 @@ post-fetch:
 	@if ! [ -f ${NPM_DISTDIR}/${NPM_TARBALL} ]; then \
 		${MKDIR} ${NPM_DISTDIR} && \
 		${ECHO_MSG} "====> Fetching npm dependencies for desktop..." && \
-		${MKDIR} /tmp/rstudio-npm-fetch && \
-		${FETCH_CMD} -q "https://raw.githubusercontent.com/rstudio/rstudio/v${DISTVERSION}/src/node/desktop/package.json" -o /tmp/rstudio-npm-fetch/package.json && \
-		${FETCH_CMD} -q "https://raw.githubusercontent.com/rstudio/rstudio/v${DISTVERSION}/src/node/desktop/package-lock.json" -o /tmp/rstudio-npm-fetch/package-lock.json && \
-		cd /tmp/rstudio-npm-fetch && \
-		HOME=/tmp/rstudio-npm-fetch npm ci --ignore-scripts && \
+		${MKDIR} ${WRKDIR}/tmp/rstudio-npm-fetch && \
+		${FETCH_CMD} -q "https://raw.githubusercontent.com/rstudio/rstudio/v${DISTVERSION}/src/node/desktop/package.json" -o ${WRKDIR}/tmp/rstudio-npm-fetch/package.json && \
+		${FETCH_CMD} -q "https://raw.githubusercontent.com/rstudio/rstudio/v${DISTVERSION}/src/node/desktop/package-lock.json" -o ${WRKDIR}/tmp/rstudio-npm-fetch/package-lock.json && \
+		cd ${WRKDIR}/tmp/rstudio-npm-fetch && \
+		HOME=${WRKDIR}/tmp/rstudio-npm-fetch npm ci --ignore-scripts && \
 		${FIND} node_modules -exec ${TOUCH} -h -d 1970-01-01T00:00:00Z {} \; 2>/dev/null; \
 		${TAR} -czf ${NPM_DISTDIR}/${NPM_TARBALL} node_modules && \
-		${RM} -rf /tmp/rstudio-npm-fetch && \
+		${RM} -rf ${WRKDIR}/tmp/rstudio-npm-fetch && \
 		${ECHO_MSG} "====> Created npm dependencies tarball ${NPM_DISTDIR}/${NPM_TARBALL}"; \
 	fi
 	@if ! [ -f ${NPM_DISTDIR}/${QUARTO_TARBALL} ]; then \
 		${MKDIR} ${NPM_DISTDIR} && \
 		${ECHO_MSG} "====> Fetching quarto/panmirror npm dependencies..." && \
-		${MKDIR} /tmp/rstudio-quarto-fetch && \
-		cd /tmp/rstudio-quarto-fetch && \
+		${MKDIR} ${WRKDIR}/tmp/rstudio-quarto-fetch && \
+		cd ${WRKDIR}/tmp/rstudio-quarto-fetch && \
 		${FETCH_CMD} -q "https://github.com/quarto-dev/quarto/archive/${QUARTO_MONO_COMMIT}.tar.gz" -o quarto.tar.gz && \
 		${TAR} -xzf quarto.tar.gz && \
 		cd quarto-${QUARTO_MONO_COMMIT} && \
-		HOME=/tmp/rstudio-quarto-fetch yarn install --ignore-scripts --network-timeout 240000 && \
+		HOME=${WRKDIR}/tmp/rstudio-quarto-fetch yarn install --ignore-scripts --network-timeout 240000 && \
 		cd apps/panmirror && PANMIRROR_OUTDIR=dist-rstudio yarn build --minify true --sourcemap true && cd ../.. && \
 		${FIND} node_modules apps/*/node_modules packages/*/node_modules apps/panmirror/dist-rstudio -exec ${TOUCH} -h -d 1970-01-01T00:00:00Z {} \; 2>/dev/null; \
 		${TAR} -czf ${NPM_DISTDIR}/${QUARTO_TARBALL} node_modules apps/*/node_modules packages/*/node_modules apps/panmirror/dist-rstudio && \
-		${RM} -rf /tmp/rstudio-quarto-fetch && \
+		${RM} -rf ${WRKDIR}/tmp/rstudio-quarto-fetch && \
 		${ECHO_MSG} "====> Created quarto npm dependencies tarball"; \
 	fi
 .endif
@@ -220,6 +227,8 @@ post-patch:
 .if ${FLAVOR:U} == server
 	@${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|' ${WRKSRC}/src/cpp/session/modules/SessionGit.cpp
 .endif
+	# substitute LOCALBASE for copilot-language-server path
+	@${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|' ${WRKSRC}/src/cpp/session/include/session/SessionConstants.hpp
 	# correct for boost-1.87+ class replacement
 	@${FIND} ${WRKSRC} -name "*.cpp" -o -name "*.hpp" | ${XARGS} ${REINPLACE_CMD} -i "" -e 's/io_service/io_context/g'
 
@@ -283,4 +292,6 @@ post-install:
 	# 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}
 
+DISTINFO_FILE=	${.CURDIR}/distinfo.${FLAVOR}
+
 .include <bsd.port.mk>
diff --git a/devel/RStudio/distinfo b/devel/RStudio/distinfo.desktop
similarity index 78%
rename from devel/RStudio/distinfo
rename to devel/RStudio/distinfo.desktop
index 203234b4cc7d..d88935495be0 100644
--- a/devel/RStudio/distinfo
+++ b/devel/RStudio/distinfo.desktop
@@ -19,3 +19,7 @@ SHA256 (rstudio-rsconnect-03c379b_GH0.tar.gz) = d24b6ee49f32f650f6d10bbfc7b2f61a
 SIZE (rstudio-rsconnect-03c379b_GH0.tar.gz) = 220711
 SHA256 (trestletech-plumber-v0.4.6_GH0.tar.gz) = 7bcbfdf5a8a2e3a051d2c673ac5ac51a483ed888afe73116cba7741dbb5f63a6
 SIZE (trestletech-plumber-v0.4.6_GH0.tar.gz) = 83332
+SHA256 (RStudio/RStudio-desktop-node_modules-2025.09.2+418.tar.gz) = dd1f7f2577742977fbab47a34f0e0739b9242188f228bd40d7d46bedcde3869d
+SIZE (RStudio/RStudio-desktop-node_modules-2025.09.2+418.tar.gz) = 35017694
+SHA256 (RStudio/RStudio-quarto-node_modules-2025.09.2+418.tar.gz) = 83a3083b0144a0db3ba14d6283414d1e7c9243251b473535865b9010b3fe4ab0
+SIZE (RStudio/RStudio-quarto-node_modules-2025.09.2+418.tar.gz) = 229334450
diff --git a/devel/RStudio/files/patch-src_cpp_session_CMakeLists.txt b/devel/RStudio/files/patch-src_cpp_session_CMakeLists.txt
index e352b7681a3c..fe8e4c1e71bd 100644
--- a/devel/RStudio/files/patch-src_cpp_session_CMakeLists.txt
+++ b/devel/RStudio/files/patch-src_cpp_session_CMakeLists.txt
@@ -1,11 +1,23 @@
 - Skip quarto installation (use quarto from separate FreeBSD package)
+- Skip copilot-language-server installation (use github-copilot-language-server port)
+- Always skip COPILOT_DIR validation (we use system copilot-language-server)
 
---- src/cpp/session/CMakeLists.txt.orig	2025-11-30 08:22:15 UTC
+--- src/cpp/session/CMakeLists.txt.orig2025-11-30 08:22:15 UTC
 +++ src/cpp/session/CMakeLists.txt
-@@ -726,27 +726,27 @@ if(NOT RSTUDIO_SESSION_WIN32 AND NOT RSESSION_ALTERNAT
+@@ -90,7 +90,7 @@ foreach(VAR RSTUDIO_DEPENDENCIES_DICTIONARIES_DIR
+    endif()
+ 
+    # skip Copilot if not enabled
+-   if("${VAR}" STREQUAL "RSTUDIO_DEPENDENCIES_COPILOT_DIR" AND NOT RSTUDIO_ENABLE_COPILOT)
++   if("${VAR}" STREQUAL "RSTUDIO_DEPENDENCIES_COPILOT_DIR")
+       continue()
+    endif()
+ 
+@@ -725,42 +725,42 @@ if(NOT RSTUDIO_SESSION_WIN32 AND NOT RSESSION_ALTERNAT
+    # install mathjax for local html preview
     install(DIRECTORY "${RSTUDIO_DEPENDENCIES_MATHJAX_DIR}"
             DESTINATION "${RSTUDIO_INSTALL_SUPPORTING}/resources")
- 
+-
 -   # install quarto (or pandoc if quarto disabled)
 -   if(QUARTO_ENABLED)
 -      # install some quarto folders into Resources, as needed
@@ -27,27 +39,55 @@
 -              DESTINATION "${RSTUDIO_INSTALL_BIN}/pandoc"
 -              USE_SOURCE_PERMISSIONS)
 -   endif()
-+#      # install quarto (or pandoc if quarto disabled)
-+#      if(QUARTO_ENABLED)
-+#         # install some quarto folders into Resources, as needed
-+#         if(APPLE)
-+#            install(DIRECTORY "${RSTUDIO_DEPENDENCIES_QUARTO_DIR}" 
-+#                  DESTINATION "${RSTUDIO_INSTALL_RESOURCES}/app"
-+#                  USE_SOURCE_PERMISSIONS
-+#                  PATTERN ".gitignore"
-+#                  EXCLUDE)
-+#         else()
-+#            install(DIRECTORY "${RSTUDIO_DEPENDENCIES_QUARTO_DIR}"
-+#                  DESTINATION "${RSTUDIO_INSTALL_BIN}"
-+#                  USE_SOURCE_PERMISSIONS
-+#                  PATTERN ".gitignore"
-+#                  EXCLUDE)
-+#         endif()
+ 
+-   # install Copilot Language Server
+-   if(RSTUDIO_ENABLE_COPILOT)
+-      if(APPLE)
+-         install(DIRECTORY "${RSTUDIO_DEPENDENCIES_COPILOT_DIR}" 
+-               DESTINATION "${RSTUDIO_INSTALL_RESOURCES}/app"
+-               USE_SOURCE_PERMISSIONS)
+-      else()
+-         install(DIRECTORY "${RSTUDIO_DEPENDENCIES_COPILOT_DIR}"
+-               DESTINATION "${RSTUDIO_INSTALL_BIN}"
+-               USE_SOURCE_PERMISSIONS)
+-      endif()
+-   endif()
+-
++#   # install quarto (or pandoc if quarto disabled)
++#   if(QUARTO_ENABLED)
++#      # install some quarto folders into Resources, as needed
++#      if(APPLE)
++#         install(DIRECTORY "${RSTUDIO_DEPENDENCIES_QUARTO_DIR}" 
++#               DESTINATION "${RSTUDIO_INSTALL_RESOURCES}/app"
++#               USE_SOURCE_PERMISSIONS
++#               PATTERN ".gitignore"
++#               EXCLUDE)
 +#      else()
-+#         install(DIRECTORY "${RSTUDIO_DEPENDENCIES_PANDOC_DIR}/"
-+#                 DESTINATION "${RSTUDIO_INSTALL_BIN}/pandoc"
-+#                 USE_SOURCE_PERMISSIONS)
++#         install(DIRECTORY "${RSTUDIO_DEPENDENCIES_QUARTO_DIR}"
++#               DESTINATION "${RSTUDIO_INSTALL_BIN}"
++#               USE_SOURCE_PERMISSIONS
++#               PATTERN ".gitignore"
++#               EXCLUDE)
 +#      endif()
- 
-    # install Copilot Language Server
-    if(RSTUDIO_ENABLE_COPILOT)
++#   else()
++#      install(DIRECTORY "${RSTUDIO_DEPENDENCIES_PANDOC_DIR}/"
++#              DESTINATION "${RSTUDIO_INSTALL_BIN}/pandoc"
++#              USE_SOURCE_PERMISSIONS)
++#   endif()
++#
++#   # install Copilot Language Server
++#   if(RSTUDIO_ENABLE_COPILOT)
++#      if(APPLE)
++#         install(DIRECTORY "${RSTUDIO_DEPENDENCIES_COPILOT_DIR}" 
++#               DESTINATION "${RSTUDIO_INSTALL_RESOURCES}/app"
++#               USE_SOURCE_PERMISSIONS)
++#      else()
++#         install(DIRECTORY "${RSTUDIO_DEPENDENCIES_COPILOT_DIR}"
++#               DESTINATION "${RSTUDIO_INSTALL_BIN}"
++#               USE_SOURCE_PERMISSIONS)
++#      endif()
++#   endif()
++#
+    # install embedded packages
+    foreach(PKG ${RSTUDIO_EMBEDDED_PACKAGES})
+       file(GLOB PKG_FILES "${RSTUDIO_DEPENDENCIES_DIR}/common/${PKG}*.tar.gz")
diff --git a/devel/RStudio/files/patch-src_cpp_session_include_session_SessionConstants.hpp b/devel/RStudio/files/patch-src_cpp_session_include_session_SessionConstants.hpp
new file mode 100644
index 000000000000..5c3f73e4d8d1
--- /dev/null
+++ b/devel/RStudio/files/patch-src_cpp_session_include_session_SessionConstants.hpp
@@ -0,0 +1,14 @@
+- Use system copilot-language-server from github-copilot-language-server port
+- Path must be directory containing the executable, not the executable itself
+
+--- src/cpp/session/include/session/SessionConstants.hpp.orig	2025-11-30 08:22:15 UTC
++++ src/cpp/session/include/session/SessionConstants.hpp
+@@ -158,7 +158,7 @@
+ 
+ #define kDefaultNodePath           "bin/node"
+ #define kDefaultQuartoPath         "bin/quarto"
+-#define kDefaultCopilotPath        "bin/copilot-language-server"
++#define kDefaultCopilotPath        "%%LOCALBASE%%/bin"
+ #define kDefaultRsclangPath        "bin/rsclang"
+ 
+ #ifdef _WIN32
diff --git a/devel/RStudio/pkg-message b/devel/RStudio/pkg-message
index 2c5418802ff9..0040a9846e5c 100644
--- a/devel/RStudio/pkg-message
+++ b/devel/RStudio/pkg-message
@@ -25,6 +25,18 @@ Then navigate to http://localhost:8787/ in your browser.
 You can also start the RStudio Server service once with:
 # service rstudio-server onestart
 
+=== COPILOT option ===
+In order to use this (default) option you need to be
+logged into your GitHub copilot account. 
+
+You can log into GitHub copilot using GitHub's CLI gh,
+or directly from the GitHub copilot application 'copilot'
+installed by misc/github-copilot-cli.
+
+The gh and copilot executables are not required to use the
+COPILOT option. You only need one of them to log into your
+GitHub account.
+
 EOM
 }
 ]