[Ubuntu] Fails to run when dotnet is installed outside ~/dotnet - System.ComponentModel.Win32Exception (2): An error occurred trying to start process

Aberta Para iniciantes
#354 2 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
62/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Stack de tecnologia
csharp, linux, ubuntu
Domínio
cli

Direção de pesquisa

Comece pelo stack trace, que aponta para DotNetRunner.Run em src/DotNetOutdated.Core/Services/DotNetRunner.cs (linha 29), que inicia o processo dotnet a partir de um caminho que assume ~/dotnet/dotnet. Leia como esse caminho é montado e depois reproduza o problema tornando o dotnet acessível apenas pelo PATH, por exemplo em /usr/share/dotnet. Está concluído quando a ferramenta encontra o executável ali, por exemplo resolvendo-o pelo PATH como sugere a issue, com um teste ou uma execução manual que confirme isso.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

Problem

I was getting the following error

Analyzing project(s)...Unhandled exception. System.ComponentModel.Win32Exception (2): An error occurred trying to start process '/home/i/dotnet/dotnet' 
with working directory '/home/mustakim/code/just-an-email'. No such file or directory                                                                                                                                                                                                                                         
   at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)     
   at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)                                                                                                                                                                                                                                                        
   at DotNetOutdated.Core.Services.DotNetRunner.Run(String workingDirectory, String[] arguments) in /home/runner/work/dotnet-outdated/dotnet-outdated/src/DotNetOutdated.Core/Services/DotNetRunner.cs:line 29                                                                                                                
   at DotNetOutdated.Core.Services.DependencyGraphService.GenerateDependencyGraph(String projectPath) in /home/runner/work/dotnet-outdated/dotnet-outdated/src/DotNetOutdated.Core/Services/DependencyGraphService.cs:line 30                                                                                                 
   at DotNetOutdated.Core.Services.ProjectAnalysisService.AnalyzeProject(String projectPath, Boolean runRestore, Boolean includeTransitiveDependencies, Int32 transitiveDepth) in /home/runner/work/dotnet-outdated/dotnet-outdated/src/DotNetOutdated.Core/Services/ProjectAnalysisService.cs:line 28                        
   at DotNetOutdated.Program.<OnExecute>b__74_0(String path) in /home/runner/work/dotnet-outdated/dotnet-outdated/src/DotNetOutdated/Program.cs:line 179                                                                                                                                                                      
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.ToList()                                                                                                                                                                                                                                                      
   at DotNetOutdated.Program.OnExecute(CommandLineApplication app, IConsole console) in /home/runner/work/dotnet-outdated/dotnet-outdated/src/DotNetOutdated/Program.cs:line 179                                                                                                                                              
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.InvokeAsync(MethodInfo method, Object instance, Object[] arguments)                                                                                                                                                                            
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.OnExecute(ConventionContext context, CancellationToken cancellationToken)                                                                                                                                                                      
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.<>c__DisplayClass0_0.<<Apply>b__0>d.MoveNext()                                                                                                                                                                                                 
--- End of stack trace from previous location ---                                                                                                                                                                                                                                                                             
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)                                                                                                                                                                                            
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)                                                                       
   at DotNetOutdated.Program.Main(String[] args) in /home/runner/work/dotnet-outdated/dotnet-outdated/src/DotNetOutdated/Program.cs:line 129 

From the error it was obvious that it's looking for dotnet executable in my home directory ~/dotnet/dotnet. However the default installation of dotnet is in /usr/share/dotnet folder (I installed it from the Microsoft package source by running sudo apt install dotnet-sdk-7.0) .

I fixed the issue by creating a softlink in the above folder.

Solution

cd ~/
ln -s /usr/share/dotnet dotnet

Suggestion

It would be nice if the tool detected the location of the dotnet executable. There might be better ways but the one I can think of is running which dotnet (in Linux + Mac) or where dotnet (in Windows) first that should return the path of the executable.

Linguagem predominante
C#
Estrelas
1.7k
Forks
172
Merge médio
1d 19h
PRs com merge (30d)
39

Preparar o ambiente

Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de dotnet-outdated/dotnet-outdated

Todas as issues de dotnet-outdated/dotnet-outdated

Issues semelhantes

Mais issues de C#

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.