Active_Model error in rails - ruby-on-rails

I went back to a rails project I was working on and the command "rails s" started to fail. The Terminal recommended that I run a bundle install. When I did I received the following message:
Bundler could not find compatible versions for gem "activemodel":
In Gemfile:
protected_attributes (>= 0) ruby depends on
activemodel (< 5.0, >= 4.0.0.beta) ruby
rails (>= 0) ruby depends on
activemodel (3.2.12)
I have updated both ruby and rails. I've re-installed active model and restarted my terminal.
My gems file is very simple:
gem 'rails'
gem 'jquery-rails'
gem 'devise'
gem 'simple_form'
gem 'protected_attributes'
group :production do
gem 'pg'
end
group :development, :test do
gem 'sqlite3'
end
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'bootstrap-sass', '~> 2.2.2.0'
gem 'bootstrap'
end

Remove your Gemfile.lock and run
rm Gemfile.lock
and
bundle install

Remove Gemfile.lock
and then bundle
if not works then specify rails version in gemfile.

have you tried running
gem update activemodel
or
bundle update

Bundler has attempted to install Rails 4 and associated gems, but you have some gems fixed at earlier incompatible versions. Either specify a 3.x.x version of Rails or remove the version requirements on your sass-rails and coffee-rails gems.
(I took your Gemfile into a sample application and attempted to run a bundle install--I didn't get the exact error you're seeing but an error of the same cause. Removing the version requirements on those gems solved the issue. Of course that may not be appropriate for your needs!)

Related

rails upgrading from 5.0.0.1 to rails rails 5.1 issues in installing gems

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)

Rail Can't find Railites - RBENV

RUBY 2.7.6
Bundler version 2.1.4
No matter what version of rails I use in the GEMFILE
I get the following error
undler could not find compatible versions for gem "railties":
In Gemfile:
rails (= 6.0.0) was resolved to 6.0.0, which depends on
railties (= 6.0.0)
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '6.1.0'
# Use mysql as the database for Active Record
gem 'mysql2', '~> 0.3.18'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
This is maybe because you have an outdated version of sass-rails.
Try the followings steps:
Remove gem versions for sass-rails from Gemfile.lock and run bundle update
If above didnt work, delete the Gemfile.lock and run bundle install, if you have no conflicting explicit gem version in your Gemfile to start with. So if this fails, remove version numbers from the Gemfile.
Hope this helps!

Upgrade rails from 4.2 to 5.2 dependencies issue

I'm doing this upgrade for the first time and I'm facing problem on very first step :-(
Basically I want to upgrade rails version of my project so I changed my Gemfile for the rails 5.2 and tried to run:
bundle update rails
as given here but I can not update bundle and am getting the following error
Bundler could not find compatible versions for gem "activerecord":
In Gemfile:
rails (~> 5.2) was resolved to 5.2.1.rc1, which depends on
activerecord (= 5.2.1.rc1)
schema_plus_views was resolved to 0.3.1, which depends on
activerecord (~> 4.2)
Bundler could not find compatible versions for gem "rails":
In Gemfile:
rails (~> 5.2)
gaffe was resolved to 1.2.0, which depends on
rails (>= 4.0.0)
rails_admin was resolved to 1.3.0, which depends on
rails (< 6, >= 4.0)
rails_admin_globalize_field was resolved to 0.4.0, which depends on
rails (>= 4.2)
sql-logging was resolved to 3.0.10, which depends on
rails (>= 4.0)
Bundler could not find compatible versions for gem "rake":
In Gemfile:
rake (~> 11.2)
capistrano (~> 3.6) was resolved to 3.11.0, which depends on
rake (>= 10.0.0)
derailed_benchmarks was resolved to 1.3.2, which depends on
rake (< 13, > 10)
My Gemfile is
source 'https://rubygems.org'
gem 'pg', platform: :ruby
gem 'schema_plus_views'
gem 'fix-db-schema-conflicts', github: 'davidlibrera/fix-db-schema-conflicts'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rake', '~> 11.2'
gem 'rails', '~> 4.2'
# gem 'rb-readline'
# Use postgresql as the database for Active Record
# Use SCSS for stylesheets
gem 'sass-rails'
gem "less-rails", platform: :ruby #Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails'
gem "typescript-rails"
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem "bootstrap-sass"
gem "font-awesome-rails"
gem 'haml'
# Use jquery as the JavaScript library
gem 'jquery-rails'
gem "bower-rails"
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
# gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'oj'
gem 'jbuilder'
gem 'angular-rails-templates'
gem 'gaffe'
gem 'color-generator'
# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1'
# we have keep redis client below version 4 until this issue is solved
# https://github.com/antirez/redis/issues/4272
# and we have to keep redis below 3.3.2 until this issue is solved
# https://github.com/redis/redis-rb/issues/650
gem 'redis', '3.3.5', require: %w(redis redis/connection/hiredis)
gem 'hiredis'
gem 'puma'
gem 'puma_worker_killer'
gem "dalli"
gem 'jbuilder_cache_multi'
gem 'globalize', '~> 5.0'
gem 'rack-attack'
gem 'ya2yaml'
gem 'cells-rails'
gem 'cells-erb'
# gem 'highline'
gem 'kaminari'
gem 'nokogiri'
gem 'zss', git: "https://github.com/ISEngineering/zmq-service-suite-ruby", platform: :ruby
gem 'ffi-rzmq', '2.0.4'
gem 'therubyracer'
gem "paperclip", "~> 4.3"
gem 'bootstrap-wysihtml5-rails'
gem 'rails-i18n', '~> 4.0'
# Excel depdendencies
gem 'xlsxtream', '>= 2'
# Excel legacy export
gem 'axlsx_rails', '0.5.1'
gem 'axlsx', git: 'https://github.com/randym/axlsx.git'
gem 'rubyzip', '>= 1.2.1'
gem 'zip-zip'
gem 'devise', '~> 4.2'
gem 'devise-i18n'
gem 'savon', '~> 2.10'
gem 'party_foul', git: 'https://github.com/alexanderadam/party_foul.git', branch: 'bugfix/132-dont-assume-that-exceptions-have-a-backtrace' #'>= 1.5.5'
gem 'ledermann-rails-settings'
gem 'dentaku'
gem 'delayed_job_active_record'
gem 'cancancan'
gem 'rolify'
gem 'rails_admin'
gem 'enumerize'
gem 'rails_admin_settings'
gem 'rails_admin_globalize_field'
gem 'trailblazer-rails'
gem 'premailer-rails'
gem 'bulk_insert'
# for assets that are referenced by libraries in vendor/assets
gem 'non-stupid-digest-assets'
gem 'actionpack-action_caching'
gem 'dotenv-rails'
group :development, :test do
gem 'database_cleaner'
gem 'rspec-rails'
gem 'pry'
gem 'pry-nav'
gem 'awesome_print'
gem 'mocha'
gem 'webmock' # for vcr
gem 'vcr'
gem 'chromedriver-helper', '>= 2.1.0'
gem 'selenium-webdriver', '3.9.0'
gem 'capybara'
end
group :test do
gem 'factory_bot_rails'
gem 'db-query-matchers'
gem 'capybara-screenshot'
gem 'fakeredis', require: 'fakeredis/rspec'
end
group :development do
gem 'i18n-tasks'
gem 'spring'
gem 'letter_opener'
gem 'derailed_benchmarks'
gem 'sql-logging'
gem 'rubocop'
gem 'rubocop-rspec'
gem 'fasterer'
gem 'better_errors'
gem 'binding_of_caller'
gem 'activerecord-colored_log_subscriber' # this won't be required with rails 5 anymore
# Use Capistrano for deployment
gem 'capistrano', '~> 3.6'
gem 'capistrano-rbenv', '~> 2.0'
gem 'capistrano-bundler', '~> 1.1.2'
gem 'capistrano-rails'
gem 'capistrano3-puma', github: "seuros/capistrano-puma"
gem 'capistrano3-delayed-job', '~> 1.0'
end
group :profile do
gem 'ruby-prof'
end
gem 'sdoc', group: :doc
gem 'sshkit' # is needed to load tasks on server
What should I do?
First, as ThorTL67 noted in the comments, it is a good idea to update your Rails version incrementally, not in one big leap. That way, your dependency issues will be less complex.
Check what version of Bundler you are using by running bundle version. If that version is old, it might be that some dependencies are not correctly calculated, and it might help to update Bundler (gem update bundler).
Then to the steps you can take to update from 4.2 to 'some higher version'. The list of errors that you got shows the conflicts between gem dependencies. You can try and tackle these conflicts one by one.
Bundler could not find compatible versions for gem "activerecord":
In Gemfile:
rails (~> 5.2) was resolved to 5.2.1.rc1, which depends on
activerecord (= 5.2.1.rc1)
schema_plus_views was resolved to 0.3.1, which depends on
activerecord (~> 4.2)
This error is pretty straightforward. It tells you that gem rails needs activerecord v5.2.1, but that gem schema_plus_views needs activerecord >= 4.2.0 but < 5.0 (see the RubyGems explanation of constraints). So how to resolve this? If you check the source page for schema_plus_views, you see that there is no compatible version yet for activerecord v5.2.1, and that it is not likely to be there soon: Any plan to update this gem to be compatible with rails 5.2?
So in this case, you have a few options. Leave it out of your Gemfile and remove the dependencies on this gem from your code; check for alternative gems that give you the needed functionality; help to update the gem to support rails 5.
Bundler could not find compatible versions for gem "rails":
In Gemfile:
rails (~> 5.2)
gaffe was resolved to 1.2.0, which depends on
rails (>= 4.0.0)
rails_admin was resolved to 1.3.0, which depends on
rails (< 6, >= 4.0)
rails_admin_globalize_field was resolved to 0.4.0, which depends on
rails (>= 4.2)
sql-logging was resolved to 3.0.10, which depends on
rails (>= 4.0)
I'm actually not sure what the problem is here. These dependencies on the rails gem do not seem to contradict each other, so I would try to find out what gem is the actual problem by commenting them out one by one and then trying the update again. This might give you more information.
Bundler could not find compatible versions for gem "rake":
In Gemfile:
rake (~> 11.2)
capistrano (~> 3.6) was resolved to 3.11.0, which depends on
rake (>= 10.0.0)
derailed_benchmarks was resolved to 1.3.2, which depends on
rake (< 13, > 10)
This also seems like it should not be a problem. I would try to change your rake dependency in your Gemfile from gem 'rake', '~> 11.2' to gem 'rake' and see what happens with the dependency messages.
Chances are that after all these steps, you will get different error messages. You have to tackle them one by one in the same manner. Unfortunately, there is no silver bullet, and updating Rails can be a tedious process, especially when your application depends on a lot of gems. You have to fix this, issue by issue, by removing your own dependencies on gems, helping gem communities with maintenance/updates, or (worst case) forking a gem and changing the code yourself to make it work again for your application. Good luck!
In order to update your dependencies, you can use tools like bummr. Please, be sure to have a good test suite as the README specify. After that, you can start fixing compatibility issues, deprecations and more.

Decoupling Gemfile bundle errors

Given a gemfile of :
source 'https://rubygems.org'
gem 'rails', '4.1.1'
group :development, :test do
gem 'railroady'
gem 'sqlite3'
gem 'jasmine'
# For linux support
gem 'therubyracer'
end
group :production do
gem 'pg'
gem 'thin'
end
gem 'sass-rails'
# gem 'coffee-rails'
gem 'uglifier', '>= 1.0.3'
gem 'colorize'
gem 'jquery-ui-rails'
gem 'jquery-rails'
gem 'rails-backbone'
# gem 'backbone-on-rails'
gem 'bootstrap-sass'
gem 'requirejs-rails', git: 'git://github.com/jwhitley/requirejs-rails.git'
gem 'ejs'
gem 'devise'
gem 'better_errors', '>= 0.2.0', :group => :development
gem 'binding_of_caller', '>= 0.6.8', :group => :development
gem 'd3_rails'
gem 'font-awesome-sass-rails'
# for a better way of looking at the rake routes by calling rake color_routes in the console
gem 'color_routes'
# lets us know which user is logged in, and store in a global variable gon{}
gem 'gon'
#browser detection
gem 'browser'
# FOR EASY TRANISTION TO Rails 4
gem 'protected_attributes'
gem 'rails-observers'
gem 'actionpack-page_caching'
gem 'actionpack-action_caching'
and when running bundle, getting the following error:
Bundler could not find compatible versions for gem "jquery-rails":
In Gemfile:
rails-backbone (>= 0) ruby depends on
jquery-rails (~> 2.1.3) ruby
jquery-rails (3.1.2)
Bundler could not find compatible versions for gem "ejs":
In Gemfile:
rails-backbone (>= 0) ruby depends on
ejs (~> 1.0.0) ruby
ejs (1.1.1)
Bundler could not find compatible versions for gem "rails":
In Gemfile:
rails-backbone (>= 0) ruby depends on
rails (~> 3.1.0.beta1) ruby
rails (4.1.1)
The errors aren't making sense. Taking the first part with jquery-rails, i get that it is saying another gem rails-backbone of a version greater than or equal to 0 depends on jquery-rails of around 2.1.3.
What does ruby mean after the versions?
What is `jquery-rails (3.1.2) mean?
Basically, you have dependency errors in your gemfile, and it seems that rails-backbone is causing most of them, consider removing it, as the latest version works with rails 3.1 - it hasn't been updated for long time
Here is info about the gem: https://rubygems.org/gems/rails-backbone
Bundler could not find compatible versions for gem "ejs":
In Gemfile:
rails-backbone (>= 0) ruby depends on
ejs (~> 1.0.0) ruby
ejs (1.1.1)
This error literally means that you are using ejs version 1.1.1 (probably a dependency of some other gem), but rails-backbone (version greater or equal 0, so any version) requires ejs in version 1.0.*
you can use rails-backbone from the git with
gem 'rails-backbone', git: 'https://github.com/codebrew/backbone-rails.git', tag: 'v1.1.2'
Version 1.1.2 depends on any version of jquery-rails and mocha, so it shouldn't cause any problems. Using git without tag will get the latest version from master, but I would advise against using development version (may cause more trouble than good)
The rubygem seems outdated, the github repository states that it works with rails 4
As a workaround, get the gem directly from github :
gem 'rails-backbone', :git => 'https://github.com/codebrew/backbone-rails.git'
jquery-rails (~> 2.1.3) means it is dependent on all jquery-rails versions between 2.1.3 and below 2.2.0.
jquery-rails (3.1.2) is already installed in the app; it can be verified by looking at Gemfile.lock contents.
Try bundle update; it will try to update all the gem versions where there are no specific version specified, and possibly succeed in getting the dependency conflict resolved.

gem install error sass-rails

I want to install an old version of sass-rails gem. But i am getting this error and my css is not working on my project, check it:
In Gemfile
group :development, :test do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
gem 'rspec-rails'
gem 'watchr'
end
and when I run this command bundle install then I got this error:
$ bundle install
Your Gemfile lists the gem sass-rails (~> 3.2.3) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of just one of them later.
Your Gemfile lists the gem coffee-rails (~> 3.2.1) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of just one of them later.
Your Gemfile lists the gem uglifier (>= 1.0.3) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of just one of them later.
Please Help me to sort out this..

Resources