Microsoft MVP성태의 닷넷 이야기
닷넷: 2341. snap으로 설치한 .NET 리눅스 실행 환경 [링크 복사], [링크+제목 복사],
조회: 2396
글쓴 사람
정성태 (seongtaejeong at gmail.com)
홈페이지
첨부 파일
 
(연관된 글이 2개 있습니다.)
(시리즈 글이 2개 있습니다.)
오류 유형: 968. snap으로 설치한 "dotnet run" 실행 시 "undefined symbol: _dl_audit_symbind_alt, version GLIBC_PRIVATE" 오류
; https://www.sysnet.pe.kr/2/0/13967

닷넷: 2341. snap으로 설치한 .NET 리눅스 실행 환경
; https://www.sysnet.pe.kr/2/0/13969




snap으로 설치한 .NET 리눅스 실행 환경

.NET 설치 문서에는 snap에 대한 것도 나오는데요,

Install .NET SDK with Snap
; https://learn.microsoft.com/en-us/dotnet/core/install/linux-snap-sdk

실제로 해 보면 이게 문제가 좀 있습니다. 이미 지난 글에서도 symbol 풀이가 안 되는 문제를 설명했는데요, 이번에는 Windows 11 + Ubuntu 22.04 WSL 초기 환경을 구성해 snap으로 아무것도 설치하지 않은 상태에서,

$ snap list
No snaps are installed yet. Try 'snap install hello-world'.

시작해 봤습니다. 일단 여기서 dotnet-sdk를 설치했더니 2개가 더 설치되는군요. ^^

$ sudo snap install dotnet-sdk --classic
2025-07-16T23:51:12+09:00 INFO Waiting for automatic snapd restart...
dotnet-sdk 8.0.407 from Canonical✓ installed

$ snap list
Name        Version   Rev    Tracking       Publisher   Notes
core20      20250526  2599   latest/stable  canonical✓  base
dotnet-sdk  8.0.407   256    latest/stable  canonical✓  classic
snapd       2.70      24792  latest/stable  canonical✓  snapd

그리고 기본 예제를 생성하고 실행하면,

$ mkdir testapp
$ cd testapp
$ dotnet new console

$ dotnet run
$

$ ./bin/Debug/net8.0/testapp
Segmentation fault (core dumped)
$

아무런 출력이 없거나 seg fault가 발생합니다. 대신 dotnet을 이용해 dll을 직접 실행하면,

$ dotnet ./bin/Debug/net8.0/testapp.dll
Hello, World!

정상적으로 동작합니다.




그렇다면, 정상적으로 실행되는 모듈과의 의존성을 비교해 볼까요?

// sudo apt install pax-utils

$ lddtree /usr/bin/ls
ls => /usr/bin/ls (interpreter => /lib64/ld-linux-x86-64.so.2)
    libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1
        libpcre2-8.so.0 => /lib/x86_64-linux-gnu/libpcre2-8.so.0
        ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6

$ lddtree ./bin/Debug/net8.0/testapp
testapp => ./bin/Debug/net8.0/testapp (interpreter => /snap/core20/current/lib64/ld-linux-x86-64.so.2)
    libpthread.so.0 => /snap/core20/current/lib/x86_64-linux-gnu/libpthread.so.0
        ld-linux-x86-64.so.2 => /snap/core20/current/lib64/ld-linux-x86-64.so.2
    libdl.so.2 => /snap/core20/current/lib/x86_64-linux-gnu/libdl.so.2
    libstdc++.so.6 => /snap/core20/current/lib/x86_64-linux-gnu/libstdc++.so.6
    libm.so.6 => /snap/core20/current/lib/x86_64-linux-gnu/libm.so.6
    libgcc_s.so.1 => /snap/core20/current/lib/x86_64-linux-gnu/libgcc_s.so.1
    libc.so.6 => /snap/core20/current/lib/x86_64-linux-gnu/libc.so.6

역시 이번에도, snap으로 설치한 .NET의 경우 interpreter가 현재 운영체제의 기본 loader가 아닌, snap에서 dotnet-sdk의 의존성으로 설치한 core20의 loader를 사용하고 있습니다.

$ ls -l /snap/core20/current/lib64/ld-linux-x86-64.so.2
lrwxrwxrwx 1 root root 34 May 27 07:13 /snap/core20/current/lib64/ld-linux-x86-64.so.2 -> ../lib/x86_64-linux-gnu/ld-2.31.so

$ ls -l /snap/core20/current/lib/x86_64-linux-gnu/ld-2.31.so
-rwxr-xr-x 1 root root 191504 Jan 29 23:41 /snap/core20/current/lib/x86_64-linux-gnu/ld-2.31.so

반면 지난번과 다른 점이 있다면, symbol 풀이는 잘 되었다는 점입니다. 혹시나 그럼 patchelf를 이용하면 되지 않을까 싶었는데요,

$ file  ./bin/Debug/net8.0/testapp
./bin/Debug/net8.0/testapp: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /snap/core20/current/lib64/ld-linux-x86-64.so.2, BuildID[sha1]=cf6c9629befc4c1d6102c9e9e5c8ca231d88d101, for GNU/Linux 2.6.32, stripped

$ patchelf --set-interpreter /lib64/ld-linux-x86-64.so.2 ./bin/Debug/net8.0/testapp
patchelf: cannot normalize PT_NOTE segment: non-contiguous SHT_NOTE sections

실패하는군요. ^^ 오류 메시지에도 나오지만 SHT_NOTE 섹션이 연속적이지 않은 경우에는 패치를 못하는 것 같습니다. 실제로도 readelf로 확인해 보면,

$ readelf -S ./bin/Debug/net8.0/testapp | grep NOTE
  [ 1] .note.gnu.bu[...] NOTE             000000000000031c  0000031c
  [32] .note.ABI-tag     NOTE             0000000000015eb8  00012eb8

.note.gnu.build-id와 .note.ABI-tag 섹션이 연속적이지 않습니다. 암튼, 이번에도 역시 문제를 해결하려면 apt로부터 .NET SDK를 설치해야 합니다.




재미있는 건, 다른 WSL + Ubuntu 24.04에서 snap으로 설치한 .NET SDK는 문제가 또 달랐다는 점입니다. 그 환경에서는 dotnet run도 잘 동작했지만, 실행 모듈을 직접 구동하면 .NET Runtime을 찾지 못한다는 메시지가 출력됐습니다.

$ which dotnet
/snap/bin/dotnet

$ dotnet run
Hello, World!

$ ./bin/Debug/net8.0/testapp
You must install .NET to run this application.

App: /home/kevin/test/testapp/bin/Debug/net8.0/testapp
Architecture: x64
App host version: 8.0.14
.NET location: Not found

Learn more:
https://aka.ms/dotnet/app-launch-failed

Download the .NET runtime:
https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=linux-x64&os=ubuntu.24.04&apphost_version=8.0.14

$ dotnet --list-sdks
8.0.407 [/snap/dotnet-sdk/256/sdk]

$ dotnet --list-runtimes
Microsoft.AspNetCore.App 8.0.14 [/snap/dotnet-sdk/256/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.14 [/snap/dotnet-sdk/256/shared/Microsoft.NETCore.App]

문서에 보면,

2. Export the install location
; https://learn.microsoft.com/en-us/dotnet/core/install/linux-snap-sdk#2-export-the-install-location

snap으로 설치한 경우에는 DOTNET_ROOT 환경 변수가 설정되지 않는다고 하는데요, 하지만 apt로 설치한 경우에도 동일하게 설정되지 않습니다. 단지 차이점이라면 apt 설치의 경우 (/etc/profile.d/dotnet.sh에 의해) "~/.dotnet/tools" 디렉터리가 PATH 환경 변수에 추가되는 정도입니다.

어쨌든, 위에서처럼 단지 .NET runtime을 찾지 못하는 경우라면 DOTNET_ROOT 설정을 통해 해결할 수는 있습니다.

$ DOTNET_ROOT=/snap/dotnet-sdk/current ./bin/Debug/net8.0/testapp
Hello, World!

즉, snap으로 설치한 dotnet의 경우 (snap 내에 설치된 바이너리인) /snap/bin/dotnet은 스스로 시스템에 설치된 닷넷 런타임/SDK를 열거할 수 있지만, 독립 실행형 모듈로 빌드한 .NET 애플리케이션은 snap 내에 설치된 .NET 런타임을 찾지 못하는 것입니다.




정리해 보면... 그냥 snap으로 닷넷 런타임/SDK는 설치는 권장하지 않습니다. ^^




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]

[연관 글]






[최초 등록일: ]
[최종 수정일: 7/17/2025]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... 106  107  108  109  110  [111]  112  113  114  115  116  117  118  119  120  ...
NoWriterDateCnt.TitleFile(s)
11237정성태7/5/201724982.NET Framework: 663. C# - PDB 파일 경로를 PE 파일로부터 얻는 방법파일 다운로드1
11236정성태7/4/201728825.NET Framework: 662. C# - VHD/VHDX 가상 디스크를 마운트하지 않고 파일을 복사하는 방법파일 다운로드1
11235정성태6/29/201723374Math: 20. Matlab/Octave로 Gram-Schmidt 정규 직교 집합 구하는 방법
11234정성태6/29/201721432오류 유형: 404. SharePoint 2013 설치 과정에서 "The username is invalid The account must be a valid domain account" 오류 발생
11233정성태6/28/201721386오류 유형: 403. SharePoint Server 2013을 Windows Server 2016에 설치할 때 .NET 4.5 설치 오류 발생
11232정성태6/28/201722266Windows: 144. Windows Server 2016에 Windows Identity Extensions을 설치하는 방법
11231정성태6/28/201721063디버깅 기술: 86. windbg의 mscordacwks DLL 로드 문제 - 세 번째 이야기 [1]
11230정성태6/28/201720696제니퍼 .NET: 26. 제니퍼 닷넷 적용 사례 (6) - 잦은 Recycle 문제
11229정성태6/27/201722604오류 유형: 402. Windows Server Backup 관리 콘솔이 없어진 경우
11228정성태6/26/201719021개발 환경 구성: 320. Visual Basic .NET 프로젝트에서 내장 Manifest 자원을 EXE 파일로부터 제거하는 방법파일 다운로드1
11227정성태6/19/201728596개발 환경 구성: 319. windbg에서 python 스크립트 실행하는 방법 - pykd [6]
11226정성태6/19/201718509오류 유형: 401. Microsoft Edge를 실행했는데 입력 반응이 없는 경우
11225정성태6/19/201717732오류 유형: 400. Outlook - The required file ExSec32.dll cannot be found in your path. Install Microsoft Outlook again.
11224정성태6/13/201720198.NET Framework: 661. Json.NET의 DeserializeObject 수행 시 속성 이름을 동적으로 바꾸는 방법파일 다운로드1
11223정성태6/12/201719631개발 환경 구성: 318. WCF Service Application과 WCFTestClient.exe
11222정성태6/10/201724326오류 유형: 399. WCF - A property with the name 'UriTemplateMatchResults' already exists.파일 다운로드1
11221정성태6/10/201721606오류 유형: 398. Fakes - Assembly 'Jennifer5.Fakes' with identity '[...].Fakes, [...]' uses '[...]' which has a higher version than referenced assembly '[...]' with identity '[...]'
11220정성태6/10/201725676.NET Framework: 660. Shallow Copy와 Deep Copy [1]파일 다운로드2
11219정성태6/7/201720167.NET Framework: 659. 닷넷 - TypeForwardedFrom / TypeForwardedTo 특성의 사용법
11218정성태6/1/201723343개발 환경 구성: 317. Hyper-V 내의 VM에서 다시 Hyper-V를 설치: Nested Virtualization
11217정성태6/1/201720154오류 유형: 397. initerrlog: Could not open error log file 'C:\...\MSSQL12.MSSQLSERVER\MSSQL\Log\ERRORLOG'
11216정성태6/1/201721040오류 유형: 396. Activation context generation failed
11215정성태6/1/201723914오류 유형: 395. 관리 콘솔을 실행하면 "This app has been blocked for your protection" 오류 발생 [1]
11214정성태6/1/201720618오류 유형: 394. MSDTC 서비스 시작 시 -1073737712(0xC0001010) 오류와 함께 종료되는 문제 [1]
11213정성태5/26/201726883오류 유형: 393. TFS - The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
11212정성태5/26/201726038오류 유형: 392. Windows Server 2016에 KB4019472 업데이트가 실패하는 경우
... 106  107  108  109  110  [111]  112  113  114  115  116  117  118  119  120  ...