Rake Command not working after upgrade rails and ruby version - ruby

I am getting an error when i am running any sort of rake command , it is showing me
rake aborted!
no such file to load -- config/environment
I am trying to upgrade the ruby version from ruby 1.8.7 to ruby 1.9.2 and rails 2.3.11 to rails 3.0.9 and when i am trying to start the server it is showing me
Value assigned to config.time_zone not recognized.Run "rake -D time" for a list of tasks for finding appropriate time zone names. (RuntimeError)
I am using RVM for this upgrade
ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [i686-linux]
rails -v
Rails 3.0.9

You can't just upgrade from Rails 2 to 3 without some rather extensive preparation. All hell will break loose. Check out these Railscasts for starters:
http://railscasts.com/episodes/225-upgrading-to-rails-3-part-1
http://railscasts.com/episodes/226-upgrading-to-rails-3-part-2
http://railscasts.com/episodes/227-upgrading-to-rails-3-part-3
There might be newer resources out there. I'd also suggest to upgrade first ruby and then Rails, or vice versa, not both at the same time. Divide and conquer.

Peepcode Rails 3 Upgrade Handbook PDF
Rails Core suggestions: Plugin to run checks on your Rails 2.x/3.x to check for obvious upgrade points on the path to 3.0.

Related

How to control which version of Ruby gets used when running bundle

In ~/src/project/ containing all the files, I'm attempting to run bundle and bundle install, but it tells me I need a gem called "buff-extensions" and that gem installer requires Ruby version >= 2.2.0 to work properly.
When I ran ruby --version, it said Ruby 2.2.4p230 is being used when run from that directory.
I know there are several versions of Ruby on the machine in several places, and I'm struggling to follow the paths and figure out which technology is using which piece.
The Bundler docs spell this out:
You can specify the required version of Ruby in the Gemfile with ruby. If the Gemfile is loaded on a different Ruby version, Bundler will raise an exception with an explanation.
ruby '1.9.3'
What this means is that this app has a dependency to a Ruby VM that is ABI compatible with 1.9.3. If the version check does not match, Bundler will raise an exception. This will ensure the running code matches. You can be more specific with the :engine and :engine_version options.
ruby '1.9.3', :engine => 'jruby', :engine_version => '1.6.7'
I finally figured out the exact incantation in order to get the intended result, and I now realize the situation is unreasonable to expect any stranger to attempt to answer.
It involved chef, and I was supposed to run chef exec bundle.

"Could not find activesupport" when 3 versions installed

I'm just trying to use the simple career_builder gem and just get it imported by running the simple script:
require 'career_builder'
puts 'Hello world!'
and yet get the following error: /Library/Ruby/Site/2.0.0/rubygems/dependency.rb:315:in 'to_specs': Could not find 'activesupport' (~> 2.3.5) - did find: [activesupport-4.2.1,activesupport-3.1.12,activesupport-3.0.3] (Gem::LoadError)
I installed the gem with gem install career_builder and ran bundle install and even updated activesupport to the most recent version, but for some reason, the program can't find the newer version of activesupport. Does the gem require version 2.3.5?
http://guides.rubygems.org/patterns/
The ~>or 'twiddle-waka' is a ruby gems shortcut to specify the earliest version of the gem you can use without letting you go up to the next major release.
Your gem is being a bit unorthodox and also specifying a patch level.
So the gem_specification you're working with (activesupport' (~> 2.3.5)) really means minimum version of 2.3.5 maximum of the last patch released before 2.4.0.
The activesupport versions you have installed are all for subsequent major releases and won't work. Install something between 2.3.5 and 2.4.0 and you should be good to go.
Yes. It does require Active Support version >= 2.3.5 and < 2.4.0. All of your Active Support versions are > 2.4.0.
~> is called the spermy operator. See Meaning of tilde-greater-than (~>) in version requirement?
The gem has not been updated in 4 years, so it uses Rails 2.
FWIW, I don't think you'll have much luck getting it to work, so you may want to find a similar gem that works with Rails 4 and has been updated within the last few months.

Ruby on rails 4.1.6 + Capistrano 3: purge gems on deployment server

Hy guys,
I have a server with apache, passenger 4.0.50, ruby 2.1.2 (started with 1.9.3), RVM and dozen of ruby on rails 4.1.x apps.
RVM is used only to manage ruby versions.
Follows the bundler configuration for each app:
BUNDLE_FROZEN: '1'
BUNDLE_PATH: "/PATH/TO/DEPLOYED/APP/shared/bundle"
BUNDLE_WITHOUT: development:test
BUNDLE_DISABLE_SHARED_GEMS: '1'
In order to save disk space (a lot of space) I would like to remove old gems of each application using bundle clean
The idea is to keep 2 releases (capistrano) and to run the command before a new deploy in order to keep gems for the last release.
The problem is that gems installed whit ruby 1.9.3 are not removed.
Can you please confirm that:
Gems for ruby 2.1.2 are installed in /PATH/TO/DEPLOYED/APP/shared/bundle/ruby/2.1.0/gems
Gems for ruby 1.9.3 are installed in /PATH/TO/DEPLOYED/APP/shared/bundle/ruby/1.9.1/gems
I can remove directory /PATH/TO/DEPLOYED/APP/shared/bundle/ruby/1.9.1/gems since I'm not using ruby 1.9 anymore
Many thanks in advance for your help.
Mauro
You dont use ruby 1.9.x anymore, so just remove the gems directory for it.

Rails 3 continues to use ruby 1.8.7 even though "ruby -v" states 1.9.2

I have finished developing my app and am currently deploying it. I'm getting a weird error from one of my controllers:
syntax error, unexpected ':', expecting ')'
When I run it in my dev environment it works fine. The only difference I can see between dev/prod is that dev is is using Ruby 1.9.2 and Prod is using 1.8.7. In my naivete I thought "Oh I'll just upgrade to 1.9.2" - what I fool I've been. I used RVM, changed my path, started new terminal session and now can see ruby is at 1.9.2:
ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
which ruby
/usr/local/rvm/rubies/ruby-1.9.2-p290/bin/ruby
However, when I run a "rails s" my computer continues to use 1.8.7:
[2011-10-05 05:58:40] INFO WEBrick 1.3.1
[2011-10-05 05:58:40] INFO ruby 1.8.7 (2010-08-16) [x86_64-linux]
[2011-10-05 05:58:45] INFO WEBrick::HTTPServer#start: pid=32574 port=3000
What the what!!!? I hope someone can help me. I'm about 15 minutes away from moving to the country, and become a farmer!
Thanks in advance.
if you used sudo when installed it might be the reason
sudo passenger-install-apache2-module
uses system ruby. Try
passenger-install-apache2-module
which should produce proper config files.
Have you tried rvm reload ? sometimes when I get strange errors like that reloading rvm fixes it.

"require 'mongoid'" is very slow

Just opening irb and typing require 'mongoid' takes more than 5 seconds on my Macbook Air. Is it normal, and how can I speed this up ? It slows down a lot my Rails and Ruby apps launches.
I tried with versions 2.0.1 and 2.1.8, same result. Ruby version is ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-darwin10.6.0]
Thanks!
require 'mongoid'
Seems to be a call that takes long, indeed.
On my MacBook Pro (ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0]) it's taking about 5-7 seconds (I've tested it on irb).
Note that one interesting message I got was:
**Notice: C extension not loaded. This is required for optimum MongoDB
Ruby driver performance. You can install the extension as follows:
gem install bson_ext
If you continue to receive this message after installing, make sure
that the bson_ext gem is in your load path and that the bson_ext and
mongo gems are of the same version.
Installing that gem does not make the gem load faster but it seems to improve speed overall.
Bottom line: try to make that require only once and at the start of your application.

Resources