sbom-tool: Unable to load shared library 'MonoPosixHelper' or one of its dependencies

I’m unable to use the sbom-tool on macOS Ventura 13.2.1 as the tool immediately fails with the latest version of 0.3.3 with the following message:

Encountered error while running ManifestTool generation workflow. Error: Unable to load shared library 'MonoPosixHelper' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(libMonoPosixHelper, 0x0001): tried: 'libMonoPosixHelper' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibMonoPosixHelper' (no such file), '/usr/lib/libMonoPosixHelper' (no such file, not in dyld cache), 'libMonoPosixHelper' (no such file), '/usr/local/lib/libMonoPosixHelper' (no such file), '/usr/lib/libMonoPosixHelper' (no such file, not in dyld cache)

Might be related to #114 and #123

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 3
  • Comments: 22 (10 by maintainers)

Most upvoted comments

@shawnfunke “Unable to load shared library ‘Mono.Unix’ or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: Error loading shared library libMono.Unix: No such file or directory” When running on an alpine docker image. It seems like it is currently not supported by the Mono.Unix library so we will be reverting back to Mono.Posix.NETStandard until we find a solution.

@sebasgomez238 I’ve replaced the package Mono.Posix with Mono.Unix directly, that seems to fix the issue, see the output below:

PS: You’ve used tabs instead of spaces in the Directory.Packages.props file.

##[information]Log file: "/var/folders/xw/cd3plhm906bgtypr02x4k0m40000gn/T/GovCompDisc_Log_20230831211220440_6418.log"
##[information]Run correlation id: e33ec177-b7d4-4707-b357-dff7561a2063
##[information]Finding components...
##[information]
##[information]_______________________________________________________________________________________________________________________________________
##[information]|Component Detector Id         |Detection Time                |# Components Found            |# Explicitly Referenced                 |
##[information]|______________________________|______________________________|______________________________|________________________________________|
##[information]|CocoaPods                     |0.1 seconds                   |0                             |0                                       |
##[information]|______________________________|______________________________|______________________________|________________________________________|
##[information]|Go                            |0.1 seconds                   |0                             |0                                       |
##[information]|______________________________|______________________________|______________________________|________________________________________|
##[information]|Gradle                        |0.1 seconds                   |0                             |0                                       |
##[information]|______________________________|______________________________|______________________________|________________________________________|
##[information]|Ivy (Beta)                    |0.076 seconds                 |0                             |0                                       |
##[information]|______________________________|______________________________|______________________________|________________________________________|
##[information]|Linux                         |0.0044 seconds                |0                             |0                                       |
##[information]|______________________________|______________________________|______________________________|________________________________________|
##[information]|MvnCli                        |0.076 seconds                 |0                             |0                                       |
##[information]|______________________________|______________________________|______________________________|________________________________________|
##[information]|Npm                           |0.1 seconds                   |0                             |0                                       |
##[information]|______________________________|______________________________|______________________________|________________________________________|
##[information]|NpmLockfile3 (Beta)           |0.1 seconds                   |0                             |0                                       |
##[information]|______________________________|______________________________|______________________________|________________________________________|
##[information]|NpmWithRoots                  |0.1 seconds                   |0                             |0                                       |
##[information]|______________________________|______________________________|______________________________|________________________________________|
##[information]|NuGet                         |0.1 seconds                   |8                             |0                                       |
##[information]|______________________________|______________________________|______________________________|________________________________________|
##[information]|NuGetPackagesConfig           |0.1 seconds                   |0                             |0                                       |
##[information]|______________________________|______________________________|______________________________|________________________________________|
##[information]|NuGetProjectCentric           |0.23 seconds                  |100                           |25                                      |
##[information]|______________________________|______________________________|______________________________|________________________________________|
##[information]|Pip                           |0.1 seconds                   |0                             |0                                       |
##[information]|______________________________|______________________________|______________________________|________________________________________|
##[information]|Pnpm                          |0.1 seconds                   |0                             |0                                       |
##[information]|______________________________|______________________________|______________________________|________________________________________|
##[information]|Poetry (Beta)                 |0.1 seconds                   |0                             |0                                       |
##[information]|______________________________|______________________________|______________________________|________________________________________|
##[information]|Ruby                          |0.1 seconds                   |0                             |0                                       |
##[information]|______________________________|______________________________|______________________________|________________________________________|
##[information]|RustCrateDetector             |0.1 seconds                   |0                             |0                                       |
##[information]|______________________________|______________________________|______________________________|________________________________________|
##[information]|SPDX22SBOM                    |0.11 seconds                  |1                             |0                                       |
##[information]|______________________________|______________________________|______________________________|________________________________________|
##[information]|Vcpkg (Beta)                  |0.1 seconds                   |0                             |0                                       |
##[information]|______________________________|______________________________|______________________________|________________________________________|
##[information]|Yarn                          |0.1 seconds                   |0                             |0                                       |
##[information]|______________________________|______________________________|______________________________|________________________________________|
##[information]|Total                         |0.24 seconds                  |109                           |25                                      |
##[information]|______________________________|______________________________|______________________________|________________________________________|
##[information]
##[information]Detection time: 0.2425711 seconds.
##[information]Scan Manifest file: "/var/folders/xw/cd3plhm906bgtypr02x4k0m40000gn/T/ScanManifest_20230831211220358.json"

@sebasgomez238 this error occurs if the incorrect runtime was specified during the build process. This issue only affects ARM based Macs.

dotnet publish src/Microsoft.Sbom.Tool/Microsoft.Sbom.Tool.csproj --configuration Release --output bin --runtime osx-arm64 -p:SelfContained=true -p:OFFICIAL_BUILD=true -p:MinVerVersionOverride=1.1.8 -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:IncludeAllContentForSelfExtract=true -p:DebugType=None -p:DebugSymbols=false

If the above command is used to build the CLI it will result in the error below. I’ve set the DYLD_PRINT_LIBRARIES environment variable to 1 for the output below.

...
dyld[38737]: <AEA11273-BFDB-37A4-8244-9D973CCF15D9> /System/Library/PrivateFrameworks/BackgroundTaskManagement.framework/Versions/A/BackgroundTaskManagement
dyld[38737]: <E2CBFE03-3A04-37F9-99D3-E96E5D8D5666> /usr/lib/libTLE.dylib
Unable to load shared library 'MonoPosixHelper' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(libMonoPosixHelper, 0x0001): tried: 'libMonoPosixHelper' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibMonoPosixHelper' (no such file), '/usr/lib/libMonoPosixHelper' (no such file, not in dyld cache), 'libMonoPosixHelper' (no such file), '/usr/local/lib/libMonoPosixHelper' (no such file), '/usr/lib/libMonoPosixHelper' (no such file, not in dyld cache)

If instead of the runtime being set to osx-arm64 its set as osx-x64 the CLI will output the expected result as seen below.

...
dyld[38880]: <B6D439B3-A94A-37D9-A777-F474BD3A8E01> /System/Library/PrivateFrameworks/BackgroundTaskManagement.framework/Versions/A/BackgroundTaskManagement
dyld[38880]: <6AAC47E0-B8C6-3221-A11A-727025280815> /usr/lib/libTLE.dylib
dyld[38880]: <FA974211-6F09-333A-A45D-17DF6609F47B> /Users/shawnfunke/.net/Microsoft.Sbom.Tool/sY7iBK+dyxsgLMO6tdAQ+lC9Bvag8jg=/libMonoPosixHelper.dylib
[INFO] Log file: /private/tmp/GovCompDisc_Log_20230720201043702.log 
[INFO] Run correlation id: 495a6034-b732-4e3a-bc41-107f3a43a659 

...

The issue here is that the Mono.Posix.NETStandard ^1 NuGet package that is being used here does only include a osx runtime, no specific ARM runtime exist. This results in the dynamic library not being included in the final executable even if IncludeNativeLibrariesForSelfExtract is set to true whenever the runtime is set to ARM during the build process.

shawnfunke@shawnfunke-mbp:~/.nuget/packages/mono.posix.netstandard/1.0.0$ tree
.
├── lib
│   └── net40
│       └── Mono.Posix.NETStandard.dll
├── mono.posix.netstandard.1.0.0.nupkg
├── mono.posix.netstandard.1.0.0.nupkg.sha512
├── mono.posix.netstandard.nuspec
├── ref
│   ├── net40
│   │   └── Mono.Posix.NETStandard.dll
│   └── netstandard2.0
│       └── Mono.Posix.NETStandard.dll
└── runtimes
    ├── linux-arm
    │   ├── lib
    │   │   └── netstandard2.0
    │   │       └── Mono.Posix.NETStandard.dll
    │   └── native
    │       └── libMonoPosixHelper.so
    ├── linux-arm64
    │   ├── lib
    │   │   └── netstandard2.0
    │   │       └── Mono.Posix.NETStandard.dll
    │   └── native
    │       └── libMonoPosixHelper.so
    ├── linux-armel
    │   ├── lib
    │   │   └── netstandard2.0
    │   │       └── Mono.Posix.NETStandard.dll
    │   └── native
    │       └── libMonoPosixHelper.so
    ├── linux-x64
    │   ├── lib
    │   │   └── netstandard2.0
    │   │       └── Mono.Posix.NETStandard.dll
    │   └── native
    │       └── libMonoPosixHelper.so
    ├── linux-x86
    │   ├── lib
    │   │   └── netstandard2.0
    │   │       └── Mono.Posix.NETStandard.dll
    │   └── native
    │       └── libMonoPosixHelper.so
    ├── osx
    │   ├── lib
    │   │   └── netstandard2.0
    │   │       └── Mono.Posix.NETStandard.dll
    │   └── native
    │       └── libMonoPosixHelper.dylib
    ├── win-x64
    │   ├── lib
    │   │   └── netstandard2.0
    │   │       └── Mono.Posix.NETStandard.dll
    │   └── native
    │       ├── MonoPosixHelper.dll
    │       └── libMonoPosixHelper.dll
    └── win-x86
        ├── lib
        │   └── netstandard2.0
        │       └── Mono.Posix.NETStandard.dll
        └── native
            ├── MonoPosixHelper.dll
            └── libMonoPosixHelper.dll

39 directories, 24 files

Here’s some more details. Might be ARM/m1 related.

Apple M1 Max macOS 13.2.1

Reproduction:

  1. dotnet tool install --global Microsoft.Sbom.DotNetTool
  2. sbom-tool generate -b <drop path> -bc <build components path> -pn <package name> -pv <package version> -ps <package supplier> -nsb <namespace uri base>
  3. Encountered error while running ManifestTool generation workflow. Error: Unable to load shared library 'MonoPosixHelper' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(libMonoPosixHelper, 0x0001): tried: 'libMonoPosixHelper' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibMonoPosixHelper' (no such file), '/usr/lib/libMonoPosixHelper' (no such file, not in dyld cache), 'libMonoPosixHelper' (no such file), '/usr/local/lib/libMonoPosixHelper' (no such file), '/usr/lib/libMonoPosixHelper' (no such file, not in dyld cache)