Created
November 16, 2024 15:19
-
-
Save featheredtoast/dcf1506e018f6d33244f8dba3c6ff1cc to your computer and use it in GitHub Desktop.
find gem dependencies?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bundle show --paths | while IFS= read -r gem_path; do | |
extconf_files=$(find "$gem_path" -name 'extconf.rb') | |
if [[ -n "$extconf_files" ]]; then | |
echo "Checking dependencies for gem at: $gem_path" | |
grep 'have_library' $extconf_files | sed -E 's/.*have_library\("([^"]+)"\).*/\1/' | sort -u | |
echo "------------------------------------" | |
fi | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Check libraries for Linux | |
if [[ "$OSTYPE" == "linux-gnu"* ]]; then | |
bundle show --paths | while IFS= read -r gem_path; do | |
# Find .so files and check if any exist | |
if find "$gem_path" -name '*.so' | grep -q .; then | |
echo "Dependencies for gem at: $gem_path" | |
find "$gem_path" -name '*.so' -print0 | xargs -0 ldd | |
echo "------------------------------------" | |
fi | |
done | |
# Check libraries for macOS | |
elif [[ "$OSTYPE" == "darwin"* ]]; then | |
bundle show --paths | while IFS= read -r gem_path; do | |
# Find .bundle files and check if any exist | |
if find "$gem_path" -name '*.bundle' | grep -q .; then | |
echo "Dependencies for gem at: $gem_path" | |
find "$gem_path" -name '*.bundle' -print0 | xargs -0 otool -L | |
echo "------------------------------------" | |
fi | |
done | |
else | |
echo "Unsupported OS." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment