Skip to content

Fix R CMD check failures: suppress GLib and libfluidsynth non-critical log messages#5

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/fix-r-cmd-check-issues
Draft

Fix R CMD check failures: suppress GLib and libfluidsynth non-critical log messages#5
Copilot wants to merge 4 commits intomainfrom
copilot/fix-r-cmd-check-issues

Conversation

Copy link

Copilot AI commented Mar 9, 2026

In restricted build environments (e.g. r-universe) where HOME is inaccessible, the message "Home directory not accessible: Permission denied" appears on stderr during R CMD check. This message comes from GLib (via g_warning()), which libfluidsynth depends on as its OS abstraction layer. When GLib lazily initializes user directory paths (triggered by the first libfluidsynth API call), it attempts g_get_home_dir() and logs the warning directly to stderr, bypassing R's suppressMessages() entirely. R CMD check treats this uncapturable stderr output as a broken startup message and cascades failures across multiple check steps.

Changes in src/init.c

  • logging_callback: only emits output for FLUID_PANIC and FLUID_ERR; FLUID_WARN, FLUID_INFO, and FLUID_DBG are silently dropped. Critical errors still surface; operational/informational chatter does not.
  • Register FLUID_DBG: added fluid_set_log_function(FLUID_DBG, logging_callback, NULL) so all libfluidsynth log levels are intercepted by our handler rather than falling through to libfluidsynth's default stderr handler.
  • GLib log handler: added glib_log_suppress() installed via g_log_set_handler() for the default GLib log domain at WARNING | MESSAGE | INFO | DEBUG levels. This intercepts GLib's "Home directory not accessible" warning before it reaches stderr. G_LOG_LEVEL_CRITICAL and G_LOG_LEVEL_ERROR are deliberately not suppressed. Guarded by #ifdef HAVE_GLIB.
// Suppress non-critical libfluidsynth messages
static void logging_callback(int level, const char *message, void *data){
  if(level <= FLUID_ERR){
    REprintf("[FluidSynth] %s\n", message);
  }
}

// Suppress non-critical GLib messages (e.g. "Home directory not accessible")
#ifdef HAVE_GLIB
static void glib_log_suppress(const gchar *log_domain, GLogLevelFlags log_level,
                               const gchar *message, gpointer user_data){
  (void)log_domain; (void)log_level; (void)message; (void)user_data;
}
#endif

Changes in configure

  • Added a check that tests whether glib.h is accessible using the fluidsynth pkg-config cflags (which already include GLib include paths on Linux/Mac, since fluidsynth depends on GLib). Sets -DHAVE_GLIB when GLib headers are found.
Original prompt

This section details on the original issue you should resolve

<issue_title>R CMD check problems</issue_title>
<issue_description>:wave: @jeroen! https://ropensci.r-universe.dev/builds indicates

* checking whether startup messages can be suppressed ... NOTE
Home directory not accessible: Permission denied

It looks like this package (or a package it requires) has a startup
message which cannot be suppressed: see ?packageStartupMessage.
* checking dependencies in R code ... NOTE
Home directory not accessible: Permission denied
* checking S3 generic/method consistency ... WARNING
Home directory not accessible: Permission denied
See sectionGeneric functions and methodsin theWriting R
Extensionsmanual.
* checking replacement functions ... WARNING
Home directory not accessible: Permission denied
The argument of a replacement function which corresponds to the right
hand side must be namedvalue.
* checking foreign function calls ... NOTE
Home directory not accessible: Permission denied
See chapterSystem and foreign language interfacesin theWriting R
Extensionsmanual.
* checking R code for possible problems ... NOTE
Home directory not accessible: Permission denied
* checking Rd files ... OK
* checking Rd metadata ... OK
* checking Rd cross-references ... OK
* checking for missing documentation entries ... WARNING
Home directory not accessible: Permission denied
All user-level objects in a package should have documentation entries.
See chapterWriting R documentation filesin theWriting R
Extensionsmanual.
* checking for code/documentation mismatches ... WARNING
Home directory not accessible: Permission denied
Home directory not accessible: Permission denied
Home directory not accessible: Permission denied
* checking Rd \usage sections ... NOTE
Home directory not accessible: Permission denied
The \usage entries for S3 methods should use the \method markup and not
their full name.
See chapterWriting R documentation filesin theWriting R
Extensionsmanual.

```</issue_description>

<agent_instructions>Does this package try to write to the home directory?</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…synth logging callback

When new_fluid_settings() is called in a restricted environment (where HOME is
not accessible), libfluidsynth logs "Home directory not accessible: Permission
denied" at FLUID_WARN level. This message went through the logging_callback
using REprintf() directly to stderr, which cannot be suppressed by R's
suppressMessages(). R CMD check detected this as an uncapturable startup
message and caused cascading failures.

Fix: restrict logging_callback to only print PANIC and ERR level messages;
also register the callback for FLUID_DBG to capture all log levels.

Co-authored-by: jeroen <216319+jeroen@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix R CMD check problems regarding permission issues Suppress libfluidsynth WARN/INFO/DBG log messages to fix R CMD check failures Mar 9, 2026
@jeroen
Copy link
Member

jeroen commented Mar 9, 2026

@copilot why does new_fluid_settings write in the home directory? What is it writing? Can we set it to write elsewhere?

Copilot AI and others added 2 commits March 9, 2026 11:07
…ling a GLib log handler

The "Home directory not accessible: Permission denied" message comes from GLib
(via g_warning()), not from libfluidsynth's own logging system. Since libfluidsynth
is compiled against GLib on Linux/Mac, GLib's log handler writes directly to stderr
when HOME is inaccessible, bypassing R's suppressMessages() entirely.

Changes:
- src/init.c: Added HAVE_GLIB conditional to install a GLib log handler that
  silently discards WARNING/MESSAGE/INFO/DEBUG level messages from the default
  GLib log domain. PANIC and CRITICAL levels are NOT intercepted.
- configure: Added check for glib.h availability using fluidsynth's pkg-config
  cflags; sets -DHAVE_GLIB when GLib headers are found (Linux/Mac).

Co-authored-by: jeroen <216319+jeroen@users.noreply.github.com>
Co-authored-by: jeroen <216319+jeroen@users.noreply.github.com>
Copy link
Author

Copilot AI commented Mar 9, 2026

@copilot why does new_fluid_settings write in the home directory? What is it writing? Can we set it to write elsewhere?

The message doesn't come from libfluidsynth itself — it comes from GLib (which fluidsynth depends on). When any GLib function is first called (e.g. triggered by new_fluid_settings()), GLib lazily initializes user directory paths by calling g_get_home_dir(). When the home directory is inaccessible (as on the r-universe build server), GLib emits g_warning("Home directory not accessible: ...") which goes directly to stderr, bypassing R's message routing and suppressMessages() entirely.

It reads (not writes) the home directory — it's looking for GLib's standard user config/data directories.

There's no fluidsynth API to prevent this; fluidsynth doesn't expose control over GLib's own directory lookups.

Fixed in commit 3331970 by installing a GLib log handler at R_init_fluidsynth() startup that silently drops GLib WARNING/MESSAGE/INFO/DEBUG messages from the default domain. The configure script now checks for GLib header availability (which is guaranteed on Linux/Mac since fluidsynth depends on GLib) and sets -DHAVE_GLIB. CRITICAL and FATAL GLib messages are deliberately not suppressed.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • gitlab.gnome.org
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Suppress libfluidsynth WARN/INFO/DBG log messages to fix R CMD check failures Fix R CMD check failures: suppress GLib and libfluidsynth non-critical log messages Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

R CMD check problems

2 participants