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

vscode from snap cannot see dotnet at /usr/bin/dotnet #1163

Closed
NJT145 opened this issue Aug 5, 2023 · 4 comments
Closed

vscode from snap cannot see dotnet at /usr/bin/dotnet #1163

NJT145 opened this issue Aug 5, 2023 · 4 comments

Comments

@NJT145
Copy link

NJT145 commented Aug 5, 2023

Repro steps:

Extension Version: 1.0.0
Error Message: .NET Acquisition Failed: Installation failed: Error: Command failed: "/home/anonymous/.vscode/extensions/ms-dotnettools.vscode-dotnet-runtime-1.6.0/dist/install scripts/dotnet-install.sh" -InstallDir "/home/anonymous/.config/Code/User/globalStorage/ms-dotnettools.vscode-dotnet-runtime/.dotnet/7.0.9" -Version 7.0.9 -Runtime dotnet
/bin/sh: 1: /home/anonymous/.vscode/extensions/ms-dotnettools.vscode-dotnet-runtime-1.6.0/dist/install scripts/dotnet-install.sh: Permission denied

Error Stack: Error: .NET Acquisition Failed: Installation failed: Error: Command failed: "/home/anonymous/.vscode/extensions/ms-dotnettools.vscode-dotnet-runtime-1.6.0/dist/install scripts/dotnet-install.sh" -InstallDir "/home/anonymous/.config/Code/User/globalStorage/ms-dotnettools.vscode-dotnet-runtime/.dotnet/7.0.9" -Version 7.0.9 -Runtime dotnet
/bin/sh: 1: /home/anonymous/.vscode/extensions/ms-dotnettools.vscode-dotnet-runtime-1.6.0/dist/install scripts/dotnet-install.sh: Permission denied

at /home/anonymous/.vscode/extensions/ms-dotnettools.vscode-dotnet-runtime-1.6.0/dist/extension.js:2:4766

DotNetAcquisition-ms-dotnettools.vscode-dotnet-runtime-1691238602004.txt

@NJT145 NJT145 changed the title vscode from snap cannot see dotnet at /usr/lib/dotnet/dotnet vscode from snap cannot see dotnet at /usr/bin/dotnet Aug 5, 2023
@NJT145
Copy link
Author

NJT145 commented Aug 5, 2023

I got my solution. here is my bash code to solve this issue:

if [ ! -d "/usr/share/dotnet" ]; then
    sudo mkdir /usr/share/dotnet
fi
sudo ln -s /usr/bin/dotnet /usr/share/dotnet/dotnet

@NJT145 NJT145 closed this as completed Aug 5, 2023
@NJT145 NJT145 reopened this Aug 7, 2023
@NJT145
Copy link
Author

NJT145 commented Aug 7, 2023

my solution may cause some more problems. Anyway to make this working with /usr/bin/dotnet ?

@baronfel
Copy link
Member

baronfel commented Aug 7, 2023

@NJT145
Copy link
Author

NJT145 commented Aug 8, 2023

Thanks. I removed all of them and installed all by following these issues at dotnet/core#7699 and dotnet/sdk#27129 .
Here is my bash code that solves all:

sudo apt remove --purge --autoremove 'aspnetcore*' 'dotnet*' 'netstandard*' 'powershell*'
sudo apt autoremove
sudo apt autoclean
sudo apt update
# https://github.com/dotnet/core/issues/7699#issuecomment-1452473797
# https://learn.microsoft.com/en-us/dotnet/core/install/linux-package-mixup?pivots=os-linux-ubuntu#whats-going-on
sudo sh -c "cat > /etc/apt/preferences.d/dotnet <<'EOF'
Package: dotnet*
Pin: origin packages.microsoft.com
Pin-Priority: -10
EOF"
sudo sh -c "cat > /etc/apt/preferences.d/aspnet <<'EOF'
Package: aspnet*
Pin: origin packages.microsoft.com
Pin-Priority: -10
EOF"
sudo sh -c "cat > /etc/apt/preferences.d/netstandard <<'EOF'
Package: netstandard*
Pin: origin packages.microsoft.com
Pin-Priority: -10
EOF"
sudo apt update

##*************************** dotNet Core
# https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu
# Get Ubuntu version
declare repo_version=$(if command -v lsb_release &> /dev/null; then lsb_release -r -s; else grep -oP '(?<=^VERSION_ID=).+' /etc/os-release | tr -d '"'; fi)
# Download Microsoft signing key and repository
wget https://packages.microsoft.com/config/ubuntu/$repo_version/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
# Install Microsoft signing key and repository
sudo dpkg -i packages-microsoft-prod.deb
# Clean up
rm packages-microsoft-prod.deb
# Update packages
sudo apt update
sudo apt install -y aspnetcore-runtime-6.0 dotnet-runtime-6.0 dotnet-sdk-6.0
sudo apt install -y aspnetcore-runtime-7.0 dotnet-runtime-7.0 dotnet-sdk-7.0
##***************************

##*************************** PowerShell Core
##install script from https://learn.microsoft.com/en-us/powershell/scripting/install/install-ubuntu
# Update the list of packages
sudo apt-get update
# Install pre-requisite packages.
sudo apt-get install -y wget apt-transport-https software-properties-common
# Download the Microsoft repository GPG keys
wget -q "https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb"
# Register the Microsoft repository GPG keys
sudo dpkg -i packages-microsoft-prod.deb
# Delete the the Microsoft repository GPG keys file
rm packages-microsoft-prod.deb
# Update the list of packages after we added packages.microsoft.com
sudo apt-get update
# Install PowerShell
sudo apt-get install -y powershell
## Start PowerShell
#pwsh
##***************************

What I did is to uninstall all microsoft related packages at first, set apt preferences for dotnet* and aspnet* and netstandard*, and install all again. Simple, right....

@NJT145 NJT145 closed this as completed Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants