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

az bicep install incorrectly downloads musl binary #5040

Closed
benc-uk opened this issue Oct 31, 2021 · 6 comments · Fixed by Azure/azure-cli#20250
Closed

az bicep install incorrectly downloads musl binary #5040

benc-uk opened this issue Oct 31, 2021 · 6 comments · Fixed by Azure/azure-cli#20250
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request
Projects
Milestone

Comments

@benc-uk
Copy link

benc-uk commented Oct 31, 2021

Bicep version
Bicep CLI version 0.4.1008 (223b8d2)

Describe the bug

After installing Bicep addon to the Azure CLI, and running any az bicep command (or deploying a bicep template) results in the following error

Error loading shared library libz.so.1: No such file or directory (needed by /home/ben/.azure/bin/bicep)
Error loading shared library libgssapi_krb5.so.2: No such file or directory (needed by /home/ben/.azure/bin/bicep)
Error loading shared library libstdc++.so.6: No such file or directory (needed by /home/ben/.azure/bin/bicep)
Error loading shared library libgcc_s.so.1: No such file or directory (needed by /home/ben/.azure/bin/bicep)
Error relocating /home/ben/.azure/bin/bicep: deflateInit2_: symbol not found
Error relocating /home/ben/.azure/bin/bicep: _ZNKSt8__detail20_Prime_rehash_policy11_M_next_bktEm: symbol not found
Error relocating /home/ben/.azure/bin/bicep: _ZNSt6localeD1Ev: symbol not found

When I run bicep from the version I download from GitHub, it functions perfectly

When I examine the binary I notice the version downloaded by az is for /lib/ld-musl-x86_64.so.1

❯ file ~/.azure/bin/bicep
/home/ben/.azure/bin/bicep: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-x86_64.so.1, BuildID[sha1]=7a77090f49016d9e7520e235b4d7832bb37e49f5, stripped

The version I download directly from GitHub is for /lib64/ld-linux-x86-64.so.2

❯ file ~/.local/bin/bicep
/home/ben/.local/bin/bicep: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=d680f06887efefa6671495f12db4fa85ec838652, stripped, too many notes (256)

To Reproduce

  • Run rm ~/.azure/bin/bicep
  • Run az bicep install
  • Run az bicep version

Additional context
I am running Ubuntu 20.04.2 LTS under WSL2 (Windows 11 version 10.0.22000 Build 22000)

@ghost ghost added the Needs: Triage 🔍 label Oct 31, 2021
@benc-uk benc-uk changed the title az bicep install results in musl binary not compatible with Ubuntu az bicep install incorrectly downloads musl binary Oct 31, 2021
@shenglol
Copy link
Contributor

shenglol commented Nov 1, 2021

Hi @benc-uk, do you happen to have the musl package /lib/ld-musl-x86_64.so.1 installed on your Ubuntu? In Azure CLI we use the existence of the that package to determine if it is a Linux distribution using musl.

@benc-uk
Copy link
Author

benc-uk commented Nov 3, 2021

Yes I do have that file on my system

@shenglol
Copy link
Contributor

shenglol commented Nov 3, 2021

That explains it. I cannot think of a more robust way to detect Linux OS type, but on thing we can do is to add a parameter to the install command to let users specify which Bicep executable they want to install.

@alex-frankel alex-frankel added bug Something isn't working enhancement New feature or request and removed Needs: Triage 🔍 labels Nov 3, 2021
@alex-frankel
Copy link
Collaborator

add a parameter to the install command to let users specify which Bicep executable they want to install

@benc-uk -- would this cover it for you? is it ok if we would still install the "wrong" version by default for this case?

Exit criteria for resolving this issue needs to include documenting this case.

@alex-frankel alex-frankel added the documentation Improvements or additions to documentation label Nov 3, 2021
@alex-frankel alex-frankel added this to the v0.5 milestone Nov 3, 2021
@benc-uk
Copy link
Author

benc-uk commented Nov 4, 2021

Thanks for taking a look at this.
I think an extra argument / parameter on the command to override the version to be installed would be a good fix

@Skepfyr
Copy link

Skepfyr commented Feb 4, 2022

I've just hit this, and while the solution does work it's really hard to find. Would it be possible to improve the error message rather than just dumping a bunch of relocation errors?

@shenglol Would it be feasible for the cli to check what binary type it is, and then download whatever that is? I guess you'd end up looking at what python you have installed.

bmc-msft pushed a commit to bmc-msft/azure-cli that referenced this issue Jun 27, 2022
Installing the bicep command on systems using glibc that also have MUSL
installed generate errors at runtime (See Azure/bicep#5040)

This expands the MUSL detection logic to exclude systems with glibc,
which is the primary non-musl libc.
@Azure Azure locked as resolved and limited conversation to collaborators May 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request
Projects
4 participants