0

1 - In my Ruby environment which I built using rbenv, I have Ruby version 2.0.0-p247

Now I need to build Ruby version 1.8.7-p374 using the gem BigDecimal version 1.1.0.

but the BigDecimal gem's got two versions 1.2.0 and 1.1.0 and when I build Ruby version 1.8.7-p374 it selects the version 1.2.0

How do I force BigDecimal version 1.1.0 while compiling the Ruby?

2 - In another Ruby environment in another computer of mine, I have Ruby version 1.8.7-p374 and Rails v2.2.2 (they all work perfectly)

But I have two versions of 'rake' v10.1.0 v0.9.2 and in the Command Line I need to use the version 0.9.2 but the version 10.1.0 comes by default. How do I use the version 0.9.2 ?

Terry
  • 1,206
  • 1
  • 10
  • 26

1 Answers1

0

1) What you're saying doesn't make sense. The BigDecimal class is included with Ruby (you can see the source here https://github.com/ruby/ruby/tree/trunk/ext/bigdecimal ) so you shouldn't need the gem. What do you mean by "build ruby using the gem BigDecimal"? A gem doesn't help you build ruby. To build ruby, you basically just run ./configure; make. Your ruby 1.8.7 should get compiled with whatever version of the BigDecimal library is in the source code. After you build ruby and install it, then you should install rubygems and use that to install whatever versions of gems you want. Could you show us what command you are running and what the desired output is and what the actual output is, or just try to better explain what is going wrong?

2) Use bundler. You can write a Gemfile that specifies what version of rake you want to use and then do "bundle exec rake" to ensure that version is run.

David Grayson
  • 84,103
  • 24
  • 152
  • 189
  • 1 - I 'm trying to do what the user 'The tin man' has done here: [link](http://stackoverflow.com/questions/17204063/why-is-bundle-installing-the-wrong-version-for-bigdecimal-using-1-2-0) – Terry Dec 12 '13 at 10:17
  • OK. The link you sent makes a little more sense. That person has already built Ruby and now he is struggling with using Bundler. I think you might be using the word "build" incorrectly. Building refers to compiling the ruby interpreter itself, and you have to compile the ruby interpreter before you can do anything with gems. Anyway, it's still not clear to me what the problem is, so let's talk in concrete terms: how did you set up your environment, what commands are you running, and what results are you getting from those commands? – David Grayson Dec 12 '13 at 18:24
  • Are you familiar with Bundler and how it works? If you use it properly it should let you control what versions of the gems you are using. I think your question basically is an issue with bundler, so you should be showing us the exact contents of `Gemfile*` and what commands you are running. – David Grayson Dec 12 '13 at 18:27
  • 1 - I've given up trying to solve this one for now, because of the time constraints. It was a problem related to trying to use several versions of Ruby and Rails. I needed to use Rails 2.2.2 but I happened to install Rails 4.0 at first, so I tried to install Rails 2.2.2 and it required Ruby 1.8.7, and so on. Just given it up because I 've installed Ruby 1.8.7 in another computer anyway. – Terry Dec 13 '13 at 00:03
  • 2 - I must solve this one because I came across this one on the Rails 2.2.2 installation and I need to keep on using this version. I'm not familiar with Bundler and don't know how it works. I started to learn Rails for the last week and in the Rails tutorial book I follow there's this command: $ rake db:create RAILS_ENV='development' and the response is: RROR: 'rake/rdoctask' is obsolete and no longer supported. Use 'rdoc/task' (available in RDoc 2.4.2+) instead. The same problem: [link](http://stackoverflow.com/questions/15374249/error-rake-rdoctask-is-obsolete-and-no-longer-supported) – Terry Dec 13 '13 at 00:09
  • OK. Did you try the answer from the question you linked to? It seems reasonable: add "gem 'rake', '0.9.2'" to your Gemfile, then run "bundle install". Then whenever you need to run a rake command like "rake db:create" you need to write "bundle exec rake" instead of "rake". – David Grayson Dec 13 '13 at 00:43
  • Yes I applied all the steps. I created a file named Gemfile which contains "source 'https://rubygems.org' gem 'rake' '0.9.2'" but when I $bundle install , it returns: Fetching gem metadata from https://rubygems.org/.. Resolving dependencies... Could not find gem 'rake0.9.2 (>= 0) ruby' in the gems available on this machine. Though the gem list --local returns: ... rake (10.1.0, 0.9.2) Consequently $ bundle exec rake db:create RAILS_ENV='development' returns: Could not find gem 'rake0.9.2 (>= 0) ruby' in the gems available on this machine. Run `bundle install` to install missing gems. – Terry Dec 13 '13 at 12:46
  • You forgot the comma in your Gemfile after 'rake'. See how it is looking for a gem whose name is "rake0.9.2" and whose version number is at least 0? That's messed up. You should fix your Gemfile and make sure that "bundle install" succeeds before proceeding. – David Grayson Dec 13 '13 at 16:35
  • That's right, I missed the comma there. After correcting it, I started to get this error when I bundle exec rake db:create RAILS_ENV='development' Please `gem install -v=2.2.2 rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed. I tried the suggestions given in the error message but they didn't work. – Terry Dec 14 '13 at 15:01
  • Bundle prevents any gems from being loaded if they are not mentioned in the Gemfile and Gemfile.lock. You probably don't have rails in your Gemfile. You should put all the gems you are using in your Gemfile, run `bundle`, and try again. – David Grayson Dec 14 '13 at 19:56
  • That's a correct estimation. After I added 'rails' , '2.2.2' and 'mysql' '2.9.1' (because it complained about mysql) to the Gemfile, it (bundle exec rake) finally worked, that's fine. I think I should take a look at the bundle and Gemfile on the wiki. They are not mentioned in the book (Agile Web Development with Rails 2009 ediiton) I 've been reading. – Terry Dec 14 '13 at 21:34
  • The Rails world changes pretty fast. Rails 4 is already out. Unless you are trying to maintain a legacy Rails 2 app I would recommend a newer book and Rails 4. – David Grayson Dec 15 '13 at 02:36