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

Update method for finding latest ruby version #410

Closed
wants to merge 1 commit into from

Conversation

kenyonj
Copy link
Contributor

@kenyonj kenyonj commented Sep 16, 2015

This PR:

  • Finds the ruby version by curling the ruby-lang site

Why?

  • This allows us to stop maintaining a separate, possibly outdated, version url

mac
find_latest_ruby() {
local ruby_download_site="https://www.ruby-lang.org/en/downloads/"

fancy_echo "Find latest stable Ruby version ..."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finding

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 72dc852

@iwz
Copy link
Contributor

iwz commented Sep 16, 2015

Since we're using rbenv in the laptop script, maybe we could use rbenv install -l to list the available versions and grab the latest version from that list.

mac

fancy_echo "Find latest stable Ruby version ..."
curl -s $ruby_download_site | grep "Current stable:" -A 1 | grep "Ruby" |\
sed 's|</b>|-|g' | sed 's|<[^>]*>||g' | sed 's/Ruby //g'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I shortened this:

curl -s "$ruby_download_site" | sed -ne '/Current stable/{n; /Ruby/s/.*Ruby //; s/<.*//p}'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @mike-burns... any thoughts on going this route verse what @iwz suggested? Since this is parsing a webpage it seems like it might have more of a potential to break in the future.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ian's suggestion is probably better.

@kenyonj
Copy link
Contributor Author

kenyonj commented Sep 16, 2015

good idea @iwz

@ausmith
Copy link

ausmith commented Sep 16, 2015

👍 to offloading that to rbenv instead of doing it yourself!

@linkyndy
Copy link

linkyndy commented Oct 2, 2015

I agree, parsing rbenv install -l's versions is the way I see it too. However, it requires some shell ninjas to do the latest version matching :octocat:

@geoffharcourt
Copy link
Contributor

@kenyonj can you squash these into one commit? I'm soliciting more feedback, but I'd like to get this merged in.

@kenyonj kenyonj force-pushed the jk-new-way-of-getting-latest-ruby branch from 29408f4 to c299c1d Compare October 3, 2015 15:01
@kenyonj
Copy link
Contributor Author

kenyonj commented Oct 3, 2015

@geoffharcourt I've squashed, but I think it would probably good to explore finding the latest version through rbenv instead, however, I use chruby so I haven't experimented with that.

@croaky
Copy link
Contributor

croaky commented Oct 7, 2015

The "it works for RVM and chruby users" argument is appealing. Laptop is coupled to rbenv but it's not a library embedded in people's programs. Many users use Laptop in the following way:

  • Fork/clone
  • Read the script
  • Hack it up to their liking
  • Run it

I see the elegance of the rbenv install -l option, but I'm a little more drawn to the current approach's portability in the above scenario. Maybe a little less pretty under the hood but also less work for users?

@iwz
Copy link
Contributor

iwz commented Oct 7, 2015

@croaky but the script installs rbenv. I'm not an rbenv user, so I just removed all the rbenv stuff, installed RVM and my own ruby. no biggie for me.

However, in the default case where no modifications are made to the script, it may be possible to have a race condition where there's a new ruby released that isn't yet available on rbenv, and the script would fail. Unless rbenv is actually doing something similar to this script and just dynamically gets the latest ruby.

@tute
Copy link

tute commented Dec 21, 2015

Where do we serve curl -sSL http://ruby.thoughtbot.com/latest from? Right now it's 2.2.3 instead of 2.2.4.

@croaky
Copy link
Contributor

croaky commented Dec 29, 2015

@tute http://ruby.thoughtbot.com/latest is served from Fastly, backed by a single file on the thoughtbot-ruby S3 bucket. We update it by going to https://tbot.io/s3, signing in, updating the file, and purging the Fastly cache.

I've just updated it to 2.3.0.

@tute
Copy link

tute commented Dec 30, 2015

Thank you!

@croaky
Copy link
Contributor

croaky commented Jan 4, 2016

When I run the script in this branch, I get:

sed: 1: "/Current stable/{n; /Ru ...": bad flag in substitute command: '}'
(23) Failed writing body
failed

I've taken a stab at the rbenv method here:

#429

@croaky
Copy link
Contributor

croaky commented Jan 9, 2016

Went with the rbenv method in 36cd104

@croaky croaky closed this Jan 9, 2016
@croaky croaky deleted the jk-new-way-of-getting-latest-ruby branch January 9, 2016 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants