I am using Ruby in an introductory computer science class in Highschool.
Of course, to keep things simple, I would like all my students to use
the same Ruby version (1.9.3p194).
At school we use Ws machines and most of the students also use it
at home, but a few use Linux or OS X. Myself, I’m a convinced Linux user
so I do want to encourage my students to use a non-Ws operating
system.
Problem is I have never used OS X and need some help from you
experienced users out there:
it seems that by default Ruby is already installed on OS X, but in
the wrong (for our purposes) version, 1.8.7. I think the student
who pointed that out to me uses Mountain Lion (maybe Lion).
What would be the least painful option, in your opinion:
somehow uninstall the preinstalled version and install 1.9.3
(I fear this could break the system, assuming Ruby is
needed for some system tool(?) since it’s already installed)
install rvm
…?
tolerate that students use different versions
(this might mean higher effort for me when providing
unit tests for programming tasks etc.)
Don’t bother uninstalling. It’ll just come back in updates.mapple leaves
/usr/local completely alone, so edit /etc/paths to have /usr/local/bin
first. Then, install Xcode via the AppStore so you can compile ruby and
gems with c extensions. Then install Mac homebrew and use that to
install ruby 1.9. Rvm is nice in certain contexts but really isn’t
necessary and overly complicates things.
As a Mac OS X user, and fairly novice Ruby scripter, I would recommend
leaving
1.8 alone on the system. Simply have them install RVM, then use RVM to
install
Ruby 1.9.3 and manage the Ruby version on the computer. This is the
easiest way,
in my opinion, to install Ruby updates. In addition, if there is desire
to
revert back, it’s a simple switch in RVM.
@Ryan: How about gems in this setting? Would installation or usage of gems work
without additional adjustments?
yup… it should just work. I recommend gem update --system, but
that’s not strictly necessary. 1.9 ships with rubygems and homebrew
(unlike many linux distros) doesn’t cripple it. The other nice thing is
that going the homebrew route opens up a lot of other things to the
student (easy access to databases, editors, etc).
Don’t bother uninstalling. It’ll just come back in updates.mapple leaves
/usr/local completely alone, so edit /etc/paths to have /usr/local/bin first.
Then, install Xcode via the AppStore so you can compile ruby and gems with c
extensions. Then install Mac homebrew and use that to install ruby 1.9. Rvm is
nice in certain contexts but really isn’t necessary and overly complicates things.
Thanks Ryan and Wayne.
I slightly tend to avoiding rvm. I do use it, but I’m not sure whether
it would be too complicated from the students’ point of view.
@Ryan: How about gems in this setting? Would installation or usage of
gems work without additional adjustments?
@Wayne: Sounds easy… how smooth is the installation?
something more complex as well as error prone?
I see no error prone-ness. I’ve now done this on four different Mac OS X
installations using representing three different systems. I can do it
reliably with my eyes closed. m.
Actually the rbenv way is even more boom-done. Once he’s done the
installation once on his machine, the .rbenv folder is totally
self-contained. Ruby 1.9.3 is in it, and ready to run. So he has to do
is zip it up, put it where his students can download it, and say
“download this, unzip it in your Home folder, and name the unzipped
folder .rbenv.” No muss, no fuss.
On 2012-09-14, at 8:48 PM, Ryan D. [email protected] wrote:
Does a homebrew install put gems into /usr/local? And do you still have
to muck with your PATH?
Homebrew installs stuff under /usr/local/Cellar/// and
then installs symlinks into /usr/local/bin/ for the binaries, so you
don’t have to muck about with PATH.
As for gems, the formula contains the following:
# Put gem, site and vendor folders in the HOMEBREW_PREFIX
ruby_lib = HOMEBREW_PREFIX/"lib/ruby"
(ruby_lib/'site_ruby').mkpath
(ruby_lib/'vendor_ruby').mkpath
(ruby_lib/'gems').mkpath
(lib/'ruby').install_symlink ruby_lib/'site_ruby',
ruby_lib/'vendor_ruby',
ruby_lib/'gems'
(where HOMEBREW_PREFIX defaults to /usr/local, I believe). That is, I
believe /usr/local/lib/ruby/gems will be symlinked into the correct
place. However I haven’t actually installed ruby 1.9 on my Mac, as I
only use 1.8.
Does a homebrew install put gems into /usr/local? And do you still have
to muck with your PATH? I can’t remember. If ‘yes’ and ‘no’ then
homebrew is definitely the way to go I think. Anything else brings RVM
back into consideration.
RVM is the alternative route, but RVM can be crazy making. Homebrew and
RVM are not mutually compatible. A lot of the complexity of RVM can be
made manageable by http://unfiniti.com/software/mac/jewelrybox which I’m
using myself these days (which is why I can’t answer my own question
about the homebrew installation).
it seems that by default Ruby is already installed on OS X, but in
the wrong (for our purposes) version, 1.8.7. I think the student
who pointed that out to me uses Mountain Lion (maybe Lion).
What would be the least painful option, in your opinion:
Again, thanks for all suggestions. Here a late update on this post:
I did not recommend it but the student absolutely wanted to try RVM.
Up to now it works fine without any problems.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.