Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled exception: An error occurred trying to start process 'bash' with working directory '/app'. No such file or directory #1815

Closed
mcraiha opened this issue Jun 15, 2022 · 10 comments
Labels

Comments

@mcraiha
Copy link

mcraiha commented Jun 15, 2022

Describe the bug
I am trying to get Terminal.GUI based app to run on docker. Host is Ubuntu 20.04 under WSL, and target is Alpine Linux. I get error about bash, which I assume is not required with Alpine Linux.

The error is:

Unhandled exception. System.ComponentModel.Win32Exception (2): An error occurred trying to start process 'bash' with working directory '/app'. 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 System.Diagnostics.Process.Start()
   at Terminal.Gui.BashRunner.Run(String commandLine, Boolean output, String inputText, Boolean runCurses)
   at Terminal.Gui.CursesDriver.Is_WSL_Platform()
   at Terminal.Gui.CursesDriver.Init(Action terminalResized)
   at Terminal.Gui.Application.Init(Func`1 topLevelFactory, ConsoleDriver driver, IMainLoopDriver mainLoopDriver)
   at Terminal.Gui.Application.Init(ConsoleDriver driver, IMainLoopDriver mainLoopDriver)
   at WhisperDragonCLI.Program.Main(String[] args) in /source/Program.cs:line 42
Aborted

To Reproduce

  1. Clone repo https://github.com/mcraiha/WhisperDragonCLI
  2. Run docker build .
  3. Run docker image ls and get the image id
  4. Run docker run -it IMAGEID
  5. Try to execute the binary with ./WhisperDragon_CLI

Expected behavior
No crash / errors

@tznind
Copy link
Collaborator

tznind commented Jun 15, 2022

A workaround might be to set Application.UseSystemConsole to true?

@BDisp I see BashRunner is used for some clipboard stuff and here to detect WSL? Do you think its worth being more conservative about that e.g. detecting when those commands are failing and turning off those features at runtime? Looks like that pattern is already in place for the clipboard logic but is missing here?

We might also want a private flag so that when xclip or BashRunner fails we mark it as not working and don't try again?

@BDisp
Copy link
Collaborator

BDisp commented Jun 15, 2022

@BDisp I see BashRunner is used for some clipboard stuff and here to detect WSL?

Yes. It seems that Clipboard is detecting WSL where it use the pwsh.exe, but since it's a docker image it's a good idea to install xclip within the image. I need do investigate better that and some help would be nice. Both use the BashRunner to runs the commands.

@mcraiha
Copy link
Author

mcraiha commented Jun 16, 2022

A workaround might be to set Application.UseSystemConsole to true?

I tried both Application.UseSystemConsole = true; and Application.UseSystemConsole = false; before the Application.Init(); but same result.

@BDisp
Copy link
Collaborator

BDisp commented Jun 16, 2022

It has nothing to do with it. It will always give the same issue. I never managed to use gui.cs in a docker custom image with the exception of the .devcontainer which is included, but I only can use it with VS Code.

@tig tig added the bug label Jun 17, 2022
BDisp added a commit to BDisp/Terminal.Gui that referenced this issue Jun 19, 2022
@tig tig closed this as completed in 9b44004 Jun 20, 2022
@mcraiha
Copy link
Author

mcraiha commented Sep 24, 2022

I tried again today with 1.8.2 nuget release and I am still getting the same error.

@BDisp
Copy link
Collaborator

BDisp commented Sep 24, 2022

I tried again today with 1.8.2 nuget release and I am still getting the same error.

Can you share your ambient to check how you are getting the error, please?

@mcraiha
Copy link
Author

mcraiha commented Sep 24, 2022

If you mean the reproduction steps, they are the same as in my first post (the repo has been updated with newer .csproj file).

@BDisp
Copy link
Collaborator

BDisp commented Sep 24, 2022

RUN apk upgrade --no-cache && apk add --no-cache libgcc libstdc++ icu-libs ncurses && apk update && apk add bash

At least doesn't give the error but only black and white. It's needed to install more stuffs to the image.

@BDisp
Copy link
Collaborator

BDisp commented Sep 25, 2022

This Dockerfile works:

FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine3.16-amd64 AS build
WORKDIR /source

COPY src/. .
RUN dotnet publish -c release -r linux-musl-x64 --self-contained -o /app -p:PublishSingleFile=true -p:EnableCompressionInSingleFile=true

FROM alpine:3.16
RUN apk upgrade --no-cache && apk add --no-cache libgcc libstdc++ icu-libs ncurses && apk update && apk add bash
ENV TERM=xterm-256color
WORKDIR /app
COPY --from=build /app ./

There is only extras output after quit the app, because it isn't restoring the terminal defaults. But this only happens with this image. If you try on WSL or Linux VM this doesn't happens.

docker-image

@mcraiha
Copy link
Author

mcraiha commented Sep 25, 2022

Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants