Microsoft MVP성태의 닷넷 이야기
오류 유형: 926. dotnet tools를 sudo로 실행하는 경우 command not found [링크 복사], [링크+제목 복사],
조회: 9466
글쓴 사람
정성태 (seongtaejeong at gmail.com)
홈페이지
첨부 파일
 

dotnet tools를 sudo로 실행하는 경우 command not found

dotnet-dump를 설치하면,

$ dotnet tool install -g dotnet-dump
You can invoke the tool using the following command: dotnet-dump
Tool 'dotnet-dump' (version '8.0.547301') was successfully installed.

$ dotnet-dump ps
No supported .NET processes were found

(PATH에 등록이 되므로) ps 명령어까지는 잘 수행되지만, collect 명령어에서는 오류가 발생합니다.

// 30417 닷넷 프로세스가 있는 경우

$ dotnet-dump collect -p 30417

Writing full to /home/testusr/logs/core_20241002_153505
Unhandled exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.Net.Sockets.SocketException (13): Permission denied
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.CreateException(SocketError error, Boolean forAsyncThrow)
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ConnectAsync(Socket socket)
   at System.Net.Sockets.Socket.ConnectAsync(EndPoint remoteEP, CancellationToken cancellationToken)
   at System.Net.Sockets.Socket.ConnectAsync(EndPoint remoteEP)
   ...[생략]...

"Permission denied" 오류에 나오듯이 권한이 없기 때문인데요, 따라서 대개의 경우 sudo를 붙여야만 합니다.

$ sudo dotnet-dump ps
sudo: dotnet-dump: command not found

그런데, 보다시피 정작 sudo로 실행하면 저렇게 명령어를 찾을 수 없다고 나옵니다. 분명히 tools 디렉터리가 PATH에 등록돼 있지만,

$ sudo echo $PATH
/home/testusr/.local/bin:...[생략]...:/home/testusr/.dotnet/tools:/home/testusr/.local/bin:/home/testusr/istio/bin

dotnet-dump를 찾을 수 없는 것입니다. 왜냐하면, sudo 실행했을 때 적용되는 환경변수는 /etc/sudoers에 있는 secure_path를 따르기 때문입니다.

암튼, 저렇기 때문에 어쩔 수 없습니다, sudo로 할 때는 그냥 전체 경로를 적어주거나,

$ which dotnet-dump
/home/testusr/.dotnet/tools/dotnet-dump

secure_path 중에 적당한 경로를 골라, 가령 /usr/local/bin에 링크를 걸어주면 됩니다.

$ sudo ln -s /home/testusr/.dotnet/tools/dotnet-dump /usr/local/bin/dotnet-dump

$ ll /usr/local/bin
total 8
drwxr-xr-x  2 root root 4096 Oct  8 00:14 ./
drwxr-xr-x 10 root root 4096 Aug 20  2021 ../
lrwxrwxrwx  1 root root   37 Oct  8 00:14 dotnet-dump -> /home/testusr/.dotnet/tools/dotnet-dump*

$ which dotnet-dump
/usr/local/bin/dotnet-dump

$ sudo dotnet-dump ps
No supported .NET processes were found





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







[최초 등록일: ]
[최종 수정일: 10/12/2024]

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

비밀번호

댓글 작성자
 




... 166  167  168  [169]  170  171  172  173  174  175  176  177  178  179  180  ...
NoWriterDateCnt.TitleFile(s)
910정성태8/19/201042726개발 환경 구성: 83. Hyper-V의 네트워크 유형 (1)
909정성태8/18/201037414오류 유형: 102. System.MissingMethodException
908정성태8/17/201028426개발 환경 구성: 82. Windows Virtual PC의 네트워크 유형 (3)
907정성태8/14/201025804개발 환경 구성: 81. Windows Virtual PC의 네트워크 유형 (2)
906정성태8/13/201033551개발 환경 구성: 80. Windows Virtual PC의 네트워크 유형 (1)
905정성태8/8/201037565Team Foundation Server: 39. 배치 파일로 팀 빌드 구성 [2]파일 다운로드1
904정성태8/8/201039749오류 유형: 101. SignTool Error: No certificates were found that met all the given criteria. [2]
903정성태8/6/201036669Team Foundation Server: 38. TFS 소스 코드 관리 기능 (4) - Branch
902정성태8/5/201029144Team Foundation Server: 37. TFS 2010의 소스 서버 수작업 구성
901정성태8/4/201028299Team Foundation Server: 36. TFS 소스 코드 관리 기능 (3) - Label
900정성태8/3/201031234Team Foundation Server: 35. TFS 소스 코드 관리 기능 (2) - Shelveset
899정성태8/2/201032813Team Foundation Server: 34. TFS 소스 코드 관리 기능 (1) - Changeset
898정성태7/31/201033066.NET Framework: 182. WCF의 InactivityTimeout [1]파일 다운로드1
897정성태7/26/201133999.NET Framework: 181. AssemblyVersion, AssemblyFileVersion, AssemblyInformationalVersion [4]
896정성태7/25/201041056.NET Framework: 180. C# Singleton 인스턴스 생성 [2]
895정성태7/25/201024730VS.NET IDE: 68. Visual Studio 2010 - .NET 1.1 원격 디버깅
894정성태7/25/201030570오류 유형: 100. Could not find the Database Engine startup handle. [1]
893정성태7/25/201031513오류 유형: 99. .NET 4.0 설치된 윈도우 7에서 SQL Server 2008 R2 설치 오류
892정성태7/9/201032556오류 유형: 98. 영문 윈도우에 한글 SQL Server 2008 R2 설치할 때 오류 [4]
891정성태7/8/201029112오류 유형: 97. MsiGetProductInfo failed to retrieve ProductVersion for package with Product Code = '{...}'. Error code: 1605. [2]
889정성태7/5/201030984.NET Framework: 179. Dictionary.Get(A) 대신 Dictionary.Get(A.GetHashCode())를 사용해서는 안 되는 이유 [1]
888정성태6/30/201028559오류 유형: 96. Hyper-V 연결 오류 - A connection will not be made because credentials may not be sent to the remote computer
887정성태6/23/201038410개발 환경 구성: 79. Hyper-V의 가상 머신에서 소리 재생 방법 [2]
886정성태6/23/201026468제니퍼 .NET: 14. ASMX, WCF 호출 모니터링 및 누수 확인
885정성태6/20/201028493개발 환경 구성: 78. COM+ 서버에서 COM+ 서버를 호출하는 방법
884정성태6/20/201031093제니퍼 .NET: 13. COM+ 서버 모니터링 [2]
... 166  167  168  [169]  170  171  172  173  174  175  176  177  178  179  180  ...