Feature #485

GMT_TMPDIR and DIR_TMP behavior

Added by Eduardo almost 4 years ago. Updated about 3 years ago.

Status:ClosedStart date:2014-01-07
Priority:NormalDue date:
Assignee:Remko% Done:

100%

Category:-
Target version:Candidate for next bugfix release
Platform:Linux

Description

  1. If GMT_TMPDIR is set and DIR_TMP is unset, gmt.history and gmt.conf both are created in GMT_TMPDIR.
  2. If both GMT_TMPDIR and DIR_TMP are set and it are the same, gmt.history and gmt.conf are created in GMT_TMPDIR.
  3. If both GMT_TMPDIR and DIR_TMP are set but it are different, gmt.conf is created in both directories (it differ in DIR_TMP variable) whereas gmt.history is created in GMT_TMPDIR.
  4. If GMT_TMPDIR is unset and DIR_TMP is set, gmt.history is created in the current working directory and gmt.conf is created en DIR_TMP

In debugging scripts case 3 is cumbersome and case 4 is dangerous.

Associated revisions

Revision 13556
Added by Remko about 3 years ago

For safety and logical reasons, DIR_TMP and DIR_USER have been removed as parameter settings.
Fixed issue #485

History

#1 Updated by Remko over 3 years ago

  • Assignee set to Remko

I see the point. 3 and 4 should not happen as they are.

The manpage of gmt.conf says the DIR_TMP overrides GMT_TMPDIR, just like DIR_DATA and DIR_USER override GMT_DATADIR and GMT_USERDIR.
Clearly that is not what happens, and that is because of the order of reading the environment variables and the gmt.conf file with respect of writing gmt.history.

This will need some analysis, but I think the different combinations should be:
  1. If GMT_TMPDIR is set and DIR_TMP is unset, gmt.history and gmt.conf both are created in GMT_TMPDIR.
  2. If both GMT_TMPDIR and DIR_TMP are set and are the same, gmt.history and gmt.conf are created in GMT_TMPDIR/DIR_TMP.
  3. If both GMT_TMPDIR and DIR_TMP are set but are different, gmt.history and gmt.conf should be created in DIR_TMP, since DIR_TMP overrides GMT_TMPDIR.
  4. If GMT_TMPDIR is unset and DIR_TMP is set, gmt.history and gmt.conf should be created in DIR_TMP, since DIR_TMP should act like GMT_TMPDIR.
  5. If neither GMT_TMPDIR nor DIR_TMP are set, gmt.history and gmt.cont should be created in the current working directory.

#2 Updated by Remko about 3 years ago

After some contemplation and studying of the code, it occurred to me that we either coded badly, or made the wrong choice about what should supersede what (environment variable or setting in gmt.conf).

Here is is my reasoning:
  1. We start the initialisation by reading the environment variables. This makes sense as we might need $GMT_SHAREDIR to find the fonts, etc.
  2. At this point we also get $GMT_USERDIR, $GMT_TMPDIR, $GMT_GSHHGDIR, $GMT_DCWDIR
  3. $GMT_USERDIR is going to tell us where to find the user's gmt.conf file, if any.
  4. Now in that file a different DIR_USER may be set. I think it is contrary to expectations that this overrules the environment variable. The environment variables were introduced to overrule the (system-wide) settings, not vice versa.
  5. Even more complicated is DIR_TMP and $GMT_TMPDIR. The latter is used to start isolation mode. I think it should not be in the gmt.conf file at all, but if so, $GMT_TMPDIR should overrule DIR_TMP, otherwise you would not be able to enter into isolation mode if DIR_TMP is (accidentally) set to . (the current directory).
  6. Another strike against having DIR_TMP in gmt.conf is what happens if you do gmtset in a directory that happens to have DIR_TMP set to somewhere. Then it will not change gmt.conf in that directory. Only manual intervention (editor) would be able to change it.
Hence I suggest the following remedies:
  1. Reverse the way in which environment variables and gmtdefaults overrule each other. The environment variable should always take precedence!
  2. For security, do not allow DIR_TMP to be part of gmt.conf, i.e. remove it from the gmtdefaults altogether.
  3. Update the manual to remove any trace of DIR_TMP. Isolation mode is explained with $GMT_TMPDIR so that would be no harm there.
  4. Update the manual to state that the environment variables overrule the gmtdefaults. I think that would be the expected behaviour anyhow.

#3 Updated by Remko about 3 years ago

  • Status changed from New to In Progress

#4 Updated by Paul about 3 years ago

I concur with all of your suggestions.

#5 Updated by Remko about 3 years ago

In fact, I realise that DIR_USER in gmt.conf also makes little sense.
  1. In the system-wide gmt.conf it will not be defined, otherwise it would not be a user directory.
  2. In order to find the user-dependent gmt.conf file where it may be specified differently, you already need to know DIR_USER
  3. This can only be useful for a gmt.conf file in the current working directory that points to another DIR_USER to get some other files (like CPT files)
  4. GMT uses the result of the environment variable $GMT_USERDIR or the default ~/.gmt long before reading gmt.conf (for PSL for example), so there will be conflicting expectations for where GMT finds things.
  5. Apart from .gmt_io all else is also looked for in DIR_DATA, so one can use that instead.

Again, this is confusing at best. DIR_USER has a practical default (~/.gmt) and can be set/overruled with the environment variable. To have it in gmt.conf which can be found generally by have DIR_USER set in the first place makes little sense.

#6 Updated by Paul about 3 years ago

I think after having added the other DIR_{DATA,GSHHG,DCW} we decided without too much thinking to add TMP and USER as well, just because. I agree they only serve to aid confusion.

#7 Updated by Remko about 3 years ago

  • Status changed from In Progress to Resolved
  • % Done changed from 0 to 100

DIR_TMP and DIR_USER have been removed from the parameter settings in r13556 (5.1.x) and r13557 (5.2.x)

#8 Updated by Paul about 3 years ago

  • Status changed from Resolved to Closed

Seems good, closing this issue.

Also available in: Atom PDF