Mac Forums

Mac Forums (http://www.mac-forums.com/forums/)
-   OS X - Development and Darwin (http://www.mac-forums.com/forums/os-x-development-darwin/)
-   -   Setting my environmental PATH (http://www.mac-forums.com/forums/os-x-development-darwin/201788-setting-my-environmental-path.html)

JayPea 05-12-2010 06:01 AM

Setting my environmental PATH
 
Hi guys,

I'm trying to install a 'pre-compiled binary release' through terminal. Basically I am being told to move the files 'cufflinks' and 'cuffcompare' binaries in your PATH environment variable.

So my question is what is the PATH environmental variable?

And how do I move these files to that?

I have looked elsewhere for the answer however I haven't found a suitable answer so far. Sorry for the newbie question.

Thanks very much, JP

xstep 05-13-2010 05:03 PM

It sounds like what you are being told is to add the path where cufflinks and cuffcompare are located to your PATH environment variable. This is done so that you can just type either of those names in the Terminal and the system can find them and execute them. Otherwise you have to type the full path to execute those executables.

How you set the path is dependent on the shell being used. The default shell for OS X is now Bash. To add a path to the PATH environment variable is done like this;
Code:

export PATH=$PATH:/Users/Shared
When you type a command that resides in that last path, you no longer have to type the whole path. Note also, that the shell searches through the paths in the order that they appear. This is important to know when you have two commands with the exact same name.

Do a 'man bash' in the Terminal and look under the 'INVOCATION' section. You'll note that if you add your export command to one of three possible login shell files, that you will not have to type that command every time you start the shell.

nabl 05-13-2010 05:10 PM

$PATH is a variable in the Terminal that tell the computer which directories contain programs; that is, when you type a command such as ls at the command-line, ls is the name of a program in one of the locations specified by $PATH.

To figure out where a binary is, you can use the which command. For example, typing which ls should return something like /bin/ls, which means that if you were to navigate to the /bin directory, you'd see the ls program within.

To see the list of locations that are currently set for $PATH, you can type echo $PATH at the command-line. It will return a list of directories (folders) separated by colons; these are the locations that will be checked in when you type a command name. In your case, you could copy those programs to a place like /usr/bin by typing the following command:
Code:

sudo cp program_name /usr/bin/
You'll need to type in your administrator password for the command to work because /usr/bin is a system directory (you get permission to move files there with the sudo command). This will copy the program you choose to that folder, at which point you can simply type its name and press Return to run it.



Alternatively, if you don't want to mess with using the sudo command (which you should always be extremely careful with), you can add a new directory to your $PATH, from which you'll be able to run commands in the future. To do this, you need to edit either .bashrc or .bash_profile. For example, type
Code:

open -a TextEdit ~/.bash_profile
This will open your Bash profile (think of it as command-line preferences) in TextEdit, where you can add this line to the bottom:
Code:

export PATH=$PATH:/new/directory
where /new/directory is the folder you want to add to your $PATH. For example, if you make a folder in your Home directory called Programs, you could run the command
Code:

export PATH=$PATH:/Users/your_username/Programs
and any binaries you put in that folder will run when you type their names at the command prompt.

Once you add that line to the file, save it and close it. For the change to take effect, type
Code:

source ~/.bash_profile
This command tells the computer to look at .bash_profile and update any changes, which will in this case update your $PATH. To make sure it took effect, you can type echo $PATH again, and you should see the same list you saw before with your new location at the end. Then, when you add any programs to the folder you chose (in this example, /Users/your_username/Programs), you'll simply be able to type their name at the command prompt and press Return to run them.



There's one final thing worth saying. If you only want to run a program once, you can navigate to the directory containing it and type the command name preceded by a period and a slash (./) to run the program regardless of whether the containing folder is in your $PATH or not. As an example, if your cuffs program is in your Downloads folder, typing the following two commands would run it a single time:
Code:

cd ~/Downloads
./cufflinks



Hopefully that little overview will help you out. :) If you want to find out more, search for "bash path" on a search engine and you should get relevant results.

JayPea 05-17-2010 06:31 AM

Thanks guys I managed to move the files prity successfully. Have got myself a UNIX book now aswell.

I have another problem now though:

I am trying to install another program it tells me to do this:

"To install TopHat, unpack the tarball and change to the package directory as follows:

tar zxvf tophat-1.0.7.tar.gz

cd tophat-1.0.7/

Now build the package:

./configure --prefix=/path/to/install/directory/

make

Finally, install TopHat:

make install"

I have tried to do this however it says there aren't the commands configure and make. I'm running bash on OS X Leopard on my Macbook Pro. Are 'make' and 'configure' not the commands used in bash?

Thanks, James

scathe 05-17-2010 07:23 AM

unless I'm mistaken, those commands come with the Mac OS Development kit

Download Xcode - Apple Developer

It can also be found on your Install Discs

vansmith 05-17-2010 07:34 AM

scathe is correct. You will need to install the Xcode developer tools to get all the tools you need to build programs. As scathe mentioned, take a look at your install discs or download it from Apple's developer website.

JayPea 05-17-2010 10:46 AM

Thanks guys, I have installed Xcode now and the 'make' cmd works. But it still doesn't recognise 'configure' as a command?

J

scathe 05-17-2010 11:41 AM

ok hold it, is there even a "configure" command? U sure it doesn't just refer to a file in the current directory with the name "configure"?

maybe it's just a file that doesn't have execute permissions? to add the execute permission run:
chmod +x filename
in this case chmod +x ./configure

first check if such file exists of course

vansmith 05-17-2010 03:07 PM

scathe is again correct - configure isn't a command/program but is a file included with many programs distributed as source. You need to execute it as such: ./configure. The ./ at the beginning signifies that the command is going to be executed from the current directory.

Note what you posted earlier:
Quote:

Originally Posted by JayPea (Post 1053662)
./configure --prefix=/path/to/install/directory/


JayPea 05-17-2010 03:31 PM

Thanks again scathe and vansmith. I did sort it out eventually. It was a file just a misplaced one, I did need the Xcode though.

Thanks a lot!

James

cradom 05-17-2010 10:53 PM

Also, for some stuff to install correctly you might have to use :
sudo make install
so it can install in places where you don't usually have permission to put things.
Depends on what you're installing and where it needs to go.


All times are GMT -4. The time now is 02:34 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.