Path Environment ~/.profile for android SDK

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
canado

Path Environment ~/.profile for android SDK

Post by canado »

Hi everyone

I'm trying to set my environment path in order to use the android SDK.
I've been trying to set the ~/.profile file with a lot of different possibilities + doing source ~/.profile + login in and out
all without success

my SDK is located in a directory named eclipse and that directory is located in home.

here is my file

Code: Select all

# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
	. "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH:/home/eclipse/sdk/tools:/home/eclipse/sdk/platform-tools"
fi


any help would be appreciated, thanks a lot

for info I tried
:/home/eclipse/sdk/tools
:$HOME/eclipse/sdk/tools
:$HOME/home/eclipse/sdk/tools
:~/home/eclipse/sdk/tools
:~/eclipse/sdk/tools
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
xenopeek
Level 25
Level 25
Posts: 29590
Joined: Wed Jul 06, 2011 3:58 am

Re: Path Environment ~/.profile for android SDK

Post by xenopeek »

Ahum. Perhaps read the lines surrounding the bit where you added your path (I'm assuming you can program, why else would you mess around with Android SDK :D). Highlighted in red the clue of the day, namely that the directory "bin" doesn't exist on a default installation of Linux Mint. This bit of code in the .profile file is there to automatically to your PATH the directory "bin", if you have created that directory in your home directory. Else it is of course skipped.
canado wrote:# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH:/home/eclipse/sdk/tools:/home/eclipse/sdk/platform-tools"
fi
I suggest you revert that piece of code and don't touch code in your .profile, but only add lines at the end.

Now you are being very unclear with the next bit.
canado wrote:my SDK is located in a directory named eclipse and that directory is located in home.
Have you the directory eclipse in your home directory (e.g., in /home/canado/eclipse), or in the home directory (i.e., in /home/eclipse). Check with your file manager where you have this directory, because you need to be exact. I hope it is in your home directory (e.g., in /home/canado/eclipse) and will proceed with that.

So to revert the changes you made and add the bits needed, this is what the lines I quoted above should be replaced with:

Code: Select all

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

# add Android SDK to PATH
PATH="$HOME/eclipse/sdk/tools:$HOME/eclipse/sdk/platform-tools:$PATH"
Image
canado

Re: Path Environment ~/.profile for android SDK

Post by canado »

Hi Vincent

Thanks for your reply

- Yes the bin directory exist so the path is applied (I tested it by copying an executable file inside bin)
- I didn't know I could chain the path, meaning I could do

PATH="$HOME/bin" and few lines later PATH="something else" and that all the parameters would be merged.

And to be more precise with my previous post, yes the sdk directory is in /home/canado/eclipse

I will try your line once home.
Thanks a lot for this quick reply. It's appreciated : )
canado

Re: Path Environment ~/.profile for android SDK

Post by canado »

Before I forget

In order to update the path, what is the procedure?
Should I do a source ~/.profile ?
Should I log out and then log in ?
Should I restart ?

Thanks
User avatar
xenopeek
Level 25
Level 25
Posts: 29590
Joined: Wed Jul 06, 2011 3:58 am

Re: Path Environment ~/.profile for android SDK

Post by xenopeek »

Log out and log in to activate changes is the most fool-proof way. And yes you can have multiple PATH assignments, as long as you include $PATH in each it will just keep adding and expanding PATH :wink:

I hope it works as I have shown, that should be correct given your clarifications.
Image
Locked

Return to “Scripts & Bash”