Questions tagged [ruby-2.0]

For issues relating to development in Ruby, version 2.0. If your question applies to Ruby in general, use the tag [ruby].

Ruby is a dynamic, open source programming language with a focus on simplicity and productivity. Ruby 2.0 was released Feb 24, 2013.

For information on Ruby in general, visit . And API documentation for Ruby 2.0.0.

The official release 2.0 announcement summarizes the changes as:

  • Language core features
    • Keyword arguments, which give flexibility to API design
    • Module#prepend, which is a new way to extend a class
    • A literal %i, which creates an array of symbols easily
    • __dir__, which returns the dirname of the file currently being executed
    • The UTF-8 default encoding, which make many magic comments omissible
  • Built-in libraries
    • Enumerable#lazy and Enumerator::Lazy, for (possibly infinite) lazy stream
    • Enumerator#size and Range#size, for lazy size evaluation
    • #to_h, which is a new convention for conversion to Hash
    • Onigmo, which is a new regexp engine (a fork of Oniguruma)
    • Asynchronous exception handling API
  • Debug support
    • DTrace support, which enables run-time diagnosis in production
    • TracePoint, which is an improved tracing API
  • Performance improvements
    • GC optimization by bitmap marking
    • Kernel#require optimization which makes Rails startup very fast
    • VM optimization such as method dispatch
    • Float operation optimization

In addition, albeit as an experimental feature, 2.0.0 includes Refinements, which adds a new concept to Ruby's modularity.

475 questions
149
votes
18 answers

cannot load such file -- bundler/setup (LoadError)

I'm setting Rails 4 application with Ruby 2.0, but I'm getting "Web application could not be started" and get this trace: cannot load such file -- bundler/setup (LoadError) …
Mr_Nizzle
  • 6,644
  • 12
  • 55
  • 85
139
votes
17 answers

Getting "Warning! PATH is not properly set up" when doing rvm use 2.0.0 --default

Above doesn't work first time, works 2nd time. Try to set ruby version to 2.0.0 for any new shell windows. Doing $ rvm use 2.0.0 --default gives Warning! PATH is not properly set up, '/home/durrantm/.rvm/gems/ruby-1.9.3-p125/ bin' is not at first…
Michael Durrant
  • 93,410
  • 97
  • 333
  • 497
82
votes
8 answers

-bash: __git_ps1: command not found

I tried to install Ruby 2.0. My command line urped and now looks like the following: -bash: __git_ps1: command not found [11:58:28][whatever@whatever ~]$ I have not a clue how to get rid of the __git_ps1: command not found error. I've searched my…
Joel Dehlin
  • 999
  • 1
  • 6
  • 9
67
votes
6 answers

How to install Ruby 2 on Ubuntu without RVM

I want to install ruby 2.0 using sudo apt-get install ruby2.0 But there isn't available package for ruby2.0 I want to install it using apt-get install the same like ruby 1.9.1 Any suggestions?
Mahmoud Khaled
  • 6,226
  • 6
  • 37
  • 42
59
votes
8 answers

"bin/rails: No such file or directory" w/ Ruby 2 & Rails 4 on Heroku

While following the Rails 4 Beta version of Michael Hartl's Ruby on Rails Tutorial, my app fails to start on Heroku, but runs fine locally with bundle exec rails server. Checking heroku logs -t reveals the following error: $ heroku[web.1]: State…
Justin Garrick
  • 14,767
  • 7
  • 41
  • 66
57
votes
9 answers

Named parameters in Ruby 2

I don't understand completely how named parameters in Ruby 2.0 work. def test(var1, var2, var3) puts "#{var1} #{var2} #{var3}" end test(var3:"var3-new", var1: 1111, var2: 2222) #wrong number of arguments (1 for 3) (ArgumentError) it's treated…
Alan Coromano
  • 24,958
  • 53
  • 135
  • 205
56
votes
1 answer

Unexpected Return (LocalJumpError)

What is the problem with this Ruby 2.0 code? p (1..8).collect{|denom| (1...denom).collect{|num| r = Rational(num, denom) if r > Rational(1, 3) and r < Rational(1, 2) return 1 else return 0 …
Eli Rose
  • 6,788
  • 8
  • 35
  • 55
48
votes
5 answers

Can I have required named parameters in Ruby 2.x?

Ruby 2.0 is adding named parameters, like this: def say(greeting: 'hi') puts greeting end say # => puts 'hi' say(greeting: 'howdy') # => puts 'howdy' How can I use named parameters without giving a default value, so that…
Nathan Long
  • 122,748
  • 97
  • 336
  • 451
47
votes
4 answers

Uninstalling all gems Ruby 2.0.0

It seems that ruby 2.0.0 has added "default" gems to the mix and makes them non removable by gem uninstall. How can you remove all non default gems?
Nathan Lilienthal
  • 864
  • 1
  • 10
  • 16
39
votes
1 answer

How to improve memory sharing between unicorn processes with Ruby 2.0 on Linux

Ruby 2.0 introduces a copy-on-write friendly garbage collector. My processes don't seem to keep memory shared for more than a few minutes - it seems to move from shared_dirty to private_dirty quite quickly. Some others have had success getting…
Kevin
  • 4,225
  • 2
  • 37
  • 40
35
votes
11 answers

Ruby on Rails - "Add 'gem sqlite3'' to your Gemfile"

I was following the Rails tutorial, but I got stuck when it said to type rails server in the blog directory. It states Specified 'sqlite3' for database adapter, but the gem is not loaded. Add gem 'sqlite3' to your Gemfile. I quit the server,…
hewhocomes
  • 441
  • 1
  • 4
  • 9
33
votes
2 answers

Garbage collector tuning in Ruby 2.0

I was wondering if the GC tuning used for ruby 1.9.x is still relevant in 2.0 with the new implementation of the GC. If so, are there any new things that we can configure on the new version? I am talking about the following…
Fernando Diaz Garrido
  • 3,995
  • 19
  • 22
32
votes
2 answers

What is the difference between 'include' and 'prepend' in Ruby?

From the Module Module#append_features(mod) → mod => When this module is included in another, Ruby calls append_features in this module, passing it the receiving module in mod. Ruby’s default implementation is to add the constants, methods, and…
Arup Rakshit
  • 116,827
  • 30
  • 260
  • 317
31
votes
1 answer

Comparability Issue rails 4 beta, ruby 2.0.0, mongoid

I am creating a test application using following versions of rails, ruby and mongoid. rails 4 beta ruby 2.0.0 mongoid 3.1.2 My GemFile looks like this gem 'rails', '4.0.0.beta1' ruby '2.0.0' gem 'mongoid', '~> 3.1.2' gem 'bson_ext' But when i run…
Zeeshan
  • 351
  • 4
  • 8
31
votes
4 answers

How to use the debugger with Ruby 2.0?

I know the debugger gem is not and never will be compatible with ruby 2.0 per "officially support ruby 2.X". In the changelog of Ruby 2.0 is: Debug support DTrace support, which enables run-time diagnosis in production TracePoint, which is an…
Intrepidd
  • 19,772
  • 6
  • 55
  • 63
1
2 3
31 32