I am facing a mysql2 gem version error while trying to create a new RailsApps example application using Rails Composer. For example, while creating a rails-devise-roles example with the following command:
$ rails new rails-devise-roles -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb
The error is:
Error loading the 'mysql2' Active Record adapter. Missing a gem it depends on? can't activate mysql2 (< 0.6.0, >= 0.4.4), already activated mysql2-0.3.21. Make sure all dependencies are added to Gemfile. (Gem::LoadError)
The messages on the console indicate mysql2 version 0.3.21 is pulled in
run bundle install --without production from "."
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies....
...................
Using mysql2 0.3.21
The generated Gemfile has
gem 'mysql2', '~> 0.3.18'
I am using ruby 2.5.3 and Rails 5.2.1
Related
I am trying to create a database for my rails 5.0.0.1 application with rails db:create but I receive the following error:
Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
The point is that there is a gem 'pg' in my Gemfile, which was updated to version 1.0.0 by bundle update, launched after bundle install:
$ gem list
...
pg (1.0.0, 0.20.0)
I have no idea why rails cannot recognize the installed pg gem and fails to create a database for my application.
pg version 1.0.0 work fine with rails 5.1.5 and newer.
See this github post
I have had trouble recently trying to deploy my rails app on Heroku. In the past, I had deployed apps on Heroku with no problem, but Heroku does not support ruby 2.0.0 anymore. They suggest adding ruby "2.2.4" to the Gemfile, which is what I did. The beginning of my Gemfile is as follows:
source 'https://rubygems.org'
ruby "2.2.4"
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0'
# Use pg as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
...
So, I have run bundle install with version 1.7.8 on my computer with no problem. I can even run my app in production mode. However, when I try to deploy the app on Heroku, I get this:
-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.2.4
-----> Installing dependencies using bundler 1.11.2
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Using rake 10.4.2
Installing i18n 0.7.0
Installing minitest 5.4.3
Installing json 1.8.3 with native extensions
Installing thread_safe 0.3.4
Installing builder 3.2.2
Installing erubis 2.7.0
Your Gemfile.lock is corrupt. The following gem is missing from the DEPENDENCIES
section: 'mini_portile2'
Bundler Output: Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Using rake 10.4.2
Installing i18n 0.7.0
Installing minitest 5.4.3
Installing json 1.8.3 with native extensions
Installing thread_safe 0.3.4
Installing builder 3.2.2
Installing erubis 2.7.0
Your Gemfile.lock is corrupt. The following gem is missing from the DEPENDENCIES
section: 'mini_portile2'
!
! Failed to install gems via Bundler.
!
! Push rejected, failed to compile Ruby app
Any help is greatly appreciated.
I'd suggest deleting your Gemfile.lock, running bundle install again locally, committing the new Gemfile.lock to your git repository and then try your git push heroku master again.
I had the same problem and what I did was I updated Ruby 2.2.4 in my system and restarted terminal, then followed these steps:
bundle install
bundle update
git push heroku
( it’s a good idea to update the gems with bundle update to make sure the versions match)
The problem is that you only changed the Ruby version number in the Gemfile, but did not recreate a valid Gemfile.lock. This leads to a Gemfile.lock that contains Gems in versions that are not compatible with Ruby 2.2.4.
If you change something in the Gemfile then you have to update or recreate the Gemfile.lock with the same Ruby version before pushing to Heroku.
I suggest to use a Ruby version manager (like rbenv or RVM) to be able to run multiple versions of Ruby on your development machine. Then update the Ruby version in your application by changing the Ruby version in Gemfile (for Heroku) and .ruby-version (for your local environment). Both version must match.
Once that is done, run bundle install to update the Gemfile.lock or (when there were major updates or you just want to ensure that you use the latest versions) run bundle update to recreate the Gemfile.lock.
Just installed via RVM Ruby 2.0.0 and Rails 4.0.0. Started a new project and when tried to add the gem 'factory-girl-rails', and run bundle install, I got this error:
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Could not find gem 'factory-girl-rails (~> 4.2.1) ruby' in the gems available on this machine.
Any thoughts why can this be happening?
You need to change those dashes to underscores:
gem 'factory_girl_rails', '4.2.1'
factory_girl_rails does not seems to be available for rails higher then version 3.2.11
https://github.com/thoughtbot/factory_girl_rails#rails
I'm trying to use omniauth with a new project. I'm using it on other projects on my computer with no issues. 'gem list' confirms:
rails 3.2.9
omniauth 1.1.4
Everything is fine until I bundle install, at which point I get this error message:
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/..
Could not find gem 'ominiauth (>= 0) ruby' in the gems available on this machine.
Here is my Gemfile:
source 'https://rubygems.org'
gem 'rails'
gem 'ominiauth'
You misspelled omniauth as ominiauth.
Its important to update rails after all of the security fixes, but when I try it says the gem does not exist even though the rails blog says it has been released.
The blog says to upgrade: http://weblog.rubyonrails.org/2013/1/28/Rails-3-0-20-and-2-3-16-have-been-released/
But when I add the following to the Gemfile:
gem 'rails', '3.2.16'
And when I update I get:
➜ bundle update rails (ruby-1.9.3-p374#usertesting-orders)
Fetching gem metadata from http://rubygems.org/......
Fetching gem metadata from http://rubygems.org/..
Could not find gem 'rails (= 3.2.16) ruby' in the gems available on this machine.
Any tips?
UPDATE: there is no such gem. Its supposed to be 3.2.11 NOT 3.2.16. The .16 is for the 2.3 Rails and not the 3.2.
Try gem 'rails', '3.2.11' ,according to the stable branch in GitHub.