Skip to content

Improve the error message for loading an old version of the GMT library#925

Merged
seisman merged 2 commits intomasterfrom
improve-check_libgmt
Feb 19, 2021
Merged

Improve the error message for loading an old version of the GMT library#925
seisman merged 2 commits intomasterfrom
improve-check_libgmt

Conversation

@seisman
Copy link
Member

@seisman seisman commented Feb 18, 2021

Description of proposed changes

See the forum post for context.

When multiple GMT versions are installed, PyGMT may incorrectly load the old version (e.g., GMT 5.4.5) and reports that it can't access a function GMT_xxx. As shown in the forum post, the error message is not helpful at all.

In this PR, we improve the error message:

  1. Show the library name libgmt._name (name or full path, depending on how the library was loaded) in the error message
  2. Mention that the possible cause is PyGMT is loading an old version of the GMT library

Now the error message is:

GMTCLibError: Error loading '/path/to/libgmt.so'. Couldn't access function GMT_Create_Session. Maybe loading an old version of the GMT shared library.

The test test_check_libgmt is also updated to check the improve message.

Fixes #

Reminders

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst.
  • Write detailed docstrings for all functions/methods.
  • If adding new functionality, add an example to docstrings or tutorials.

Slash Commands

You can write slash commands (/command) in the first line of a comment to perform
specific operations. Supported slash commands are:

  • /format: automatically format and lint the code
  • /test-gmt-dev: run full tests on the latest GMT development version

@seisman seisman added the maintenance Boring but important stuff for the core devs label Feb 18, 2021
@seisman seisman added this to the 0.3.1 milestone Feb 18, 2021
@seisman
Copy link
Member Author

seisman commented Feb 18, 2021

/test-gmt-dev

@seisman seisman requested a review from a team February 18, 2021 05:28
Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
@seisman seisman merged commit 0fd514e into master Feb 19, 2021
@seisman seisman deleted the improve-check_libgmt branch February 19, 2021 00:58
@seisman seisman changed the title Improve the error message for loading a old version of the GMT library Improve the error message for loading an old version of the GMT library Feb 19, 2021
sixy6e pushed a commit to sixy6e/pygmt that referenced this pull request Dec 21, 2022
GenericMappingTools#925)

Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Boring but important stuff for the core devs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants