Microsoft MVP성태의 닷넷 이야기
닷넷: 2341. snap으로 설치한 .NET 리눅스 실행 환경 [링크 복사], [링크+제목 복사],
조회: 316
글쓴 사람
정성태 (seongtaejeong at gmail.com)
홈페이지
첨부 파일
 

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

비밀번호

댓글 작성자
 




... 76  77  78  79  80  81  82  83  84  85  [86]  87  88  89  90  ...
NoWriterDateCnt.TitleFile(s)
11835정성태3/5/201923654.NET Framework: 810. C# 8.0의 Index/Range 연산자를 .NET Framework에서 사용하는 방법 및 비동기 스트림의 컴파일 방법 [3]파일 다운로드1
11834정성태3/4/201922323개발 환경 구성: 432. Visual Studio 없이 최신 C# (8.0) 컴파일러를 사용하는 방법
11833정성태3/4/201923650개발 환경 구성: 431. Visual Studio 2019 - CMake를 이용한 공유/실행(so/out) 리눅스 프로젝트 설정파일 다운로드1
11832정성태3/4/201918181오류 유형: 524. Visual Studio CMake - rsync: connection unexpectedly closed
11831정성태3/4/201919242오류 유형: 523. Visual Studio 2019 - 새 창으로 뜬 윈도우를 닫을 때 비정상 종료
11830정성태2/26/201918234오류 유형: 522. 이벤트 로그 - Error opening event log file State. Log will not be processed. Return code from OpenEventLog is 87.
11829정성태2/26/201919528개발 환경 구성: 430. 마이크로소프트의 CoreCLR 프로파일러 예제 빌드 방법 - 리눅스 환경 [1]
11828정성태2/26/201928332개발 환경 구성: 429. Component Services 관리자의 RuntimeBroker 설정이 2개 있는 경우 [8]
11827정성태2/26/201920366오류 유형: 521. Visual Studio - Could not start the 'rsync' command on the remote host, please install it using your system package manager.
11826정성태2/26/201921025오류 유형: 520. 우분투에 .NET Core SDK 설치 시 패키지 의존성 오류
11825정성태2/25/201926885개발 환경 구성: 428. Visual Studio 2019 - CMake를 이용한 리눅스 빌드 환경 설정 [1]
11824정성태2/25/201921124오류 유형: 519. The SNMP Service encountered an error while accessing the registry key SYSTEM\CurrentControlSet\Services\SNMP\Parameters\TrapConfiguration. [1]
11823정성태2/21/201921953오류 유형: 518. IIS 관리 콘솔이 뜨지 않는 문제
11822정성태2/20/201921497오류 유형: 517. docker에 설치한 MongoDB 서버로 연결이 안 되는 경우
11821정성태2/20/201922387오류 유형: 516. Visual Studio 2019 - This extension uses deprecated APIs and is at risk of not functioning in a future VS update. [1]
11820정성태2/20/201925403오류 유형: 515. 윈도우 10 1809 업데이트 후 "User Profiles Service" 1534 경고 발생
11819정성태2/20/201924570Windows: 158. 컴퓨터와 사용자의 SID(security identifier) 확인 방법
11818정성태2/20/201922292VS.NET IDE: 131. Visual Studio 2019 Preview의 닷넷 프로젝트 빌드가 20초 이상 걸리는 경우 [2]
11817정성태2/17/201918257오류 유형: 514. WinDbg Preview 실행 오류 - Error : DbgX.dll : WindowsDebugger.WindowsDebuggerException: Could not load dbgeng.dll
11816정성태2/17/201922399Windows: 157. 윈도우 스토어 앱(Microsoft Store App)을 명령행에서 직접 실행하는 방법
11815정성태2/14/201920566오류 유형: 513. Visual Studio 2019 - VSIX 설치 시 "The extension cannot be installed to this product due to prerequisites that cannot be resolved." 오류 발생
11814정성태2/12/201918803오류 유형: 512. VM(가상 머신)의 NT 서비스들이 자동 시작되지 않는 문제
11813정성태2/12/201919699.NET Framework: 809. C# - ("Save File Dialog" 등의) 대화 창에 확장 속성을 보이는 방법
11812정성태2/11/201917043오류 유형: 511. Windows Server 2003 VM 부팅 후 로그인 시점에 0xC0000005 BSOD 발생
11811정성태2/11/201923405오류 유형: 510. 서버 운영체제에 NVIDIA GeForce Experience 실행 시 wlanapi.dll 누락 문제
11810정성태2/11/201919924.NET Framework: 808. .NET Profiler - GAC 모듈에서 GAC 비-등록 모듈을 참조하는 경우의 문제
... 76  77  78  79  80  81  82  83  84  85  [86]  87  88  89  90  ...