Here are several commands to inspect and modify rpath for both linux and macos.

Inspect rpath

macos: otool -l my.dylib
linux: readelf -d my.so

Inspect binary dependency

macos: otool -L my.dylib
linux: ldd my.so

Change rpath

macos: install_name_tool -change old new my.dylib
linux: patchelf --set-rpath old:new my.so