Skip to content

dotnet-install script causes shell to exit #25

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

Closed
JohnRusk opened this issue Sep 4, 2017 · 6 comments
Closed

dotnet-install script causes shell to exit #25

JohnRusk opened this issue Sep 4, 2017 · 6 comments
Assignees
Labels
maintenance-mode-prerequisite Maintenance mode prerequisites triaged

Comments

@JohnRusk
Copy link

JohnRusk commented Sep 4, 2017

Steps to reproduce

  1. Create an Ubuntu 16.04 VM in Azure
  2. Run the following:
  • wget https://dot.net/v1/dotnet-install.sh
  • chmod 700 dotnet-install.sh
  • source dotnet-install.sh --shared-runtime --version 1.1.2

Expected behavior

A message is displayed about missing dependencies (libuwind8 etc)

Actual behavior

It just exits my shell. Unless its a subshell, this results in my whole terminal window just closing.

Workaround

Install all the dependencies first, with sudo apt-get install curl libunwind8 gettext apt-transport-https

@johnbeisner
Copy link

@JohnRusk
I could not reproduce the failure. See attached file for the complete session text capture.
SessionTestCapture.txt

@omajid
Copy link
Member

omajid commented Sep 14, 2017

@johnbeisner The reporter mentioned that they only see this when the script fails - for example, when dependencies are missing.

The bug seems very real to me. I can reproduce it on my system too. Here is one way to see the error:

source ./scripts/obtain/dotnet-install.sh --runtime-id fedora.26-x64

(But source ./scripts/obtain/dotnet-install.sh --runtime-id fedora.24-x64 will work)

More interestingly, even if the script works, what happens when you run false after sourcing the script?

The script does set -e but never set +e. When the script is sourced, this leaks into the shell. Now any user command that fails will cause the shell to exit.

Here is a smaller reproducer for the issue:

#!/bin/bash
set -e
false

If you save this as exit-on-source and then do a source ./exit-on-source, your shell will exit.

@johnbeisner johnbeisner reopened this Sep 14, 2017
@masaeedu
Copy link

@johnbeisner I'm seeing this on Powershell as well. You can trivially reproduce it by running docker run -it --rm microsoft/dotnet-framework powershell, then run iwr -UseBasicParsing https://dot.net/v1/dotnet-install.ps1 | iex. This will end up killing the docker container. You can work around it by opening a sacrificial subshell, but then the path modifications are lost.

@JohnRusk
Copy link
Author

JohnRusk commented Oct 4, 2017

Just a note of another side effect of this issue. The scripts recently started checking another dependency (libcurl). For the users of my app, I'd written up instructions on how to install the necessary prerequisites. Now, there was a new prerequisite, not listed in my instructions. So bang!, the dotnet install script exited and closed their shell.

In other words, this issue magnifies the effect of any other change or problem that may be introduced to the script.

@johnbeisner johnbeisner removed their assignment Dec 23, 2019
@msftgits msftgits transferred this issue from dotnet/cli Jan 31, 2020
@bekir-ozturk bekir-ozturk transferred this issue from dotnet/sdk May 19, 2020
@donJoseLuis
Copy link
Contributor

@JohnRusk greetings. The side effect issue you mentioned is tracked in #36

Problem summary:

  • when the scripts (either PS1 or SH) run into trouble the container is killed

@vlada-shubina
Copy link
Member

We agreed not to fix the error handling when sourcing dotnet-install.sh script at the moment as it requires a lot of efforts for changing the error handling. As the workaround, the script can be launched in the subshell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance-mode-prerequisite Maintenance mode prerequisites triaged
Projects
None yet
Development

No branches or pull requests

8 participants