Jun's Blog

Output, activities, memo and etc.

Install Ruby v2.3.0 to check its new features

Install Ruby v2.3.0 from source

Ruby source code is managed by SVN server.
But this time I will use Github mirror.

At first, I will do fork ruby source from original source of github to my repository of github, as I may modify it later.

And download (git clone) it.

$ git clone https://github.com/junaruga/ruby.git
$ cd ruby

trunk branch is used as master branch, as it is managed by SVN.
ruby_X_Y branches are for back port.
Trunk's security fix is updated for the branches.

You can see the tag of github refer for target SVN tag.
https://bugs.ruby-lang.org/projects/ruby/wiki/HowToReleaseJa

% git tag v2_3_0 origin/tags/v2_3_0 && git push ruby v2_3_0

Also refer this release engineering page to check each branch's status.
https://bugs.ruby-lang.org/projects/ruby/wiki/ReleaseEngineering

$ git branch -r
  origin/HEAD -> origin/trunk
  origin/ruby_1_3
  origin/ruby_1_4
  origin/ruby_1_6
  origin/ruby_1_8
  origin/ruby_1_8_5
  origin/ruby_1_8_6
  origin/ruby_1_8_7
  origin/ruby_1_9_1
  origin/ruby_1_9_2
  origin/ruby_1_9_3
  origin/ruby_2_0_0
  origin/ruby_2_1
  origin/ruby_2_2
  origin/ruby_2_3
  origin/trunk
  origin/v1_0r
  origin/v1_1dev
  origin/v1_1r

To check recent tags.

$ git tag | grep '^v2_[23]'
v2_2_0
v2_2_0_preview1
v2_2_0_preview2
v2_2_0_rc1
v2_2_1
v2_2_2
v2_2_3
v2_2_4
v2_3_0
v2_3_0_preview1
v2_3_0_preview2

To release v2.3.0

$ git checkout v2_3_0
Note: checking out 'v2_3_0'.
...

$ git branch
* (detached from v2_3_0)
  trunk

Install

$ autoconf
$ ./configure --prefix=/usr/local/ruby-2.3.0 --with-openssl-dir=`brew --prefix openssl`
$ make
$ make install
$ /usr/local/ruby-2.3.0/bin/ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin13]

Try new features of v2.3.0

Watching this Matz's video to check new features of v2.3.0.
https://www.youtube.com/watch?v=E9bO1uqs4Oc&t=532

See for detail: NEWS-2.3.0: https://github.com/ruby/ruby/blob/trunk/doc/NEWS-2.3.0

did you mean

Case1
$ cat did_you_mean.rb
u = []
u.siz

Above code should be

$ /usr/local/ruby-2.3.0/bin/ruby did_you_mean.rb
# => undefinded method `siz` for []:Array (NoMethodError)
#    Did you mean?  size

But actually

$ /usr/local/ruby-2.3.0/bin/ruby did_you_mean.rb
did_you_mean.rb:2:in `<main>': undefined method `siz' for []:Array (NoMethodError)

...??

Case2
$ cat did_you_mean2.rb
"Yuki".starts_with?("Y")

Above code should be

# => NoMethodError: undefined method `starts_with?' for "Yuki":String
#    Did you mean?  start_with?

But actually

$ /usr/local/ruby-2.3.0/bin/ruby did_you_mean2.rb
did_you_mean2.rb:1:in `<main>': undefined method `starts_with?' for "Yuki":String (NoMethodError)

...???

$ /usr/local/ruby-2.3.0/bin/ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin13]

Well...

Install Ruby v2.3.0 on rbenv

As the ruby installed from source was not run, like I expected, I will install Ruby v2.3.0 on rbenv.

$ rbenv install 2.3.0
  => 2.3.0 was not displayed.

Upgrade rbenv, seeing below pages.

https://github.com/rbenv/rbenv#upgrading
https://github.com/rbenv/ruby-build/releases

$ rbenv -v
rbenv 0.4.0

$ brew update
$ brew upgrade rbenv ruby-build

$ rbenv -v
rbenv 1.0.0

$ rbenv install -l | grep '2.3.0'
  2.3.0-dev
  2.3.0-preview1
  2.3.0-preview2
  2.3.0
  rbx-2.3.0

$ rbenv install 2.3.0

$ rbenv versions
...
  2.3.0

$ rbenv shell 2.3.0
$ ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin13]

Case1

$ ruby did_you_mean.rb
did_you_mean.rb:2:in `<main>': undefined method `siz' for []:Array (NoMethodError)
Did you mean?  size

Success!

Case2
$ ruby did_you_mean2.rb
did_you_mean2.rb:1:in `<main>': undefined method `starts_with?' for "Yuki":String (NoMethodError)
Did you mean?  start_with?

Success!

Check the difference of Ruby on rbenv, and compiled from source.

Well, completely same version for both Rubys.
It depends on configure or make options?

$ rbenv shell 2.3.0

$ which ruby
/Users/jun.aruga/.rbenv/shims/ruby

$ ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin13]

$ /usr/local/ruby-2.3.0/bin/ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin13]

Try configure & make again, referring below official release way document.

https://bugs.ruby-lang.org/projects/ruby/wiki/HowToReleaseJa
% ../../src/ruby_2_3/configure --disable-install-doc --enable-shared --without-tk --with-opt-dir=/usr/local --prefix=/home/naruse/local/ruby_2_3
% make Makefile;make Makefile&&make -j8 install-nodoc

However did_you_mean feature is not available by default.

$ ./configure \
  --prefix=/usr/local/ruby-2.3.0 \
  --disable-install-doc \
  --enable-shared \
  --without-tk \
  --with-opt-dir=/usr/local \
  --with-openssl-dir=`brew --prefix openssl`

$ make Makefile; make Makefile && make -j8 install-nodoc

$ ls -d /usr/local/ruby-2.3.0/
/usr/local/ruby-2.3.0//

$ /usr/local/ruby-2.3.0/bin/ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin13]

$ /usr/local/ruby-2.3.0/bin/ruby did_you_mean.rb
did_you_mean.rb:2:in `<main>': undefined method `siz' for []:Array (NoMethodError)

Pending to solve this problem.