'How do I set up global Environment Variables in Garuda Linux?

I recently switched to Garuda Linux and was trying to set-up development environment for react-native. I just wanted to know how do I export my ANDROID_HOME within .baschrc for global environment variables. It uses pacman as package manager. I'm a total new to any Linux environment and I don't know anything about it's file system and commands. And yes I searched and tried almost all the methods I could find on this topic. I also asked this in the Garuda Forum but they just closed my topic without properly answering. I cannot seem to find what exactly I'm doing wrong. Please help and guide me through the steps.



Solution 1:[1]

You'll want to add these lines to one of your environment configs:

export ANDROID_HOME=/path/to/your/android/sdk # change this
export PATH="$PATH:$ANDROID_HOME/tools"
export PATH="$PATH:$ANDROID_HOME/platform-tools"

The specific config will depend on how global you want it to be and how your configs are sourced, but in general:

Solution 2:[2]

Garuda uses fish by default. You can save your path in config.fish. For example, if I want to export environment variable for PHP, then I will have to write

set PATH $PATH /opt/lampp/bin:$PATH

And then paste this code to file config.fish. You can also paste code in ~/.profile. as fish's config is automatically set to read ~/.profile.

Similarly for android, it will probably like set ANDROID_HOME ~/.android # /opt/android-sdk

Also check out the fish docs & https://fishshell.com/docs/current/language.html#variables-export for more details.

Source - https://forum.garudalinux.org/t/how-to-add-set-enviroment-variables-or-paths-in-garuda/8777

Solution 3:[3]

You have to add the Environment variable in the system. well, you can use the above example. Here I am trying a different approach.

open terminal

sudo nano ~./bashrc

Save your variable in the file and save it.

# .bashrc file
export VAR="My permanent variable"

That's it

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 tdy
Solution 2
Solution 3 CodePerfectPlus