What is the correct way to fix bundler not finding compatible versions - ruby-on-rails-3

I have an old rails 3 application which I want to update to rails 4 at the moment. I removed the Gemfile.lock manually and changed the Gemfile to require rails in version "4.0.0" before running a fresh "bundle install". I was getting several messages that bundler was not able to find compatible versions.
I am using ruby 2.0.0 here installed with rvm on a linux system.
I installed rails 4.0.0 manually using
gem install rails -v 4.0.0
And then I tried again with
bundle install
This is one example of the messages that pop up:
Bundler could not find compatible versions for gem "activerecord":
In Gemfile:
activerecord-import (~> 0.4.1) was resolved to 0.4.1, which depends on
activerecord (>= 3.0)
authlogic (~> 3.3.0) was resolved to 3.3.0, which depends on
activerecord (>= 3.2)
delayed_job_active_record (~> 4.0.0) was resolved to 4.0.3, which depends on
activerecord (>= 3.0, < 5.0)
rails (= 4.0.0) was resolved to 4.0.0, which depends on
activerecord (= 4.0.0)
This is my Gemfile:
source 'https://rubygems.org'
# the rails framework: September 14, 2016
gem 'rails', '4.0.0'
# the postgres db connector
gem 'pg', '~> 0.18.0'
# a templating engine for html
gem 'haml', '~> 3.1.7'
# authentication solution
gem 'authlogic', '~> 3.3.0'
# role-based authorization system
gem 'acl9', '~> 0.12.1'
# helper methods for rails 3 models
gem 'dynamic_form', '~> 1.1.4'
# upload management for active record
gem 'paperclip', '~> 4.2.2'
# tag a single model on several contexts
gem 'acts-as-taggable-on', '~> 2.4.1'
# read and write spreadsheet documents
gem 'spreadsheet', '0.9.7'
# active record backend for Delayed::Job
gem 'delayed_job_active_record', '~> 4.0.0'
# wrap ruby scripts executed as deamon
gem 'daemons', '~> 1.1.9'
# writing and deploying cron jobs
gem 'whenever', '~> 0.8.2', require: false
# bulk inserting data using active record
gem 'activerecord-import', '~> 0.4.1'
# named scoples for postgres fulltext search
gem 'pg_search', '~> 0.5.7'
# jQuery and the jQuery-ujs driver for your Rails
gem 'jquery-rails', '~> 3.1.3'
# jQuery UI's JavaScript, CSS, and image files
gem 'jquery-ui-rails', '~> 3.0.1'
# paginated queries with Active Record
gem 'will_paginate', '~> 3.0.5'
# group :production do
# performance management system
# gem 'newrelic_rpm'
# end
# Profiling toolkit
# gem 'rack-mini-profiler', :group => :development
group :test, :development do
# unit testing framework
gem 'test-unit', '~> 2.5.4'
# process manager
gem 'foreman', '~> 0.61.0'
# code profiler
# gem 'ruby-prof'
# bindings for the GNOME Libxml2
gem 'libxml-ruby', '~> 2.4.0'
# wrapper for Linux inotify
gem 'rb-inotify', '~> 0.9.1'
# web server
gem 'thin', '~> 1.5.0'
# gem 'debugger'
gem 'better_errors', '~> 0.3.2'
# retrieve the binding of a method's caller
gem 'binding_of_caller', '~> 0.8.0'
# hosted test coverage service (badge)
gem 'coveralls', '~> 0.8.23', require: false
# gem 'codecov', :require => false, :group => :test
end
group :assets do
# sass adapter
gem 'sass-rails', '~> 3.2.3'
# coffee script adapter
gem 'coffee-rails', '~> 3.2.1'
# call java script code and manipulate java script
# gem 'therubyracer', :platforms => :ruby
# uglifier minifies java script
gem 'uglifier', '~> 2.7.2'
end
group :tools do
# code formatter
gem 'rubocop', require: false
# report vulnerable gems
gem 'gemsurance', '~> 0.9.0'
# handle events on file system modifications
gem 'guard', '~> 1.6.1'
# automatically run your tests on file modification
gem 'guard-test', '~> 0.7.0'
# html parser
gem 'hpricot', '~> 0.8.6'
# ruby parser written in pure ruby
gem 'ruby_parser', '~> 3.1.2'
end
Due to the manual install of rails 4 I have activerecord in version 4.0.0 in my gems available. Why does it come up with that message? From my interpretation of the listed activerecord versions the dependency should be fulfilled with version 4.0.0? It is in the listed range between 3.0 and less than 5.

Related

rails 5.1.4 console in production doesn't find models

I think I got a configuration issue with my rails setup in production.
I've got a puma working fine without any issues (connecting to db, loading models etc) and previously was able to use the console (I've encountered this [bug][https://github.com/rails/rails/issues/19256] but worked around it by filling in the database.yml)
When I try to open the console to perform little operations, none of my model classes are found.
✗ bundle exec rails console production
Running via Spring preloader in process 18313
Loading production environment (Rails 5.1.4)
irb(main):001:0> User.count
NameError: uninitialized constant User
from (irb):1
irb(main):002:0>
Similar questions on SO recommend to run ActiveRecord::Base.subclasses and eventually Rails.application.eager_load!
When I do try to run Rails.application.eager_load! I get uninitializaed constant error
irb(main):005:0> Rails.application.eager_load!
NameError: uninitialized constant ApplicationController
Did you mean? ApplicationCable
from app/controllers/accounts_controller.rb:1:in `<top (required)>'
from (irb):5
So I guess my console is now somehow lost and hasn't loaded the project source correctly.
How can I troubleshoot this situation ?
edit 2018-02-15 : I connected my workstation to the prod environment to use the console. This worked at first, the console was behaving correctly. After a couple times the same issues appeared. After doing spring stop I was able again to user my local workstation to open a console in prod.
Interesting fact : this never happens in dev environment, although spring had an app running in this environment.
It turns out spring is also running in prod, although the spring gem is only in dev group. (see below)
Gemfile
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
gem 'rails', '~> 5.1.4'
gem 'puma', '~> 3.7'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'therubyracer', platforms: :ruby
gem 'coffee-rails', '~> 4.2'
gem 'jbuilder', '~> 2.5'
group :development, :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'capybara', '~> 2.13'
gem 'selenium-webdriver'
gem 'rails-erd', require: false, group: :development
end
group :development do
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
gem 'pry'
gem 'pry-byebug'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'devise'
gem 'devise-i18n'
gem 'cancancan', '~> 2.0'
gem 'rolify'
gem 'redis', '~> 3.2'
group :production do
gem "sidekiq"
gem "sentry-raven"
end
gem 'pg'
gem "paperclip", "~> 5.0.0"
gem 'i18n-country-translations'
gem 'rails-i18n', '~> 5.0.0'
gem 'i18n_alchemy'
gem 'wicked_pdf'
gem 'wkhtmltopdf-binary'
If you deployed through Docker make sure using -ti prefix in running command like:
docker exec -ti 4d318d505e9f rails c production

.worker file with `gemfile "Gemfile", "group"` increases remote build time x10

To better manage the required gems across my application, I created a Gemfile group called :iron:
group :default, :iron do
  gem "activerecord", require: 'active_record
  gem 'mysql2'
  gem 'aws-sdk'
  gem 'yajl-ruby'
  gem 'hashie'
  gem 'require_all'
end
This would help consolidate the required gems for iron worker. My .worker file is now as follows:
gemfile '../Gemfile', 'iron'
instead of redundantly listing all the gems individually:
gem "activerecord"
gem 'mysql2'
...
Unfortunately, this increased my remote build time from 1 minute to 10 minutes. The output attempts to include far more gems, seemingly bubbling up nested dependencies:
BEFORE:
------> Creating code package
Found workerfile with path='iron_job.worker'
Detected exec with path='iron_job_bootstrapper.rb' and args='{}'
Merging dir with path='../app/models' and dest=''
Merging dir with path='../lib' and dest=''
Merging file with path='iron.json' and dest=''
Adding ruby gem dependency with name='activerecord' and version='>= 0'
Adding ruby gem dependency with name='mysql2' and version='>= 0'
Adding ruby gem dependency with name='aws-sdk' and version='>= 0'
Adding ruby gem dependency with name='yajl-ruby' and version='>= 0'
Adding ruby gem dependency with name='hashie' and version='>= 0'
Adding ruby gem dependency with name='require_all' and version='>= 0'
AFTER:
------> Creating code package
Found workerfile with path='iron_job.worker'
Detected exec with path='iron_job_bootstrapper.rb' and args='{}'
Merging dir with path='../app/models' and dest=''
Merging dir with path='../lib' and dest=''
Merging file with path='iron.json' and dest=''
Adding ruby gems dependencies from iron group of ../Gemfile
Adding ruby gem dependency with name='i18n' and version='0.6.5'
Adding ruby gem dependency with name='minitest' and version='4.7.5'
Adding ruby gem dependency with name='multi_json' and version='1.8.1'
Adding ruby gem dependency with name='atomic' and version='1.1.14'
Adding ruby gem dependency with name='thread_safe' and version='0.1.3'
Adding ruby gem dependency with name='tzinfo' and version='0.3.37'
Adding ruby gem dependency with name='activesupport' and version='4.0.0'
Adding ruby gem dependency with name='builder' and version='3.1.4'
Adding ruby gem dependency with name='activemodel' and version='4.0.0'
Adding ruby gem dependency with name='activerecord-deprecated_finders' and version='1.0.3'
Adding ruby gem dependency with name='arel' and version='4.0.0'
Adding ruby gem dependency with name='activerecord' and version='4.0.0'
Adding ruby gem dependency with name='json' and version='1.8.0'
Adding ruby gem dependency with name='mini_portile' and version='0.5.1'
Adding ruby gem dependency with name='nokogiri' and version='1.6.0'
Adding ruby gem dependency with name='uuidtools' and version='2.1.4'
Adding ruby gem dependency with name='aws-sdk' and version='1.11.1'
Adding ruby gem dependency with name='bundler' and version='1.3.5'
Adding ruby gem dependency with name='hashie' and version='2.0.5'
Adding ruby gem dependency with name='mysql2' and version='0.3.13'
Adding ruby gem dependency with name='require_all' and version='1.3.1'
Adding ruby gem dependency with name='yajl-ruby' and version='1.1.0'
This output was local, but the time stretched out even more on the IronWorker service because it reinstalls gems more than once (uninstall then reinstalls bundler). The log below has the details.
https://hud.iron.io/tq/projects/5254773dd05880000d000003/tasks/525ee1d9f8953468b927e83f/log
We have since gone back to a .worker file that simply lists out the gems we need rather than invoke gemfile "Gemfile", "iron". Any help on how to use gemfile without reinstalling bundler and have a 10m upload time would be much appreciated!
Thanks.
Edit
Adding full Gemfile. Please note that we have no desire to pull in all the gems on the :default group. That is overkill for our workers. We just want :iron.
Bundler version 1.3.5
source 'https://rubygems.org'
ruby '1.9.3'
gem 'typhoeus' # Only for ruby 1.9.3
gem 'rails', '4.0.0'
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'haml-rails'
gem 'thin-rails'
gem 'therubyracer'
gem 'less-rails'
gem 'twitter-bootstrap-rails'
gem 'settingslogic'
gem 'iron_worker_ng'
group :default, :iron do
gem "activerecord", require: 'active_record'
gem 'mysql2'
gem 'aws-sdk'
gem 'yajl-ruby'
gem 'require_all'
end
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
group :production, :qa do
gem 'rails_12factor' #for heroku
end
group :development, :test do
gem 'factory_girl_rails'
gem 'ffaker'
gem 'shoulda-matchers'
gem 'pry'
gem 'debugger', '>= 1.6.1'
gem 'pry-debugger'
gem 'pivotal_git_scripts'
gem 'rspec-rails'
gem 'capybara'
gem 'fuubar'
end
group :test do
gem 'database_cleaner'
end
grouped Gemfile:
source 'https://rubygems.org'
ruby '1.9.3'
group :rails do
gem 'typhoeus' # Only for ruby 1.9.3
gem 'rails', '4.0.0'
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'haml-rails'
gem 'thin-rails'
gem 'therubyracer'
gem 'less-rails'
gem 'twitter-bootstrap-rails'
gem 'settingslogic'
gem 'rack-mini-profiler'
end
group :rails, :iron do
gem "activerecord", require: 'active_record'
gem 'mysql2'
gem 'aws-sdk'
gem 'yajl-ruby'
gem 'require_all'
gem 'hashie'
gem 'iron_worker_ng'
end
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
group :production, :qa do
gem 'rails_12factor' #for heroku
end
group :development, :test do
gem 'factory_girl_rails'
gem 'ffaker'
gem 'shoulda-matchers'
gem 'pry'
gem 'debugger', '>= 1.6.1'
gem 'pry-debugger'
gem 'pivotal_git_scripts'
gem 'rspec-rails'
gem 'capybara'
gem 'fuubar'
end
group :test do
gem 'database_cleaner'
end
IronWorker already announced a "Docker Workflow" and you don't need the .worker file anymore. You just need to install all dependencies locally in docker image reproducing the same environment as running on IronWorker servers. Here you can find a ruby "HelloWorld" example.

undefined method `page' for # Kaminari::PaginatableArray

I have been using Kaminari since a while. I use to paginate generic arrays using the following line.
Kaminari.paginate_array([1,2,3]).page(1).per(1)
That use to work before but I noticed that since yesterday this show the error
undefined method `page' for #<Kaminari::PaginatableArray:0x007f8e5d10fde0>
However calling page on ActiveRecord relation is working fine. something like this is working
User.page(1).per(1)
My Gem file
source 'https://rubygems.org'
ruby '1.9.3'
gem 'rails', '3.2.8'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2'
gem 'pg'
# Ok lets try out the heroku business
gem 'heroku'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-fileupload-rails'
gem 'jquery-rails'
gem 'jquery-ui-rails'
# Twitter Boostrap and Upgrade dependencies
gem 'therubyracer'
gem 'less-rails'
gem 'twitter-bootstrap-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
gem 'unicorn'
# Deploy with Capistrano
gem 'capistrano'
gem 'cap_bootstrap', github: 'benrs44/cap_bootstrap'
gem 'awesome_print'
group :test, :development do
gem 'rspec-rails', '>= 2.0.1'
gem "capybara-webkit"
gem 'capybara'
gem 'launchy'
gem 'selenium-webdriver'
gem 'shoulda-matchers'
gem 'ci_reporter'
gem "factory_girl_rails", "~> 4.0"
# DRb server RSpec
gem "spork-rails"
# To use debugger
gem 'debugger'
end
group :test do
gem "guard-rspec"
gem 'rb-fsevent', '~> 0.9.1'
gem 'database_cleaner'
gem 'fuubar'
end
#Image Uploader
gem 'carrierwave'
#Image Processor
gem "rmagick"
#Video Processor
gem 'video_info'
gem 'hpricot'
#Authenitcation
gem 'omniauth-facebook', '1.4.0'
#Messaging
gem 'mailboxer', github: 'rralston/mailboxer'
gem 'haml-rails'
gem 'simple_form'
#Gelocation
gem 'geocoder'
#Search
gem 'ransack'
# For easily making nouns possessive
gem 'possessive'
#Pagination
gem "kaminari"
gem 'will_paginate', '~> 3.0'
#Web App Monitoring
gem 'newrelic_rpm'
#FB Style Newsfeeds
gem 'public_activity'
# Heroku CDN Link to AWS
gem "asset_sync"
# Carrier Wave link to AWS S#
gem 'fog', '~> 1.12.1'
gem 'cancan'
# client side validtions
gem 'client_side_validations'
# tagging
gem 'acts-as-taggable-on'
# remote file uploads
gem "remotipart", "~> 1.2.1"
# social sharing
gem 'social-share-button'
gem 'devise', "~> 2.2.3"
gem 'omniauth'
gem 'devise-async'
running bundle show bundle show kaminari gives /Users/***/.rvm/gems/ruby-1.9.3-p448/gems/kaminari-0.14.1
Turned out to be that my colleague has added a configuration file for Kaminari and changed this page function with this line.
config.page_method_name = :kaminari_page
So instead of using Kaminari.paginate_array([1,2,3]).page(1).per(1) I should now use
Kaminari.paginate_array([1,2,3]).kaminari_page(1).per(1)

issue with mercury rails gem

I was working on a blog app so I want to implemant mercury-rails gem into it, i tried and i got it the tool bar but i was unable to edit any content from my show page
even after everything i am using with the foundation front end framework
<p><span id="page_content class="mercury-region" data-type="editable">
<%=raw #article.content %></span></p>
<h5><span data-type="editable"><%= #article.title %></span></h5>
this is my gem file
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'zurb-foundation'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'debugger'
gem 'simple_form'
gem 'friendly_id'
gem 'devise'
gem "rmagick"
gem "carrierwave"
gem "mercury-rails"
By the looks of things you've followed the old railscast. The mercury-rails projects updates quite frequently.
The problem lies in your attributes on the span tag. You can safely remove the class="mercury-region"
You will also need to change data-type="editable" to data-mercury="full".
See the different edit types (defined in the data-mercury attribute) on the github page: https://github.com/jejacks0n/mercury#region-types
I hope that helps!

test-unit gem displays test stat for every rake run

I using test-unit gem with a Rails 3.1 project, and I have a small issue. If I start rake tasks, I always see a test result, with zeros.
My Gemfile is:
source :rubygems
gem 'rails', '3.1.2'
gem 'sqlite3'
gem 'json_pure'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
# gem 'sass-rails', '~> 3.1.5.rc.2'
# gem 'coffee-rails', '~> 3.1.1'
gem 'therubyracer'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# Rails i18n
gem 'rails-i18n', :git => 'git://github.com/hron84/rails-i18n.git'
# Paginator
gem 'will_paginate'
# To use ActiveModel has_secure_password
gem 'bcrypt-ruby', '~> 3.0.0'
# Use unicorn as the web server
gem 'thin'
# Deploy with Capistrano
gem 'capistrano'
# To use debugger
# gem 'ruby-debug'
group :development do
gem 'rails3-generators'
gem 'nifty-generators'
end
group :test do
gem 'rspec'
gem 'rspec-rails'
gem 'ci_reporter'
gem 'factory_girl'
unless defined? Rubinius
gem 'rcov'
gem 'rcov_rails'
gem 'test-unit'
end
gem 'ruby-prof'
gem 'faker'
end
# Application-related stuffs
gem 'authlogic'
# Slug helper
gem 'slug'
# vim: ft=Gemfile
Is there a way to avoid it? What I do wrong?
Check your RAILS_ENV. Make sure it's set to "development", not "test". If that's not the culprit, try removing gems (particularly test/spec-related ones) one by one until the problem goes away. Then you'll know which gem is giving you the problem.