I am not a Linux user so this might be a easy fix but I have tried the following:
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin
for which I get the following result:dotnet-install: .NET Core SDK version 2.1.403 is already installed. dotnet-install: Adding to current process PATH:
/home/<!username!>/.dotnet
. Note: This change will be visible only when sourcing script. dotnet-install: Installation finished successfully.
. ~/.profile
to reload the profile,
but even after this when I run dotnet
I get the following error:Command 'dotnet' not found, but can be installed with: sudo snap install dotnet-sdk`
I was expecting the script to do everything and make dotnet
available.
TLDR: curl | bash
can not modify PATH
so it will not add dotnet
to your PATH
. You need to add dotnet
to your path manually. Add export PATH="$PATH:/home/<!username!>/.dotnet"
to your ~/.profile
(or ~/.bashrc
or equivalent) and log out and log back in.
Long version:
When you run a command in the shell (for example, bash), the shell tries to find an executible with the name in the all the paths listed in the environment variable PATH
. PATH
is generally set to something like /bin:/usr/bin
. So when you type a command like curl
, your shell looks in both /bin
and /usr/bin
for an executible file named curl
.
You can see what your PATH
is by doing env | grep PATH
or echo $PATH
.
The other important piece of information is how environment variables propagate. It's quite simple, actually:
What this means is that a program that you execute can not modify the environment variables of another random program. The shell actually provides a special command, export
to set its own environment variables (and any child processes it later creates will inherit those).
Note the output at the end of step 1.
Note: This change will be visible only when sourcing script.
If you run curl | bash
, it runs bash
as a child process. That child process can not modify the environment variables of the program that started it (the shell that invoked curl | bash
). So it can not modify PATH
to add the location of dotnet
to it. It even (helpfully) tells you that it can't.
In step 2, you are reloading ~/.profile
. But does it contain any commands to add dotnet
to PATH
? I dont think so. I know the dotnet-install.sh script has not historically added it. You need to add a line like
export PATH="$PATH:/home/<!username!>/.dotnet"
To your ~/.profile
(or ~/.bashrc
, or equivalent) manually.
Actually, I would write it as follows to make the change more portable to other users:
export PATH="$PATH:$HOME/.dotnet"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With