Windows Bash (WSL) - sudo: no tty present and no askpass program specified
So silly, after looking further down I see a solution from Beorat:
To avoid the sudo tty issue and others, run these commands just before running do-release-upgrade:
sudo -S apt-mark hold sudosudo -S apt-mark hold procpssudo -S apt-mark hold strace
If you've already upgraded, run the above commands, then manually downgrade to the Trusty packages:
sudo -S wget http://mirrors.kernel.org/ubuntu/pool/main/s/sudo/sudo_1.8.9p5-1ubuntu1.1_amd64.debsudo -S wget http://mirrors.kernel.org/ubuntu/pool/main/p/procps/procps_3.3.9-1ubuntu2_amd64.debsudo -S wget http://mirrors.kernel.org/ubuntu/pool/main/s/strace/strace_4.8-1ubuntu5_amd64.debsudo -S dpkg -i sudo_1.8.9p5-1ubuntu1.1_amd64.debsudo -S dpkg -i procps_3.3.9-1ubuntu2_amd64.debsudo -S dpkg -i strace_4.8-1ubuntu5_amd64.deb
More info here: https://github.com/Microsoft/BashOnWindows/issues/482
WSL uses the lxrun executable for management from Windows:
lxrun -h
Usage: /install - Installs the subsystem Optional arguments: /y - Do not prompt user to accept /uninstall - Uninstalls the subsystem Optional arguments: /full - Perform a full uninstall /y - Do not prompt user to accept /setdefaultuser - Configures the subsystem user that bash will be launched as. If the user does not exist it will be created. Optional arguments: username - Supply the username /y - If username is supplied, do not prompt to create a password /update - Updates the subsystem's package index
Given that, you can use lxrun /setdefaultuser root
. Just thought I'd point out this side of it since it was required when I ran into the same issue as you after trying to upgrade to Xenial. I can confirm that running this command, then the wget / dpkg commands my issues were resolved.
The commands I used:
wget http://mirrors.kernel.org/ubuntu/pool/main/s/sudo/sudo_1.8.9p5-1ubuntu1.4_amd64.debwget http://mirrors.kernel.org/ubuntu/pool/main/p/procps/procps_3.3.9-1ubuntu2_amd64.debwget http://mirrors.kernel.org/ubuntu/pool/main/s/strace/strace_4.8-1ubuntu5_amd64.debdpkg -i sudo_1.8.9p5-1ubuntu1.4_amd64.debdpkg -i procps_3.3.9-1ubuntu2_amd64.debdpkg -i strace_4.8-1ubuntu5_amd64.deb
Finally, you might need to run sudo apt-get install -f
in case you get The following packages have unmet dependencies [xxx] but it is not going to be installed
I got rid of the error by moving /etc/hosts to /etc/hosts.bu. After closing the shell en opening again, /etc/hosts is recreated and your computer name is added. The error is gone (for me.)