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

Fix 'required_ruby_version: unbound variable' #1373

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 14 additions & 15 deletions bin/setup
Expand Up @@ -17,7 +17,7 @@ provision-project() {

### DON'T MODIFY ANYTHING BELOW THIS LINE! #####################################

# This setup script was generated with setup_script_generator 0.2.7,
# This setup script was generated with setup_script_generator 0.3.1,
# available on RubyGems.
#
# To regenerate this section, install the gem and run:
Expand Down Expand Up @@ -190,20 +190,25 @@ provision-ruby() {
USE_BUNDLER_1=0

if [[ -f .tool-versions ]]; then
REQUIRED_RUBY_VERSION=$(cat .tool-versions | grep '^ruby ' | sed -Ee 's/^ruby (.+)$/\1/')
REQUIRED_RUBY_VERSION=$(cat .tool-versions | grep '^ruby ' | head -n 1 | sed -Ee 's/^ruby (.+)$/\1/')
elif [[ -f .ruby-version ]]; then
REQUIRED_RUBY_VERSION=$(cat .ruby-version)
else
error "You don't seem to have a Ruby version set in your project."
REQUIRED_RUBY_VERSION=$(cat .ruby-version | head -n 1 | sed -Ee 's/^ruby-([[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+)$/\1/')
fi

if [[ -z $REQUIRED_RUBY_VERSION ]]; then
error "Could not determine required Ruby version for this project."
print-wrapped "\
You'll need to create either a .tool-versions file or .ruby-version file in your
project before you can run this script."
Your project needs to include either a valid .tool-versions file with a 'ruby'
line or a valid .ruby-version file."
exit 1
fi

ensure-ruby-development-libraries-installed
ensure-ruby-installed
ensure-project-ruby-dependencies-installed

if [[ -f Gemfile ]]; then
ensure-project-ruby-dependencies-installed
fi
}

ensure-ruby-development-libraries-installed() {
Expand Down Expand Up @@ -236,12 +241,6 @@ ensure-ruby-installed() {
error "Please use chruby to install Ruby $REQUIRED_RUBY_VERSION!"
fi
fi
elif has-executable rvm; then
if ! (rvm list | grep $required_ruby_version'\>' &>/dev/null); then
banner "Installing Ruby $required_ruby_version with rvm"
rvm install $required_ruby_version
rvm use $required_ruby_version
fi
else
error "You don't seem to have a Ruby manager installed."
print-wrapped "\
Expand All @@ -262,7 +261,7 @@ ensure-project-ruby-dependencies-installed() {
banner 'Installing Ruby dependencies'

if [[ $USE_BUNDLER_1 -eq 1 ]] && (! has-bundler || ! [[ $(bundle -v) =~ '^Bundler version 1\.' ]]); then
gem install bundler -v '~> 1.0'
gem install bundler:'~> 1.0'
elif ! has-bundler; then
gem install bundler
fi
Expand Down