All Heroku Commands Are Broken due to Ruby Version - ruby-on-rails

Everytime I run a heroku command I receive this error:
Your Ruby version is 1.9.3, but your Gemfile specified 2.1.2
This has been happening since I pushed several changes (adding sidekiq and making changes to my clock.rb file, also: a new model I need to migrate the db for)
Does anyone know why this might be happening? It only started after I added ruby '2.1.2' to the gemfile. But before that I was getting this funky segmentation fault error.
Here's my gemfile:
source 'https://rubygems.org'
ruby '2.1.2'
gem 'rails', '4.1.1'
gem 'pg'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'clockwork'
gem 'httparty'
gem 'omniauth-facebook'
gem 'parse-ruby-client'
gem 'parse_resource', '~> 1.8.0'
gem 'stripe', :git => 'https://github.com/stripe/stripe-ruby'
gem 'sidekiq'
gem 'foundation-rails'
group :development, :test do
gem 'pry-rails'
gem 'rspec-rails'
gem 'factory_girl_rails'
gem 'shoulda-matchers'
gem 'valid_attribute'
gem 'capybara'
gem 'dotenv-rails'
gem 'better_errors'
gem 'binding_of_caller'
end
group :production do
gem 'rails_12factor'
gem 'thin'
end

It's seems to related bundler issue. Go through here https://github.com/sstephenson/rbenv/issues/400 same sort of issue also here get fixed with :
# Rakefile
task :freedom do
Bundler.with_clean_env { sh "heroku" }
end
Hope this help you!

I had two applications using Ruby. In your terminal, change to the directory of the application, then check the Ruby version you are using. Update it appropriately.

Related

How to completely remove webpack and all its dependencies from Rails App

I created my rails with this template that included webpack, I still write my javascript code in app/assets/javascript. I am trying to deploy my app to heroku and it keeps failing, I get this error
"remote:
/tmp/build_6f0656280cbbda40c5832ccb79fc1783/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.2/lib/bundler/rubygems_integration.rb:432:in
`block in replace_bin_path': can't find executable webpack for gem
webpacker (Gem::Exception)"
I have tried lots of solutions but still cant get my app deployed to Heroku. I want to know how to completely delete webpack and all its depencies from my app since it was not even useful to my app
source 'https://rubygems.org'
ruby '2.3.5'
gem 'figaro'
gem 'jbuilder', '~> 2.0'
gem 'puma'
gem 'rails', '5.1.4'
gem 'redis'
gem 'cloudinary'
gem 'carrierwave', '~> 1.2'
gem 'rails_admin', '~> 1.2'
group :production do
gem 'pg', '~> 0.20'
end
gem 'autoprefixer-rails'
gem 'bootstrap-sass'
gem 'jquery-rails'
gem 'font-awesome-sass'
gem 'sass-rails'
gem 'simple_form'
gem 'turbolinks', '~> 5.0.0'
gem 'coffee-rails'
gem 'uglifier'
gem 'webpacker'
gem 'devise'
gem 'ransack'
gem 'trix'
gem "letter_opener", group: :development
group :development do
gem 'web-console', '>= 3.3.0'
gem 'sqlite3'
end
group :development, :test do
# gem 'binding_of_caller'
# gem 'better_errors'
gem 'pry-byebug'
gem 'pry-rails'
gem 'listen', '~> 3.0.5'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
remove bin/webpackor run bundle exec rake rails:update:bin
remove config/webpacker.yml
remove config/webpack
remove app/javascripts
remove config.webpacker.check_yarn_integrity = false from config/{development, test, production}.rb
verify that you don't have webpacker in your gemfile and run bundle install or bundle clean
imho, don't create your rails app with generators (unless it's your own)

Can't run R on Heroku with RinRuby

R is running okay in development on my Rails 4.2.6 app, but I can't get it to run in production on Heroku with the RinRuby gem (2.0.3). Heroku rejects an attempted push with the following errors (relevant parts of log):
-----> Installing node-v6.10.0-linux-x64
-----> Detecting rake tasks
sh: 2: Syntax error: Unterminated quoted string
sh: 2: Syntax error: Unterminated quoted string
/app/tmp/buildpacks/ f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/helpers/rake_runner.rb:102:in `load_rake_tasks!': Could not detect rake tasks (LanguagePack::Helpers::RakeRunner::CannotLoadRakefileError)
ensure you can run `$ bundle exec rake -P` against your app
and using the production group of your Gemfile.
rake aborted!
Bundler::GemRequireError: There was an error while trying to load the gem 'rinruby'.
Gem Load Error is: No such file or directory - R
ruby_compile:15:in `<main>'
! Push rejected, failed to compile Ruby app.
! Push failed
I didn't have problems deploying to Heroku before installing RinRuby. I can successfully run
bundle exec rake -P command
against the app. I also tried placing
config.assets.compile =true
in the production environment, but that didn't solve the issue.
Don't know what's going on with the syntax errors; stumped on the RinRuby load error. To deploy R in production, I have the following files in the root directory:
.buildpacks:
http://github.com/virtualstaticvoid/heroku-buildpack-r.git#cedar-14-chroot
https://github.com/heroku/heroku-buildpack-ruby.git
init.r:
install.packages("ggplot2", dependencies = TRUE)
While researching, I found a similar but unanswered post: Install error of Rinruby on Heroku
What I'm I missing? How do I fix? More detail ... here's the gem file:
source 'https://rubygems.org'
ruby "2.2.4"
gem 'rails', '4.2.6'
gem 'bootstrap-sass', '~> 3.2.0.0'
gem "font-awesome-rails"
gem 'bcrypt', '~> 3.1.7'
gem 'cancancan', '~> 1.10'
gem 'devise'
gem 'rolify'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'jquery-tablesorter'
gem 'momentjs-rails', '>= 2.8.1'
gem 'bootstrap3-datetimepicker-rails', '~> 4.7.14'
gem 'turbolinks'
gem 'jquery-turbolinks', '~> 0.2.1'
gem 'jbuilder', '~> 2.0'
gem 'jc-validates_timeliness'
gem 'validates_overlap'
gem 'time_difference'
gem 'simple_form'
gem "paperclip", "~> 5.1.0"
gem 'aws-sdk', '~> 2' # Amazon S3 cloud storage
gem 'chart-js-rails', '~> 0.0.9'
gem 'by_star', :git => "git://github.com/radar/by_star"
gem 'ransack'
gem 'kaminari'
gem 'private_pub'
gem 'thin' # serves Faye to handle publishing/subscribing asynchronously
gem 'twilio-ruby', '~> 4.11.1'
gem 'newrelic_rpm'
gem 'rinruby', '~> 2.0', '>= 2.0.3'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
group :development do
gem 'spring'
gem 'better_errors'
gem 'binding_of_caller'
gem 'figaro'
gem 'guard-rspec', require: false
gem 'seed_dump'
gem 'rails-erd'
gem 'brakeman', require: false
gem 'rubocop', require: false
gem 'rails_best_practices', require:false
gem "letter_opener"
end
group :development, :test do
gem 'pg'
gem 'rspec-rails'
gem 'factory_girl_rails'
end
group :test do
gem 'capybara'
gem 'capybara-email'
gem 'email_spec'
gem 'shoulda-matchers'
gem 'faker'
gem 'database_cleaner'
gem 'launchy'
gem 'rspec-activemodel-mocks'
gem 'poltergeist'
gem 'pry-rails'
end
group :production do
gem 'pg'
gem 'rails_12factor'
gem 'unicorn', '~> 4.8.3'
end
I successfully installed R on Heroku for my Rails app. In an effort to help someone else who may need this information, here are the steps I took to solve the problem:
Uninstalled the RinRuby gem, and installed rootapp-rinruby (https://rubygems.org/gems/rootapp-rinruby), a more recent fork of the RinRuby gem.
Modifed the int.r file:
my_packages = c("ggplot2")
install_if_missing = function(p) {
if (p %in% rownames(installed.packages()) == FALSE) {
install.packages(p, dependencies = TRUE)
}
else {
cat(paste("Skipping already installed package:", p, "\n"))
}
}
invisible(sapply(my_packages, install_if_missing))
Created a file called .r-version and put it in root directory with the following content:
3.4.0
Added this R buildpack (http://github.com/virtualstaticvoid/heroku-buildpack-r.git#cedar-14-chroot) to Heroku
Now when I push, the Heroku log reports....
R 3.4.0 successfully installed (with init)
I hope this information helps someone. Good luck!
For improved visibility, placing my comment as an answer:
In your Gemfile, replace:
gem 'rinruby'
with
gem 'rootapp-rinruby'

Ruby version 2.2.5 but your Gem file specified 2.1.2

I already tried to update gem bundle and also try to pick gem 2.1.2 but ruby is not supporting them. Here is the error message:
error message
Gemfile:
source 'https://rubygems.org'
ruby '2.1.2'
gem 'rails', '4.2.4'
gem 'pry-rails'
gem 'pg'
gem 'bcrypt', require: 'bcrypt'
gem 'friendly_id'
gem 'sass-rails', '~> 5.0'
gem 'bootstrap-sass'
gem 'uglifier', '>= 1.3.0'
gem 'jquery-rails'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'puma'
gem 'rails_12factor', group: :production
gem 'newrelic_rpm'
gem 'rack-timeout'
gem 'rmagick'
gem 'aws-sdk'
gem 'paperclip'
group :development, :test do
gem 'byebug'
end
group :development do
gem 'web-console', '~> 2.0'
gem 'binding_of_caller'
gem 'better_errors'
gem 'annotate'
gem 'dotenv-rails'
gem 'spring'
end
It seems that you have defined the ruby version for your project in the Gemfile. If you comment it out then, your app could use the system version of Ruby. If you need further help please publish the code in Gemfile.

Bundle install cause strange error

I'm getting a strange error message when running bundle install or even just rails -v within a rails project root directory:
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'railties' (>= 0) among 16 total gem(s) (Gem::LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
from /usr/local/bin/rails:22:in `<main>'
However this doesn't happen in my home directory /Users/myname
I messed up something and don't know what, any help?
EDIT
Gemfile
source 'https://rubygems.org'
ruby '2.2.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0'
gem 'checkr-official'
gem 'chronic'
gem 'devise', '~> 3.4.0'
gem 'exception_notification'
gem 'friendly_id'
gem 'geocoder'
gem 'kaminari'
gem "mini_magick"
gem 'mysql2'
gem 'linkedin'
gem 'omniauth'
gem 'omniauth-facebook'
gem "omniauth-google-oauth2"
gem 'RedCloth'
gem "refile", require: "refile/rails"
gem "refile-mini_magick"
gem 'StreetAddress'
gem "stripe"
gem 'truevault', github: "marks/truevault.rb", ref: "e3bda1af6bfb355"
gem 'whenever', '~> 0.9.4'
gem 'impressionist'
gem "koala"
gem 'twilio-ruby', '~> 4.11.1'
# CSS and javascript
gem 'coffee-rails', '~> 4.1.0'
gem 'compass-rails'
gem 'ejs'
gem 'faker'
gem 'font-awesome-sass', '~> 4.3.0'
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'momentjs-rails', '>= 2.8.1'
gem 'sass-rails'
gem 'uglifier', '>= 1.3.0'
# Generic admin requirements not specified elsewhere
gem 'bootstrap-sass', '>= 3.3' # 3.3 adds better support for media css object
gem 'simple_form', ">= 3.1.0.rc2"
# google api client used for dashboard authorization for google analytics
gem 'google-api-client'
gem 'capistrano', '~> 3.4'
gem 'capistrano-rvm'
gem 'capistrano-rails'
gem "capistrano-db-tasks", require: false
group :development do
gem 'awesome_print', :require => 'ap'
end
group :development, :test do
gem "factory_girl_rails", "~> 4.0"
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
gem 'pry'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring', '1.4.0'
end
This error is probably caused by a corruption of the Rails installation.
Try running gem list. If you don't see railties in the list, run gem install rails.
If that doesn't work, I think you should try starting afresh. Create a new gemset, install bundler and run bundle install. That should fix things.

Rspec not working when rails_env=test

When I type this, everything works :
set rails_env=development
rspec spec/models/foo.rb
When I type this, my program get stuck with a deprecation warning :
set rails_env=test
rspec spec/models/foo.rb
->Rack::File headers parameter replaces cache_control after Rack 1.5.
I really need to launch my tests with rails_env=test Do you know what is going on?
Useful infos :
C:\dev>ruby --version
ruby 1.9.3p385 (2013-02-06) [i386-mingw32]
C:\dev>rails --version
Rails 3.2.12
My Gemfile :
source 'https://rubygems.org'
gem 'rails', '3.2.12'
gem 'sqlite3'
gem 'delayed_job_active_record', '= 0.3.3'
gem 'delayed_job', '= 3.0.5'
gem 'clockwork'
gem 'dj_mon'
gem 'libxml-ruby'
gem 'haml-rails'
gem 'log4r'
gem 'spreadsheet'
gem 'mail'
gem "axlsx", "= 2.0.0"
gem 'axlsx_rails'
gem 'ruby-prof'
gem 'test-unit', :require => "test/unit"
gem 'ruby-oci8', '= 2.1.4'
gem 'pg', :require => 'pg'
gem 'devise', '<= 2.2.3'
gem 'cancan', '<= 1.6.9'
gem 'validates_timeliness'
gem 'will_paginate'
gem 'nokogiri'
gem 'simplecov'
gem 'google_visualr'
gem 'thin'
gem 'workflow'
gem 'ruby-graphviz'
gem 'ruby-odbc'
gem 'rubyzip', "= 0.9.9"
gem "rspec-deep-ignore-order-matcher"
gem 'rspec'
gem 'awesome_print'
gem 'syntax'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails', '2.3.0'
group :test, :development do
gem "rspec-rails", "~> 2.0"
end
Update :
I updated my rails version to 3.2.13. The warning disapeared but my app is still stuck.
Update to rails 3.2.13 -- this was a bug fixed
https://github.com/rails/rails/pull/8812
Scroll to the bottom for the closed marker to see the note.
Fixed thanks to koffeinfre.
My test database config had a typo and I didn't know that I had logs into log/test.log.
Also, thanks to trh and Peter Alfvin for pointing out that the deprecation warning was fixed in rails 3.2.13.

Resources