ruby version error when pushing to heroku - ruby-on-rails

I am running into an error when trying to push my app to Heroku. I have pasted my gemfile below for your reference.
The Error:
An error occurred while installing ruby-2.3.1 remote: ! remote: ! This version of Ruby is not available on Heroku-18.
Gemfile:
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby "~> 2.3.1"
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.2'
# Use sqlite3 as the database for Active Record
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'mini_racer', platforms: :ruby
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
gem 'bootsnap', '>= 1.1.0', require: false
gem 'bootstrap', '>=4.0'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'sqlite3'
end
group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
# Easy installation and use of chromedriver to run system tests with Chrome
gem 'chromedriver-helper'
end
group :production do
gem 'pg'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

heroku stack:set heroku-16, running this command in your terminal will help you.

Change the Heroku Stack for Ruby -v 2.6.2
I used the following command to fix it.
heroku stack:set heroku-16
Reference: upokary.com

Here you can find a list of Ruby versions currently supported on Heroku:
https://devcenter.heroku.com/articles/ruby-support#ruby-versions
You'll have to upgrade your application to at least Ruby 2.4.5 to get it working there.

Related

bootsnap `require': cannot load such file -- faraday/request/multipart (LoadError)

Suddenly got this error when starting my rails server
bundle exec rails s
Here is the error message
1: from /Users/michelleroos/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:15:in `require'
/Users/michelleroos/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:15:in `require': cannot load such file -- faraday/request/multipart (LoadError)
I'm not sure if it is something to do with my gem file. I Googled the error and tried the solutions proposed in other SO threads but nothing worked.
What I tried already:
Basically everything in this thread
This thread
And this thread
Here is my gem file
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.5.3'
gem 'google-apis-sheets_v4'
gem 'google_drive'
gem 'dotenv-rails'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2' #5.2.3
# Use postgresql as the database for Active Record
gem 'pg', '>= 0.18', '< 2.0'
# Use Puma as the app server
gem 'puma', '~> 4.3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'mini_racer', platforms: :ruby
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
# gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'
# Use ActiveStorage variant
# gem 'mini_magick', '~> 4.8'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1', require: false #1.1.0
gem 'jquery-rails'
gem 'serialize_json-rails'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'rspec-rails'
gem 'factory_bot_rails'
gem 'rails-controller-testing'
gem 'better_errors'
gem 'binding_of_caller'
end
group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
gem 'annotate'
gem 'pry-rails'
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
# Easy installation and use of chromedriver to run system tests with Chrome
gem 'chromedriver-helper'
gem 'faker'
gem 'guard-rspec'
gem 'launchy'
gem 'shoulda-matchers'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
In my case I got this error after fixing an initial error regarding the Spring gem and then after fixing an error regarding Multipart post. After lot of trial and error I decided to undo all the fixes by doing a git reset --hard and then removing the spring and spring-watcher-listen gems from the Gemfile and then uninstalling these 2 gems via the bundle exec gem uninstall gemname command.
I then discovered a new error when trying to run rails s which was about MySQL. Finally after fixing those errors I was able to do a successful rails s. I then added back the 2 gems, ran bundle and had no errors afterwards.

Your Ruby version is 2.5.1, but your Gemfile specified 2.6.3

I'm trying to run command " rake db:test:prepare" in 6.2 of Rails Tutorial book. And then I had this problem
I have already run " gem install bundler". But it wasn't work. After I check version in path /home/myname/.rvm/gems. T got version of Ruby is 2.6.3
Gemfile:
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.6.3'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.3'
# Use mysql as the database for Active Record
gem 'mysql2', '>= 0.4.4', '< 0.6.0'
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'mini_racer', platforms: :ruby
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use ActiveStorage variant
# gem 'mini_magick', '~> 4.8'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
gem 'annotate', '~> 2.7', '>= 2.7.5'
gem 'rspec-rails', '~> 3.8', '>= 3.8.2'
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
# Easy installation and use of chromedriver to run system tests with Chrome
gem 'chromedriver-helper'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
# group :production do
# gem 'pg', '0.17.1'
# gem 'rails_12factor', '0.0.2'
# end
How can i fix this problem? Thank you.
This usually comes up when the specified ruby version is not installed. To install using rvm run:
rvm install ruby-2.6.3
If you suspect it's already installed, then you may need to tell rvm to use the specific version, as it might default to another version (in this case 2.5.1). To do that run:
rvm --default use ruby-2.6.3
If it's not installed, the above command will throw a relevant error.

trouble pushing app to heroku, ruby version error - RVM

remote: ! An error occurred while installing ruby-2.3.1
this version of ruby is not available on heroku-18
so, when I run Ruby -v, I get:
ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]
and my gemfile:
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby "2.6.0"
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.2'
# Use sqlite3 as the database for Active Record
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'mini_racer', platforms: :ruby
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
gem 'bootsnap', '>= 1.1.0', require: false
gem 'bootstrap', '>=4.0'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'sqlite3'
end
group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
# Easy installation and use of chromedriver to run system tests with Chrome
gem 'chromedriver-helper'
end
group :production do
gem 'pg'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
Everything is running locally, what am I doing wrong? to note, i am using RVM - Is there anything special that i need to do to use RVM with heroku ?

ERROR: ServiceError - Failed to deploy application. on ElasticBeanstalk

So, I am launching my app with Elasticbeanstalk and I am using Ruby on Rails for my app. However, when I ran the command "eb deploy {name}", it showed me the error
Creating application version archive "app-4f49-180904_151051".
Uploading: [##################################################] 100%
Done...
2018-09-04 07:12:09 INFO Environment update is starting.
2018-09-04 07:12:15 INFO Deploying new version to instance(s).
2018-09-04 07:12:47 ERROR [Instance: i-0ae9e24acc3308f6d] Command
failed on instance. Return code: 1 Output:
(TRUNCATED)...c65750cc.js.gz
rake aborted!
Autoprefixer doesn’t support Node v4.6.0. Update it.
/opt/rubies/ruby-2.5.1/bin/bundle:23:in `load'
/opt/rubies/ruby-2.5.1/bin/bundle:23:in `<main>'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace).
Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/11_asset_compilation.sh
failed. For more detail, check /var/log/eb-activity.log using console
or EB CLI.
2018-09-04 07:12:47 INFO Command execution completed on all
instances. Summary: [Successful: 0, Failed: 1].
2018-09-04 07:12:47 ERROR Unsuccessful command execution on
instance id(s) 'i-0ae9e24acc3308f6d'. Aborting the operation.
2018-09-04 07:12:48 ERROR Failed to deploy application.
ERROR: ServiceError - Failed to deploy application.
However, I have check my gemfile, and did not see Autoprefix of any kind. I hope I am providing enough info, if not, please guide me in providing more details and finding an answer for this. Thank you in advance.
My gemfile
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.5.1'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.0'
# Use mysql as the database for Active Record
gem 'mysql2', '>= 0.4.4', '< 0.6.0'
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'mini_racer', platforms: :ruby
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use ActiveStorage variant
# gem 'mini_magick', '~> 4.8'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15', '< 4.0'
gem 'selenium-webdriver'
# Easy installation and use of chromedriver to run system tests with Chrome
gem 'chromedriver-helper'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'devise'
gem 'figaro'
gem 'omniauth-google-oauth2'
gem 'twitter'
gem 'omniauth-twitter'
gem 'carrierwave', '~> 1.0'
gem "mini_magick"
gem 'omniauth-facebook'
gem "recaptcha", require: "recaptcha/rails"
gem 'impressionist'
gem 'social-share-button'
gem 'fog-aws'
# include bootstrap
gem 'bootstrap', '~> 4.1.0'
#include fontawesome
gem 'font-awesome-rails'
#include jquery & jquery ujs
gem 'jquery-rails'
gem 'acts-as-taggable-on', '~> 6.0'
gem 'will_paginate', '~> 3.1.0'
gem 'autosize'
gem 'jquery-ui-rails'
gem 'select2-rails'
Same issue–fixed it by uncommenting mini-racer worked for me, like #KedarnagMukanahallipatna suggested above.
Change From
# Gemfile
# gem 'mini_racer', platforms: :ruby
Change To
# Gemfile
gem 'mini_racer', platforms: :ruby

Rails unable to deploy new gem to production

so for all this while i have been deploying my web app without knowing its on production or not.
I would usually create my project as usual , where i just do the basic bundle install. and add new gems. Setup unicorn + nginx .
And then when i view the aws's public dns, it would show me my site as i would get on localhost:3000.
In my mind, i am still in development environment. However, it seems that when i installed a new gem , it only works on localhost:3000 but on the deployed site it self it is unrecognized. Example would be an ActiveAdmin gem , where on my site it shows "uninitialized constant ActiveAdmin" .
How should i solve this ? I am suspecting it could be because of different environments, but i am unsure how to approach this.
UPDATE my gem file
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
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.1'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
gem 'therubyracer', platforms: :ruby
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
#gem 'pdf-reader'
gem 'pdf-reader-turtletext'
gem 'nokogiri'
gem 'whenever', :require => false
gem 'unicorn'
gem 'devise'
#gem 'rails_admin', '~> 1.1.1'
gem 'activeadmin', github: 'activeadmin'
gem 'inherited_resources', github: 'activeadmin/inherited_resources'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '~> 2.13'
gem 'selenium-webdriver'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

Resources