Sdk: can't compile F# projects on microsoft/dotnet:2.1-sdk-alpine (bash dependency)

Created on 22 Jun 2018  路  14Comments  路  Source: dotnet/sdk

Steps to reproduce

docker run --rm microsoft/dotnet:2.1-sdk-alpine /usr/share/dotnet/sdk/2.1.301/FSharp/RunFsc.sh

Expected behavior

The F# compiler runs on published SDK image. A couple of simple solutions are:

  • install bash on the Alpine SDK image
  • change the shell script to not be bash specific
docker run --rm microsoft/dotnet:2.1-sdk-alpine sh /usr/share/dotnet/sdk/2.1.301/FSharp/RunFsc.sh
/usr/share/dotnet/sdk/2.1.301/FSharp/RunFsc.sh: line 9: syntax error: bad substitution

Actual behavior

env: can't execute 'bash': No such file or directory

I can't build any F# projects without installing bash first. Workaround:

docker run --rm microsoft/dotnet:2.1-sdk-alpine sh -c "apk update; apk add bash; /usr/share/dotnet/sdk/2.1.301/FSharp/RunFsc.sh"

Environment data

dotnet --info output:

cc @KevinRansom

Most helpful comment

that would need work in roslyn for csharp and vb

@livarcocc, can you point to those scripts in roslyn? I think it used to be through scripts, RunCsc and RunVb, but not anymore?

@svick, we don't need to write in Almquist shell Alpine. If the scripts are written in Unix/Bourne Shell with shebang #!/usr/bin/env sh, that just works in all distros of BSD, Linux, Mac, Solaris.


That is one of the reasons why many utilities out there such as npm use Unix/Bourne shell instead of bash. In .NET repos, bashism is a normal trait probably because it saves 10-15 minutes of figuring-out and coding time from devs who are new to Unix shells. It is also really a very poor excuse to shove bash down the throats of all consumers, even those who made a choice to use other shells. So please, do consider spending some time and updating the scripts (at least those that are shipped with product and related to runtime) to the common denominator, Unix Shell.

- #!/usr/bin/env bash
+ #!/usr/bin/env sh

... and then some changes in the file ...
... it is hard at first, then gets easier ...
... everything that is possible in bash is possible in sh with bit of an effort ...

This is really a thing to invest time on when you have widespread library/product. There are people in .NET who are trying to reduce amount of dependencies, this could be categories under that epic.

Then there are scripts under github.com/dotnet, that are fully Unix Shell compatible, but yet having bash shebang on the top.. This shows lack of interest/awareness.

At least effort could be started by avoiding bash in new scripts (in dotnet/arcade for example)..

re: https://github.com/Microsoft/omi/issues/497

cc @Petermarcu, @weshaggard

All 14 comments

Why are you invoking RunFsc directly? That file is not meant to be invoked like that. Why aren't you just invoking dotnet build? Which, I guess would fail as well. But in any case, using that script directly is neither recommended nor supported.

That was simply me pointing out the root cause. The error occurs when you use dotnet build

@MichaelSimons what is the proper way to track adding bash to the alpine docker imagine? We will need it for csharp as well and vb.

@livarcocc Do you actually need bash? Wouldn't it be better to rewrite the scripts so that they also work on the shell that's included in Alpine by default? (I believe it's Almquist shell.)

Sure, but that would need work in roslyn for csharp and vb and on the CLI for fsharp. I think we should do that, but meanwhile, I would like for things to work out for folks trying out alpine.

I would like to avoid adding anything to the Alpine images to work around product issues like this. The product should be fixed instead. Once bash is added to the Alpine image, we will not be able to remove it until the next major version. Given the goal of trying to keep the Alpine images as slim as possible, this would be counter productive.

We want the 2.1-runtime-alpine as slim as possible. We don't care if 2.1-sdk-alpine grows in size to accommodate a bash install. We do want the tools to work out of the box. Please add bash to the sdk until product removes it is a dependency.

that would need work in roslyn for csharp and vb

@livarcocc, can you point to those scripts in roslyn? I think it used to be through scripts, RunCsc and RunVb, but not anymore?

@svick, we don't need to write in Almquist shell Alpine. If the scripts are written in Unix/Bourne Shell with shebang #!/usr/bin/env sh, that just works in all distros of BSD, Linux, Mac, Solaris.


That is one of the reasons why many utilities out there such as npm use Unix/Bourne shell instead of bash. In .NET repos, bashism is a normal trait probably because it saves 10-15 minutes of figuring-out and coding time from devs who are new to Unix shells. It is also really a very poor excuse to shove bash down the throats of all consumers, even those who made a choice to use other shells. So please, do consider spending some time and updating the scripts (at least those that are shipped with product and related to runtime) to the common denominator, Unix Shell.

- #!/usr/bin/env bash
+ #!/usr/bin/env sh

... and then some changes in the file ...
... it is hard at first, then gets easier ...
... everything that is possible in bash is possible in sh with bit of an effort ...

This is really a thing to invest time on when you have widespread library/product. There are people in .NET who are trying to reduce amount of dependencies, this could be categories under that epic.

Then there are scripts under github.com/dotnet, that are fully Unix Shell compatible, but yet having bash shebang on the top.. This shows lack of interest/awareness.

At least effort could be started by avoiding bash in new scripts (in dotnet/arcade for example)..

re: https://github.com/Microsoft/omi/issues/497

cc @Petermarcu, @weshaggard

@livarcocc - Any update on this? Can you remove the bash dependency from the RunFsc.sh script and ensure the e2e UX on Alpine doesn't require bash? This is going to lead to the best Alpine experience for the end users.

@richlander

Also tagging @KevinRansom and @dsplaisted

And @agocke for the C#/VB compiler.

ping @KevinRansom and @agocke to comment on changes to the shell scripts.

I note this commit: https://github.com/Microsoft/visualfsharp/commit/5ae8597a4fe49f9ee496533c53e2dd44778e7c01

which would seem to avoid this issue in the future. Not sure when that version of the F# tooling would make its way into a dotnet core release.

This issue was moved to Microsoft/visualfsharp#6323

Was this page helpful?
0 / 5 - 0 ratings