Agent will not run on Linux if profiler log path contains non-existing intermediate paths #763
Labels
bug
Something isn't working
win != linux
Behavior in windows is not the same as Linux and/or vice versa
Milestone
Description
By default, the native profiler component of the agent logs to
$NEW_RELIC_HOME/Logs
(or$NEW_RELIC_HOME/logs
on Linux). This location can be overridden with the environment variableNEWRELIC_PROFILER_LOG_DIRECTORY
. On Windows, any non-existing components of the path supplied in this variable will be created (assuming the process being instrumented is running with sufficient permissions to do so). For example:C:\existingDir
<- existsC:\existingDir\nonExistingDir
<- doesn't existNEWRELIC_PROFILER_LOG_DIRECTORY=C:\existingDir\nonExistingDir\profilerLogs
then
C:\existingDir\nonExistingDir
will be created as part of the process of creating the profiler log directory.On Linux, this doesn't work. Only the final component of the path can be automatically created.
NEWRELIC_PROFILER_LOG_DIRECTORY=/home/user/existingDir/profilerLogs
<- worksNEWRELIC_PROFILER_LOG_DIRECTORY=/home/user/nonExistingDir/profilerLogs
<- doesn't workNOTE: this problem blocks the profiler from initializing, which means that the agent will not run.
The cause appears to be that on Windows, the system call used to create the profiler log directory is
SHCreateDirectoryExW
, which automatically creates intermediate path components: https://docs.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shcreatedirectoryexwwhereas on Linux, the system call used is
mkdir
, which doesn't: https://man7.org/linux/man-pages/man2/mkdir.2.html (under errors, see "ENOENT: A directory component in pathname does not exist")Expected Behavior
The behavior of the agent should be consistent between Windows and Linux.
See this Stack Overflow discussion on how to make a version of
mkdir
that automatically creates intermediate path components: https://stackoverflow.com/questions/2336242/recursive-mkdir-system-call-on-unixThe text was updated successfully, but these errors were encountered: