1

I'm installing C# and dotnet 6.0 SDK in the Linux lubuntu 22.04 version.

Following recommendations from Microsoft documentation to install manually such as:

mkdir -p $HOME/dotnet && tar zxf dotnet-sdk-6.0.400-linux-x64.tar.gz -C $HOME/dotnet

export DOTNET_ROOT=$HOME/dotnet
export PATH=$PATH:$HOME/dotnet

The above script dotnet runs only in the session opened, it means if opened another terminal session, should run the same script again to use dotnet.

The same documentation recommends including the following script in the ~/.bashrc file:

export PATH=$PATH:$HOME/dotnet
export DOTNET_ROOT=$HOME/dotnet

But it isn't working anyway.

Previously I already used JAVA SDK at the same ~/.bashrc file, where I had a variable named PATH. I didn't find anything that explains to me whether this variable could subscribe another, how I wasn't using Java anymore, I deleted the lines that had Java variables. Although, it wasn't working. I found a similar issue here, but I'm already using the given solution.

The last attempt was to put quotation marks in the variable values, but nothing.

Has anyone already had a similar issue?

Kusalananda
  • 320,670
  • 36
  • 633
  • 936
Roge
  • 11
  • 1

1 Answers1

0

First, confirm that the path to the dotnet folder is correct. You can do this by either opening the file manager or by running ls -a1 --group-directories-first. If that looks okay, try adding this to your .bashrc:

export DOTNET_ROOT="/home/YOURUSER/dotnet"
export PATH="$DOTNET_ROOT:$PATH"

Close the terminal and reopen it, and type echo $PATH. In the result, it should be pointing to where dotnet is installed.


One part that wasn't clear about your question, though: do you have Java installed and want it in your $PATH again, alongside dotnet, or are you just wondering about how you can add more paths to your $PATH variable? If it's the latter, you can do that by separating the paths to the respective programs by using a colon (:). Please note that leaving trailing colons may pose a security risk.

export PATH="$DOTNET_ROOT:/home/YOURUSER/path/to/program1:/home/YOURUSER/path/to/program2:$PATH"

Yet another alternative would be to assign every path to a different variable and then call it into $PATH. Like this

export MY_PROGRAM1="path/to/program1"
export MY_PROGRAM2="path/to/program2"

export PATH=$MY_PROGRAM1:$MY_PROGRAM2:$PATH"

EDIT: reboot the machine to be 100% sure that everything worked.

telometto
  • 1,825
  • 2
  • 8
  • 29
  • Hey, thanks! I tried use your first suggestion but isn't works yet. When I type echo $PATH it isn't returning dotnet path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin About your second suggestion, I was wondering, but you already answer this question, and now Java works fine. – Roge Sep 06 '22 at 17:54
  • What happens if you type `which dotnet` in the terminal? I'm not familiar with dotnet, but if you know a package that dotnet provides, you can try `which ` to see if the console echoes the path the package is in. If the first doesn't work, I suspect something has gone wrong when you installed dotnet. – telometto Sep 06 '22 at 18:22
  • @Roge Is the dotnet folder hidden? Does it start with a dot (`.`)? If that's the case, you have to add the `.` to your path i.e. `export DOTNET_ROOT"/home/YOURUSER/.dotnet". – telometto Sep 06 '22 at 18:28
  • A few weeks ago I unistall dotnet and since then I was running only for the terminal session in which it was run, so I forgot that. Anyway I just already install and now I find dotnet folder with 'which dotnet' command, but it isnt works yet. See, whether dotnet it's installed on my desktop, only works runtime ASP.NET, but I need SDKS, when I tried run that command recommended in microsft docs, isn't works. Only works if dotnet doesn't installed. I tried again follow your suggestion after install dotnet again, but it didn't work. – Roge Sep 06 '22 at 20:07