DOTNET_CLI_HOME not respected, unset HOME can break CI
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Start with the path construction in src/LibraryManager/Cache/CacheService.cs:46 and src/LibraryManager/Configuration/Settings.cs:97, then reproduce the Jenkins or unset-HOME scenario described in the issue. Done means DOTNET_CLI_HOME is honored on non-Windows platforms and missing HOME no longer leads to an attempted /.librarymanager path or an unhandled permission error.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
Similar to NuGet#6989
On non-Windows platforms, DOTNET_CLI_HOME does not override HOME. And if HOME is unset, it effectively defaults to / potentially causing permissions issues in CI/CD systems etc.
To Reproduce
Steps to reproduce the behavior:
- Run the following Jenkinsfile in Jenkins:
pipeline {
agent {
docker {
image 'mcr.microsoft.com/dotnet/sdk:5.0'
}
}
environment {
DOTNET_CLI_HOME = "/tmp/DOTNET_CLI_HOME"
//HOME = "/tmp/DOTNET_CLI_HOME" // This line will "fix" it, but above should be enough.
}
stages {
stage('Setup') {
steps {
sh 'dotnet tool install -g Microsoft.Web.LibraryManager.Cli'
}
}
stage('Build') {
steps {
sh 'libman --version'
sh 'libman restore'
}
}
}
}
Expected behavior
If DOTNET_CLI_HOME is set, libman restore runs without error even if HOME is unset.
If neither is set, warn, rather than assuming '/.librarymanager'
Actual behavior
+ libman restore
Unhandled exception. System.TypeInitializationException: The type initializer for 'Microsoft.Web.LibraryManager.Configuration.Settings' threw an exception.
---> System.UnauthorizedAccessException: Access to the path '/.librarymanager' is denied.
---> System.IO.IOException: Permission denied
--- End of inner exception stack trace ---
at System.IO.FileSystem.CreateDirectory(String fullPath)
at System.IO.Directory.CreateDirectory(String path)
at Microsoft.Web.LibraryManager.Configuration.Settings.SaveSettingsFile(String filePath, JToken token) in C:\A\1\3\s\src\LibraryManager\Configuration\Settings.cs:line 170
at Microsoft.Web.LibraryManager.Configuration.Settings.InitSettingsFile(String configFilePath) in C:\A\1\3\s\src\LibraryManager\Configuration\Settings.cs:line 82
at Microsoft.Web.LibraryManager.Configuration.Settings..ctor() in C:\A\1\3\s\src\LibraryManager\Configuration\Settings.cs:line 73
at Microsoft.Web.LibraryManager.Configuration.Settings..cctor() in C:\A\1\3\s\src\LibraryManager\Configuration\Settings.cs:line 35
--- End of inner exception stack trace ---
at Microsoft.Web.LibraryManager.Configuration.Settings.get_DefaultSettings() in C:\A\1\3\s\src\LibraryManager\Configuration\Settings.cs:line 35
at Microsoft.Web.LibraryManager.Tools.Contracts.HostInteraction.get_Settings() in C:\A\1\3\s\src\libman\Contracts\HostInteraction.cs:line 41
at Microsoft.Web.LibraryManager.Tools.Commands.ConfigCommand..ctor(IHostEnvironment hostEnvironment, Boolean throwOnUnexpectedArg) in C:\A\1\3\s\src\libman\Commands\ConfigCommand.cs:line 25
at Microsoft.Web.LibraryManager.Tools.Commands.LibmanApp.Configure(CommandLineApplication parent) in C:\A\1\3\s\src\libman\Commands\LibmanApp.cs:line 34
at Microsoft.Web.LibraryManager.Tools.Program.Main(String[] args) in C:\A\1\3\s\src\libman\Program.cs:line 32
Aborted (core dumped)
Additional context
libman --version
2.1.113+g422d40002e.RR
These spots could be changed to validate before calling Path.Combine:
src/LibraryManager/Cache/CacheService.cs:46: CacheFolderValue = Path.Combine(localAppData, ".librarymanager", "cache");
src/LibraryManager/Configuration/Settings.cs:97: return Path.Combine(Environment.ExpandEnvironmentVariables(envVar), ".librarymanager");
https://github.com/NuGet/Home/issues/6989
https://newbedev.com/dotnet-build-permission-denied-in-docker-container-running-jenkins
https://blog.jongallant.com/2018/09/solution-users-home-directory-could-not-be-determined/
https://stackoverflow.com/questions/53556623/dotnet-build-permission-denied-in-docker-container-running-jenkins
- Ngôn ngữ chính
- C#
- Star
- 485
- Fork
- 92
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của aspnet/LibraryManager
-
System.IO.IOException: The process cannot access the file because it is being used by another processCó thể đã có người làm @brecht-yperman-uz đã nhận 4 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
aspnet/LibraryManager#824 · 1 bình luận · 3 reaction ·
-
Add documentation about using `Microsoft.Web.LibraryManager.Build`Có thể đã có người làm @jimmylewis đã nhận 321 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
aspnet/LibraryManager#804 · 2 reaction ·
-
Changelog for 3.0.114Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 48/100
aspnet/LibraryManager#829 · 1 bình luận · 4 reaction ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
aspnet/LibraryManager#820 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
aspnet/LibraryManager#808 · 5 bình luận ·
Tất cả issue của aspnet/LibraryManager
Issue tương tự
-
enhancement needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
elastic/docs-builder#4495 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ASP.NET Core container quickstart: `docker-run: debug` task sample is missing its closing braceĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
microsoft/vscode-docs#10499 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
🌶️ hot chocolate
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
ChilliCream/graphql-platform#10567 ·
Maintainer thường phản hồi trong vòng 1 ngày