Skip to content

Commit 542e4fd

Browse files
Improve network check for rubygems.org accessibility with retries and conditional gem installation
1 parent 511611c commit 542e4fd

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

test/ruby-rails-postgres/test.sh

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,22 @@ check "rails" rails --version
1616
check "rails installation path" gem which rails
1717
check "user has write permission to rvm gems" [ -w /usr/local/rvm/gems ]
1818
check "user has write permission to rvm gems default" [ -w /usr/local/rvm/gems/default ]
19-
# Check if we can reach rubygems.org before proceeding.
20-
# This uses curl to silently (-s) make a request to https://rubygems.org
21-
# Redirects output to /dev/null because we only care if the request succeeds, not the result itself.
22-
if ! curl -s https://rubygems.org > /dev/null; then
23-
echo "Network access to rubygems.org is unavailable. Please check network or proxy settings."
24-
exit 1
19+
20+
# This section verifies connectivity to rubygems.org and attempts to install a gem if reachable.
21+
can_reach_rubygems=false
22+
for i in 1 2 3 4 5; do
23+
if curl -fsSL --connect-timeout 10 --max-time 20 https://rubygems.org/ >/dev/null; then
24+
can_reach_rubygems=true
25+
break
26+
fi
27+
sleep $((i * 2))
28+
done
29+
30+
if [ "${can_reach_rubygems}" = "true" ]; then
31+
check "user can install gems" gem install --no-document github-markup
32+
else
33+
echo "WARN: Could not reach rubygems.org after retries; skipping gem install check."
2534
fi
26-
check "user can install gems" gem install github-markup
2735

2836
# Report result
2937
reportResults

0 commit comments

Comments
 (0)