# Setting GMT into $PATH?

**URL:** <https://forum.generic-mapping-tools.org/t/setting-gmt-into-path/3034>\
**Category:** Q&A\
**Created:** [June 19, 2022, 8:33am UTC](https://forum.generic-mapping-tools.org/t/setting-gmt-into-path/3034 "2022-06-19T08:33:57Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![jocabo](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/jocabo/32/151_2.png) [@jocabo](https://forum.generic-mapping-tools.org/u/jocabo)\
**Post date:** [June 19, 2022, 8:33am UTC](https://forum.generic-mapping-tools.org/t/setting-gmt-into-path/3034/1 "2022-06-19T08:33:57Z")

</div>

Hi There,

Trying to set up a new MacBook Pro with GMT. If this question has been addressed already in the forum, please feel free to point me to it… I’ve searched but cannot find what I am looking for. Been using GMT a long time, but always have issues with set up as I can never remember what I did `n` years ago when I set up the previous machine. Presently working on a Windows machine through cygwin, so I haven’t had to set up a Mac in nearly 10 years (and yes, that old machine is still going, sort of…) Anyway, I digress…

Situation so far, I have downloaded installed and launched GMT 6.4 for the first time. I used the Application Bundles from the GitHub. Trying to get the GMT to be callable from other directories. I tried the commands below, but I am not sure what to do on (b)…

```
Note 1: If you want to use GMT outside of this terminal or in scripts, then follow these steps:
        a) export GMTHOME=/Applications/GMT-6.4.0.app/Contents/Resources
        b) prepend $GMTHOME/bin to your path
        c) export PROJ_LIB=$GMTHOME/share/proj
        d) export GS_LIB=$GMTHOME/share/ghostscript/Resource/Init
        e) export MAGICK_CONFIGURE_PATH=$GMTHOME/lib/GraphicsMagick/config

```

I did something (followed some instructions from somewhere on the web) and now when I go:

`echo $PATH`

I get:

`/Applications/GMT-6.3.0.app/Contents/Resources:/usr/local/bin:/usr/bin:/bin:/usr/sbin`

BUT when I try to do a GMT command in a different directory, I get:

```
> wainui:~ olas$ pscoast
> -bash: pscoast: command not found

```

So, what’s the ‘right’ way to get GMT to run from elsewhere?

Should I uninstall and install it using the home-brew route?

Any help appreciated.

Thanks,

-jose

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [June 19, 2022, 8:57am UTC](https://forum.generic-mapping-tools.org/t/setting-gmt-into-path/3034/2 "2022-06-19T08:57:16Z")

</div>

Hi Jose, if you wish to continue to run GMT4-style commands (no leading “gmt”) then see the sidebar item called [Migrating from an Earlier Version](https://docs.generic-mapping-tools.org/6.4/migrating.html) on how to handle the missing **gmt** command.

Also, if you installed 6.4 you will need to edit your init file (.bashrc, .bash\_profile, .profile, .cshrc or whatever) to change that 6.3 to 6.4 in the PATH.

---

<div class="post-metadata">

**Author:** ![jocabo](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/jocabo/32/151_2.png) [@jocabo](https://forum.generic-mapping-tools.org/u/jocabo)\
**Post date:** [June 19, 2022, 9:23am UTC](https://forum.generic-mapping-tools.org/t/setting-gmt-into-path/3034/3 "2022-06-19T09:23:48Z")

</div>

Hi Paul,

OK, yes, I get that. But I think I am still stuck on the

`b) prepend $GMTHOME/bin to your path`

part of the deal.

I did this:

```
olas@wainui ~ % GMTHOME=/Applications/GMT-6.4.0.app/Contents/Resources
olas@wainui ~ % echo $GMTHOME                                         
/Applications/GMT-6.4.0.app/Contents/Resources
olas@wainui ~ % export PATH=$PATH:$GMTHOME/bin
olas@wainui ~ % echo $PATH /opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/GMT-6.4.0.app/Contents/Resources/bin

```

So I see that the GMT is in the PATH. When I then go

`gmt coast` or  
`gmt` or  
`gmt pscoast`

I do indeed get the Information for that command.

However, if I quit the terminal and restart, the changes to the $PATH are lost…

what do I need to type to make it stick?

THANKS!

-Jose

---

<div class="post-metadata">

**Author:** ![jocabo](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/jocabo/32/151_2.png) [@jocabo](https://forum.generic-mapping-tools.org/u/jocabo)\
**Post date:** [June 19, 2022, 9:29am UTC](https://forum.generic-mapping-tools.org/t/setting-gmt-into-path/3034/4 "2022-06-19T09:29:48Z")

</div>

Another note, that was all in the zsh shell.

I switched terminal to be bash

from some previous fiddling I have:

```
wainui:~ olas$ echo $PATH
/Applications/GMT-6.3.0.app/Contents/Resources:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

```

not sure what I did to get the GMT part in there without the /bin at the end!

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [June 19, 2022, 9:38am UTC](https://forum.generic-mapping-tools.org/t/setting-gmt-into-path/3034/5 "2022-06-19T09:38:32Z")

</div>

See the list of init files I mentioned (.bashrc etc) and open in editor and make the changes in the file that mas the /Application/GMT-6.3.0.app entry (fix it so it ends with the bin dir). Then quit terminal and start it up again. Now the PATH will be updated.

---

<div class="post-metadata">

**Author:** ![jocabo](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/jocabo/32/151_2.png) [@jocabo](https://forum.generic-mapping-tools.org/u/jocabo)\
**Post date:** [June 19, 2022, 9:40am UTC](https://forum.generic-mapping-tools.org/t/setting-gmt-into-path/3034/6 "2022-06-19T09:40:17Z")

</div>

OK, now I have edited the `/.profile` file and added the `/bin` so `echo $PATH` gives me:

```
/Applications/GMT-6.3.0.app/Contents/Resources/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

```

but still no joy on the `gmt coast`

```
wainui:~ olas$ gmt
-bash: gmt: command not found

```

hmmm… I know I’m doing something dumb…

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [June 19, 2022, 9:51am UTC](https://forum.generic-mapping-tools.org/t/setting-gmt-into-path/3034/7 "2022-06-19T09:51:25Z")

</div>

I think bash needs .bash\_profile and .bashrc. I have no .profile myself and running bash,

---

<div class="post-metadata">

**Author:** ![jocabo](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/jocabo/32/151_2.png) [@jocabo](https://forum.generic-mapping-tools.org/u/jocabo)\
**Post date:** [June 19, 2022, 10:02am UTC](https://forum.generic-mapping-tools.org/t/setting-gmt-into-path/3034/8 "2022-06-19T10:02:42Z")

</div>

Paul: found my ‘duh!’.

I changed the ‘3’ to a ‘4’ and now it works. didn’t notice that it was on ‘3’. was a leftover from when I first tried a few days ago before you released 6.4. then I downloaded 6.4 and threw away 6.3, so yeah, that’s why…

As for the `/.profile` thing, I have no Idea, I saw it somewhere online, lost the link now.

but regardless, it worked.

Now to update my scripts! oof…

-jose

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [June 19, 2022, 10:12am UTC](https://forum.generic-mapping-tools.org/t/setting-gmt-into-path/3034/9 "2022-06-19T10:12:58Z")

</div>

See …share/tolls/gmt5syntax which promises to accept a GMT4 script and write out a GMT6 script. Might save some typing if it works as advertised.

---

<div class="post-metadata">

**Author:** ![jocabo](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/jocabo/32/151_2.png) [@jocabo](https://forum.generic-mapping-tools.org/u/jocabo)\
**Post date:** [June 19, 2022, 12:20pm UTC](https://forum.generic-mapping-tools.org/t/setting-gmt-into-path/3034/10 "2022-06-19T12:20:00Z")

</div>

> [@jocabo](#):
>
> ```auto
> Note 1: If you want to use GMT outside of this terminal or in scripts, then follow these steps:
> a) export GMTHOME=/Applications/GMT-6.4.0.app/Contents/Resources
> b) prepend $GMTHOME/bin to your path
> c) export PROJ_LIB=$GMTHOME/share/proj
> d) export GS_LIB=$GMTHOME/share/ghostscript/Resource/Init
> e) export MAGICK_CONFIGURE_PATH=$GMTHOME/lib/GraphicsMagick/config
> 
> ```

OK, now referring to items c, d and e above…

I got it all working, calling GMT from anywhere, so that is good,

I then modified my ancient script to add the ‘GMT’ bit before each command (still working in classic for now).

Everything runs fine but the `GMT psconvert` fails because I never ran items c, d or e above. I can see the plot I am making just fine in the .ps file

As a test, I ran those commands (a, c, d and e) in the terminal window where I was working, and after that, my GMT script worked great, I got the .png I was looking for.

but, as I suspected, when I quit terminal and started up again, those configurations were lost.

also, now I cannot replicate that behavior, i.e. running commands a, c, d, and e before running my script does not lead to successfully running GMT psconvert

do I put them in the .profile file as part of the $PATH? if so, I’m just not sure how that looks.

Thanks again, almost there!

-jose

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [June 19, 2022, 12:37pm UTC](https://forum.generic-mapping-tools.org/t/setting-gmt-into-path/3034/11 "2022-06-19T12:37:08Z")

</div>

Just copy those 4 export statements to your .profile (leaving out the a) b) etc) of course). Then quit terminal and restart.

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [June 19, 2022, 1:18pm UTC](https://forum.generic-mapping-tools.org/t/setting-gmt-into-path/3034/12 "2022-06-19T13:18:30Z")

</div>

> [@jocabo](#):
>
> `export PROJ_LIB=$GMTHOME/share/proj`

This should not be necessary (automatically found). If it was then it would be missing the export of `GDAL_DATA` dir.

---

<div class="post-metadata">

**Author:** ![jocabo](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/jocabo/32/151_2.png) [@jocabo](https://forum.generic-mapping-tools.org/u/jocabo)\
**Post date:** [June 19, 2022, 9:48pm UTC](https://forum.generic-mapping-tools.org/t/setting-gmt-into-path/3034/13 "2022-06-19T21:48:38Z")

</div>

Thanks Paul.

It is now working

In order to assist anyone else searching through the forum for this type of info, here is what I did:

Computer:  
MacBook Pro 2021 Model  
macOS Monterey (12.4)

1. Installed GMT 6.4 from application bundles, double clicked it from inside ‘Applications’ folder. It gives you the following notes/instructions:

"Note 1: If you want to use GMT outside of this terminal or in scripts, then follow these steps:  
a) export GMTHOME=/Applications/GMT-6.4.0.app/Contents/Resources  
b) prepend $GMTHOME/bin to your path  
c) export PROJ\_LIB=$GMTHOME/share/proj  
d) export GS\_LIB=$GMTHOME/share/ghostscript/Resource/Init  
e) export MAGICK\_CONFIGURE\_PATH=$GMTHOME/lib/GraphicsMagick/config

Note 2: GMT may use Ghostscript, GraphicsMagick, FFmpeg, and GDAL executables; see  
/Applications/GMT-6.4.0.app/Contents/Resources/share/Licenses for details."

To accomplish the above:

1. change the default shell to bash in the Terminal preferences (original default is zsh)
2. do: `nano /.profile` to edit the startup profile
3. type the following into the the .profile file:

`export GMTHOME=/Applications/GMT-6.4.0.app/Contents/Resources`  
`export PROJ_LIB=$GMTHOME/share/proj`  
`export GS_LIB=$GMTHOME/share/ghostscript/Resource/Init`  
`export MAGICK_CONFIGURE_PATH=$GMTHOME/lib/GraphicsMagick/config`  
`export PATH=$GMTHOME/bin:/opt/homebrew/bin:/opt/homebrew/sbin:$PATH`

1. save it
2. close open terminal windows and quit terminal
3. restart terminal, type in ‘GMT’ at the prompt and you should get all the GMT info in the terminal window

Then I:  
8) got one of my old scripts and appended ‘GMT’ before every classic module command  
9) ran it and it worked.

Hope this is helpful for someone.

All the best,

-jose

---

<div class="post-metadata">

**Author:** ![seisman](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/seisman/32/4_2.png) [@seisman](https://forum.generic-mapping-tools.org/u/seisman)\
**Post date:** [June 20, 2022, 12:18am UTC](https://forum.generic-mapping-tools.org/t/setting-gmt-into-path/3034/14 "2022-06-20T00:18:11Z")

</div>

> [@jocabo](#):
>
> change the default shell to bash in the Terminal preferences (original default is zsh)

You don’t have to change your default shell. The same steps work for zsh, except that `~/.zshrc` is the file you need to modify.
