Skip to content

Commit f940ef9

Browse files
committed
Install OpenSSL conditionally for Ruby 3.0
1 parent 66ee836 commit f940ef9

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

chunks/lang-ruby/Dockerfile

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,8 @@ ENV GEM_HOME=/home/gitpod/.rvm
1616
ENV GEM_PATH=$GEM_HOME:$GEM_PATH
1717
ENV PATH=/home/gitpod/.rvm/bin:$PATH
1818

19-
# the version of openssl changed in Jammy, some versions of Ruby need an older version
20-
# https://github.com/rvm/rvm/issues/5209#issuecomment-1114159447
21-
# another option: https://github.com/rvm/rvm/issues/5209#issuecomment-1134927685 or sudo apt install libssl-dev=1.1.1l-1ubuntu1.4
22-
RUN bash -lc " \
23-
rvm requirements \
24-
&& rvm pkg install openssl \
25-
&& rvm install ${RUBY_VERSION} --with-openssl-dir=$HOME/.rvm/usr --default \
26-
&& rvm alias create default $RUBY_VERSION \
27-
&& rvm rubygems current \
28-
&& gem install bundler --no-document \
29-
&& gem install solargraph --no-document"
19+
ADD ./install.sh /tmp
20+
RUN /tmp/install.sh $RUBY_VERSION
3021

3122
RUN echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*' >> /home/gitpod/.bashrc.d/70-ruby
3223
RUN echo "rvm_gems_path=/workspace/.rvm" > ~/.rvmrc

chunks/lang-ruby/install.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
RUBY_VERSION=$1
5+
6+
# the version of openssl changed in Jammy, Ruby 3.0 needs an older version
7+
# https://github.com/rvm/rvm/issues/5209#issuecomment-1114159447
8+
# another option: https://github.com/rvm/rvm/issues/5209#issuecomment-1134927685 or sudo apt install libssl-dev=1.1.1l-1ubuntu1.4
9+
if grep -q "3.0." <<<"${RUBY_VERSION}"; then
10+
bash -lc "
11+
rvm requirements \
12+
&& rvm pkg install openssl \
13+
&& rvm install \"${RUBY_VERSION}\" --with-openssl-dir=\"${HOME}\"/.rvm/usr --default \
14+
&& rvm alias create default \"${RUBY_VERSION}\" \
15+
&& rvm rubygems current \
16+
&& gem install bundler --no-document \
17+
&& gem install solargraph --no-document"
18+
else
19+
# Ruby 3.1 and higher do not
20+
bash -lc "
21+
rvm requirements \
22+
&& rvm install \"${RUBY_VERSION}\" --default \
23+
&& rvm alias create default \"${RUBY_VERSION}\" \
24+
&& rvm rubygems current \
25+
&& gem install bundler --no-document \
26+
&& gem install solargraph --no-document"
27+
fi

0 commit comments

Comments
 (0)