I am working on a very old rails project. The gemfile is like this:
source 'http://rubygems.org'
gem 'rails', '2.3.17'
gem 'rake', '0.8.7'
gem 'rdoc', '3.6.1'
gem 'mysql', '2.8.1'
gem 'roo', '1.9.7'
gem 'rubyzip', '0.9.4'
gem 'pdf-writer', '1.1.8'
gem 'prawn', '0.12.0'
gem 'sendmail'
gem 'htmldoc', '0.2.3'
The ruby version is 1.8.7
What is the easy way to upgrade this rails app ? Can I just change the version of each gem to the latest one and expect it will work fine?
There is no easy way. Before You start upgrade you must add tests to be sure that application will still work after upgrade.
Then I recommend to change gem description to following syntax:
gem 'mysql', '~> 2.8.1' it tells bundler to update only last number of version of gem.
Then repeat following step
change rails version to next
bundle update rails
corrected conflicted gem version by hands
bundle update
Related
I want to upgrade an old legacy app from rails 5.0 to rails 5.1 then so on until rails 7
I have dockerized the app for easiness
please read the Gemfile, which gems are supported in Rails 7
terminal:
$ docker-compose run rails bundle install
terminal logs:
An error occurred while installing nio4r (2.5.8), and Bundler cannot continue.
In Gemfile:
rename was resolved to 1.0.8, which depends on
rails was resolved to 5.2.8.1, which depends on
actioncable was resolved to 5.2.8.1, which depends on
nio4r
this is my Gemfile: app/Gemfile
I have removed the Gemfile.lock to avoid conflicts in version that were locked
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem 'rails', '~> 5.1'
gem 'mysql2'
gem 'sassc'
gem 'sass'
# gem 'sass-rails', git:'https://github.com/sass/sassc-rails.git', branch: 'master'
gem 'sassc-rails'
gem 'uglifier'
gem 'coffee-rails'
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'turbolinks'
gem 'jquery-turbolinks'
gem 'js_cookie_rails'
gem 'jbuilder'
gem 'sdoc', group: :doc
gem 'rake'
gem 'kaminari'
gem 'slim-rails'
gem 'rack-user_agent'
gem 'gmail'
gem 'whenever'
gem 'actionpack-action_caching'
gem 'breadcrumbs_on_rails'
gem 'execjs'
gem 'ltsv-logger'
gem 'therubyracer'
# 問い合わせなどの画像認証
gem 'scout_apm'
gem "recaptcha", require: "recaptcha/rails"
gem 'sentry-raven'
gem 'faraday'
gem 'faraday_middleware'
gem 'config'
gem 'font-awesome-rails'
Are you working from the Rails guide for updating versions?
Don't start with Rails 7 in mind. Just do one minor version bump at a time (5.1, 5.2, 6.0 etc... you don't have to worry about patch numbers) and make sure it works in production before moving on.
Also, if there are changes that break in version x.x, you can usually make those changes in x.x-1 before you upgrade to x.x. I suggest doing as much as you can before you get to the point of upgrading Rails and other gems.
In this case, is your app already working with Rails 5.1 (and how have you evaluated that)?
Bundler is trying to install Rails 5.2 because rails '~> 5.1' will find the latest 5.x version that is equal or greater than 5.1. If you're not sure your app is working on 5.1 yet, start there by adding a patch version so you get the latest 5.1.x: `gem 'rails', '~> 5.1.0'.
Once you've got the version number right in your Gemfile, you're on to the next step of the guide:
Change the Rails version number in the Gemfile and run bundle update
(now do the rest of the steps)
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.
I get the following error issued by Phusion when loading a web page:
There was an error while trying to load the gem 'compass-rails'.
Gem Load Error is: undefined method `has?' for Sass::Util:Module
Did you mean? hash
Hash
Backtrace for gem load error is:
/Volumes/Data/htdocs/zetcho/vendor/bundle/gems/compass-0.12.2/lib/compass/sass_extensions/functions/urls.rb:5:in `has?'
The code at the indicated location is:
module Compass::SassExtensions::Functions::Urls
def self.has?(base, instance_method)
Sass::Util.has?(:instance_method, base, instance_method)
end
My gem file contains:
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.2'
# Use mysql as the database for Active Record
gem 'mysql2', '~> 0.3.18'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Compass for stylesheets
gem 'compass-rails'
# Use the Compass extension susy
gem "sprockets"
gem 'susy'
I've just created the Ruby on Rails site using Rails 5.1.2 and ruby 2.3.1. I have a much older site that works fine with the gem. Did I miss a step in the overall install or is this a bug with compass-rails?
I got the same error when I tried to add a controller:
rails generate controller home index
After more digging around, I found a similar problem. I fixed this one by changing the gem file to:
gem 'compass-rails', github: 'Compass/compass-rails'
Then:
rm gemfile.lock
bundle
It seems that the issue can be found in compass-rails 2.0.0. The version 3.0.2 seems to fix this issues. So a possible solution is :
# Gemfile
gem 'compass-rails', '~> 3.0.2'
Then bundle update compass-rails
This avoids targeting the compass-rails git master branch in favor of an actual release.
I came here having the same issue with a grunt compiling issue trying to use Compass/Sass, if this might help someone, my issue was caused because I had an updated version of Sass (sass-3.7.4) that was higher that the max-version compatible with compass, I uninstalled sass:
gem uninstall sass
Which in turn uninstalled compass, and reinstalled compass letting it choose the right version, and problem solved.
gem install compass
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
I developed a web in rails and it was working perfectly for months. Now I went to my web folder and started "rails server" but got the reply:
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
I really don't understand how rails could disappeared from my system, I am sure I haven't removed it. I was using rails 3.1 on a Mac. Any clues or suggestions?
Gemfile:
source 'rubygems.org';
gem 'rails', '3.1.0.rc5'
# gem 'rails', :git => 'git://github.com/rails/rails.git'
#group :test, :production do
# gem 'mysql', '5.1.58'
#end
#group :development do gem 'sqlite3'
#end
#gem install activerecord-mysql-adapter
gem 'json'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', "~> 3.1.0.rc"
gem 'coffee-rails', "~> 3.1.0.rc"
gem 'uglifier'
end
gem 'jquery-rails'
I have faced a similar problem.
I believe rails 3.1.0 is buggy, i myself tried my hands on it and reverted back to the stable version of rails i.e. anything but 3.1.0. It would have been better if you have installed RVM. With RVM you can have one or more rails version, in fact an entire gemset.
I myself have a global gemset and another gemset named rails1.
rvm gemset create gemset_name
Once you install the like of ruby and rails version you can set it default
rvm gemset default#gemset_name
I did this back then and it works fine on my end. More on RVM
Hope it helps.