Skip to content

Improve the error message when PyGMT fails to load the GMT library - #814

Merged
seisman merged 8 commits into
masterfrom
load-library-error
Jan 30, 2021
Merged

seisman merged 8 commits into
masterfrom
load-library-error

Conversation

@seisman

@seisman seisman commented Jan 29, 2021 •

Copy link
Copy Markdown
Member

Description of proposed changes

When PyGMT fails to load the GMT library, it raises an error:

GMTCLibNotFoundError: Error loading the GMT shared library '/opt/GMT-6.1.1/lib/libgmt.dylib'.

However, it's still unclear why it fails.

After this PR, the error message will contain the original error
message. For example:

GMTCLibNotFoundError: Error loading the GMT shared library '/opt/GMT-6.1.1/lib/libgmt.dylib'.
 dlopen(/opt/GMT-6.1.1/lib/libgmt.dylib, 6): Library not loaded: @rpath/libnetcdf.15.dylib
  Referenced from: /opt/GMT-6.1.1/lib/libgmt.6.1.1.dylib
  Reason: image not found.

Fixes #792.

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.

Notes

  • You can write /format in the first line of a comment to lint the code automatically

When PyGMT fails to load the GMT library, it raises an error:
```
GMTCLibNotFoundError: Error loading the GMT shared library '/opt/GMT-6.1.1/lib/libgmt.dylib'.
```
However, it's still unclear why it fails.

After this PR, the error message will contain the original error
message. For example:
```
GMTCLibNotFoundError: Error loading the GMT shared library '/opt/GMT-6.1.1/lib/libgmt.dylib'.
 dlopen(/opt/GMT-6.1.1/lib/libgmt.dylib, 6): Library not loaded: @rpath/libnetcdf.15.dylib
  Referenced from: /opt/GMT-6.1.1/lib/libgmt.6.1.1.dylib
  Reason: image not found.
```
@seisman seisman added the maintenance Boring but important stuff for the core devs label Jan 29, 2021
@seisman seisman added this to the 0.3.0 milestone Jan 29, 2021
@seisman
seisman requested review from a team January 29, 2021 03:11
Comment thread pygmt/clib/loading.py Resolved
@seisman

seisman commented Jan 30, 2021

Copy link
Copy Markdown
Member Author

/format

@weiji14 weiji14 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good (sorry about the Syntax Error!). I'll leave it up to you to decide whether to add the skip-changelog tag. Once this is done, we should look at finalizing #702 too.

@seisman seisman changed the title Display the original error message if failing to load the GMT library Improve the error message when PyGMT fails to load the GMT library Jan 30, 2021
@seisman
seisman merged commit ef628bc into master Jan 30, 2021
@seisman
seisman deleted the load-library-error branch January 30, 2021 05:15
sixy6e pushed a commit to sixy6e/pygmt that referenced this pull request Dec 21, 2022
…enericMappingTools#814)

When PyGMT fails to load the GMT library, it raises an error:
```
GMTCLibNotFoundError: Error loading the GMT shared library '/opt/GMT-6.1.1/lib/libgmt.dylib'.
```
However, it's still unclear why it fails.

After this PR, the error message will contain the original error
message. For example:
```
GMTCLibNotFoundError: Error loading the GMT shared library '/opt/GMT-6.1.1/lib/libgmt.dylib'.
 dlopen(/opt/GMT-6.1.1/lib/libgmt.dylib, 6): Library not loaded: @rpath/libnetcdf.15.dylib
  Referenced from: /opt/GMT-6.1.1/lib/libgmt.6.1.1.dylib
  Reason: image not found.
```

Co-authored-by: Wei Ji <[email protected]>

This branch was previously deployed

1 inactive deployment
Preview — 3cd70880 Deployed Jan 30, 2021 by vercel[bot]
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.

Improve error message when failing to load gmt library

2 participants