Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 8 commits into from
Jan 30, 2021

Conversation

seisman
Copy link
Member

@seisman seisman commented Jan 29, 2021

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
pygmt/clib/loading.py Outdated Show resolved Hide resolved
@seisman
Copy link
Member Author

seisman commented Jan 30, 2021

/format

Copy link
Member

@weiji14 weiji14 left a comment

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]>
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