Can't start Rails 3 app - ruby-on-rails

I have just configured dependencies for a simple Rails application using Gemfile, but I'm not able to start it anymore.
Here is the error message I get:
/Library/Ruby/Site/1.8/rubygems.rb:274:in `activate': can't activate rails (= 2.3.5, runtime) for [], already activated rails-3.0.4 for [] (Gem::LoadError)
from /Library/Ruby/Site/1.8/rubygems.rb:216:in `try_activate'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
...
The Gemfile is configured as follows
source :rubygems
gem 'rails', '3.0.4'
#gem 'rails', '2.3.5'
gem 'fastercsv', '1.5.4'
gem 'comma', '0.4.1'
and my environment.rb contains the following line
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '3.0.4' unless defined? RAILS_GEM_VERSION
Note that if I change that variable to 2.3.5, the server starts.
Any idea about what is causing the issue?

If you want to change an existing gemfile run: bundle update. Bundle install is only used for the initial setup. And by the way we are at 3.0.5 now. I am also wondering was this a rails 2 application? Did you simply swap out the gem version number and expect it to then become a rails 3 app? The environment.rb file in a rails 3 application does not show the rails gem version.

Related

How can I use SQLite 3 with RubyOnRails?

First, I'm bad at english, so I can't give a lot of details.. I've been trying to create a website using ruby on rails:
rails new azer
rails generate controller pages home
The last command doesn't work and there's an error occuring during generating:
/home/esteban/.rbenv/versions/2.4.4/lib/ruby/gems/2.4.0/gems/activerecord-4.2.10/lib/active_record/connection_adapters/connection_specification.rb:177: in
'rescue in spec': Specified 'sqlite3' for database adapter, but the
gem is not loaded. Add gem 'sqlite3' to your Gemfile (and ensure its
version is at the minimum required by ActiveRecord).(Gem::LoadError)
So I opened my gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.10'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
...
...
I'm unsure what might be the error cause thus I don't know how to proceed.
Versions:
Ruby 2.4.4
Rails 4.2.10
SQLite3 1.4.1.
EDIT : Thanks for your help everyone, I appreciate it ! I just tried to reinstall rails and it worked
It seems version 1.4.x won't work with Rails 4. Install version 1.3.13 instead:
Unisntall version 1.4.1:
gem uninstall sqlite3 -v1.4.1
Modify Gemfile:
gem 'sqlite3', '~> 1.3.13'
And run bundle install.

Active-sqlserver-adapter with Rails 5 application.

I am trying to set up a new application with rails 5. I have a half dozen applications working fine with rails 4.x.
When I try to do a bundle install, I get an error that starts with
Error:[rake --tasks] DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super. (called from <top (required)> at C:/Users/cmendla/RubymineProjects/user_message_console/config/application.rb:7)
DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super. (called from <top (required)> at C:/Users/cmendla/RubymineProjects/user_message_console/config/application.rb:7)
rake aborted!
Bundler::GemRequireError: There was an error while trying to load the gem 'activerecord-sqlserver-adapter'.
Gem Load Error is: undefined method `add_order!' for class `Class'
Backtrace for gem load error is:
If I do a bundle show activerecord I get
C:\Users\cmendla\RubymineProjects\user_message_console>bundle show activerecord
C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/activerecord-5.0.0.1
I've tried both a plain gem and a gem with different versions
gem 'tiny_tds'
# gem 'activerecord-sqlserver-adapter', '~> 5.0.0'
gem 'activerecord-sqlserver-adapter'
A bundle install shows an error code of 0
Using activerecord-sqlserver-adapter 2.3.8
(this is a partial list ).....
Using sprockets-rails 3.2.0
Using coffee-rails 4.2.1
Using jquery-rails 4.2.1
Using web-console 3.4.0
Using rails 5.0.0.1
Using sass-rails 5.0.6
Bundle complete! 14 Gemfile dependencies, 58 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
Process finished with exit code 0
But then I get the error that I posted above . There server I am using is server 2012
There is some info at https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/rails5 but it doesn't seem clear as to if I am loading the right gem version as that document references gem 'activerecord-sqlserver-adapter', '~> 4.2.0'
If anyone knows of compatibility issues between rails 5 and the ActiveRecord SQL Server Adapter, I can stay with rails 4.x for a bit. Otherwise, I'd like to try to get this working.
I had this problem recently. I solved it by adding the following to the gemfile:
gem 'activerecord-sqlserver-adapter', :github => 'rails-sqlserver/activerecord-sqlserver-adapter', :branch => 'master'

The bundle currently has rails locked at 3.2.12. whats to do?

I've changed in my gemfile the rails version from 3.2.12 to 4.2.0
then I got this error:
The bundle currently has rails locked at 3.2.12
so I tried bundle update / and bundle update rails ... but I got this:
Bundler could not find compatible versions for gem "rails":
In Gemfile:
prototype-rails (>= 0) ruby depends on
rails (~> 3.2) ruby
rails (4.2.0)
What do I have to do?
Update Gemfile:
source 'http://rubygems.org'
#gem 'rails', '3.2.12'
gem 'rails', '4.2.0'
gem "airbrake"
#gem "mysql"
gem 'mysql2', '~>0.3.7'
gem 'fastercsv'
gem 'newrelic_rpm', :group => [:production, :staging]
gem "xml-simple", :require => "xmlsimple"
gem "will_paginate", "~> 3.0.0"
gem "json", '1.7.7'
gem "default_value_for"
gem "whenever"
gem 'charlock_holmes'
gem 'prototype-rails'
gem 'rails_autolink'
group :development do
gem 'capistrano'
gem 'capistrano-ext'
end
Just run
bundle update
without telling to update just a specific gem (like rails). This allows bundler to find the lastest possible combination for all gems in the Gemfile.
The prototype-rails gem is not actively supported anymore. You should try to replace it as soon as possible (even if the latest version still works for you).
Furthermore: Multiple configuration settings have changed between Rails 3.2 and 4.2, you will have to change some of your config and core files. You also might want to read the Rails Guide: Upgrading Rails.
I suggest to upgrade your app in smaller steps (3.2 -> 4.0, 4.0 -> 4.1, 4.1 -> 4.2). Make sure that the app works in each step before you continue to the next. Also, watch out for deprecation warnings in the console or the logs.
remove your gemfile.lock
rm Gemfile.lock
then add
rails 4.2.0 in your Gemfile
then
bundle install
I think, the problem is in prototype-rails
https://github.com/rails/prototype-rails
Below Comment of prototype-rails gem
Unfortunately, due to limited manpower and resources, the Rails core team has not been able to confirm if this gem currently works with Rails 4.1 and above. If you have found any problems while upgrading your application, please report them at the issue tracker, or better yet, submit patches by sending a pull request.
Tried to remove first remove prototype-rails then run
bundle update

heroku - can't activate test-unit (= 1.2.3, runtime), already activated test-unit-2.3.1. Make sure all dependencies are added to Gemfile

I keep getting this error on heroku....here is my gemfile...what do i do
source 'http://rubygems.org'
gem 'rails', '2.3.8'
gem 'will_paginate', '2.3.12'
gem 'googlecharts'
# gem 'faker'
gem 'httparty'
gem 'bandsintown'
gem 'itunes-search-api','0.1.0', :path => 'vendor/gems/itunes-search-api-0.1.0'
gem 'i18n', '0.4.2'
gem "giggly", "~> 0.1.2"
gem "ruby-paypal",'0.0.5', :path => 'vendor/gems/ruby-paypal-0.0.5'
group :production do
gem 'test-unit', "2.3.1"
gem 'pg'
end
group :development, :test do
gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'
end
I tried taking it gem 'test-unit', "2.3.1" out and even leaving it without a specific version and I got this error...
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/file_utils.rb:84: warning: already initialized constant LN_SUPPORTED
rake/rdoctask is deprecated. Use rdoc/task instead (in RDoc 2.4.2+)
rake aborted
rake/rdoctask is deprecated. Use rdoc/task instead (in RDoc 2.4.2+)
rake aborted!
can't activate test-unit (= 1.2.3, runtime), already activated test-unit-2.3.1. Make sure all dependencies are added to Gemfile.
/usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/shared_helpers.rb:108:in `block in cripple_rubygems'
Now I am getting this error
/app/lib/tasks/rspec.rake:1:in `<top (required)>'
test-unit is not part of the bundle. Add it to Gemfile.
/usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/shared_helpers.rb:102:in `block in cripple_rubygems'
/app/lib/tasks/rspec.rake:1:in `<top (required)>'
I am so confused...on what to do next
To sum up:
no need of test-unit in production
remove the rspec rake task since you don't use rspec
For me, this error:
/app/lib/tasks/rspec.rake:1:in `<top (required)>'
test-unit is not part of the bundle. Add it to Gemfile.
started unexpectedly when I went to do some maintenance work on an old project. This was triggered by this line in the rspec rake task:
gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
In returning to this application, the default Ruby version was upgraded to 1.9. Using RVM to set this back to 1.8 (in my case under Jruby) eliminated this message and got me back going as before without the message.
Charles
An error like this can occur if your code loads some gems before Bundler is run and it happens to load a different version than is specified in Gemfile and Gemfile.lock. When Bundler is run later, it will detect that the wrong version of a gem has been loaded and raise this error. The solution is to make sure the Bundler.setup runs before any other gems are loaded. There are instructions on how to do this in Rails 2.3 on the bundler website, which you should follow:
http://gembundler.com/rails23.html

Heroku deployment using Mongo

Can someone tell me what I am doing wrong? I am trying to push a simple rails app to Heroku that uses MongoDB. My Gemfile contains the following line:
gem "mongo"
When pushing the app to Heroku it error's out with: no such file to load -- mongo
-----> Heroku receiving push
-----> Rails app detected
-----> Detected Rails is not set to serve static_assets
Installing rails3_serve_static_assets... done
-----> Gemfile detected, running Bundler version 1.0.3
Unresolved dependencies detected; Installing...
/usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- mongo (LoadError)
Here is my whole gemfile:
require 'rubygems'
require 'mongo'
source 'http://gemcutter.org'
gem "rails", "3.0.0"
#gem 'rails', :git => 'http://github.com/rails/rails.git'
gem "mongo_mapper"
gem 'mongoid', '2.0.0.beta.20'
gem 'devise', :git => 'git://github.com/plataformatec/devise.git'
gem 'heroku', '1.13.7'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
You dont need either of these lines in your Gemfile:
require 'rubygems'
require 'mongo'
Neither of those are required for bundler to update or install your gems.
Also, is there a reason why you're installing both mongoid and mongo_mapper?
Perhaps another approach that you can use, is to use something like https://mongolab.com, connect you application with the database on the cloud, and then make the deployment (only the rails application).I've been using MongoLabs for a while, and works pretty good, you can check your collections directly from there (you don't need to use the JS shell). This is just a suggestion, to make the deployment easier :)

Resources