When i push my app to heroku it gives me following error
-----> Ruby/Rails app detected
-----> Installing dependencies using Bundler version 1.3.2
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment
You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.
You have added to the Gemfile:
* therubyracer
!
! Failed to install gems via Bundler.
!
! Heroku push rejected, failed to compile Ruby/Rails app
I deleted my Gemlock file and again bundle install it but still gives me same error. I also tried bundle install --without development:test for production it also gives me same error What can I do. Here is my Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.9'
gem 'carrierwave'
gem 'newrelic_rpm'
#gem "less-rails" #Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS
#gem "twitter-bootstrap-rails"
gem 'will_paginate', '3.0.3'
#gem 'bootstrap-will_paginate', '0.0.6'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
#gem 'mysql2'
gem 'dynamic_form'
gem 'therubyracer', '0.10.2', :platforms => :ruby
gem 'devise'
gem 'hirb'
# Gems used for Facebook
gem 'facebook_oauth'
gem 'oauth','0.4.7'
gem 'will_paginate', '3.0.3'
gem 'bootstrap-will_paginate', '0.0.6'
gem 'thin'
gem 'pg'
# 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 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
Try run bundle install than push changes to remote repo.
Also if you use therubyracer for assets compilation, you may precompile assets locally and read this docs:
https://devcenter.heroku.com/articles/rails-asset-pipeline#compiling-assets-locally
https://devcenter.heroku.com/articles/rails-asset-pipeline#therubyracer
therubyracer gem is used to evaluate JavaScript from within Ruby(It embeds the JavaScript interpreter into Ruby).
This gem is required, if you are developing in Ubuntu since, ubuntu doesn't have a Javascript runtime.
But its not case with Heroku.
So, just keep the line for therubyracer gem in the Gemfile under development group like shown below :
group :development do
gem 'therubyracer', '0.10.2', :platforms => :ruby
end
According to Heroku docs:
If you were previously using therubyracer or therubyracer-heroku, these gems are no longer required and strongly discouraged as these gems use a very large amount of memory.
As a replacement on Ubuntu you can install NodeJS:
sudo apt-get install nodejs
Related
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.
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
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.
My simple web app runs ok on Windows 7. Now I am moving it to bluehost.
Getting this error when starting the app:
ActionView::Template::Error (cannot load such file -- uglifier
Trying to resolve it I have run 'gem install uglifier' and seems to mostly work:
SSH# gem install uglifier
Successfully installed uglifier-1.3.0
1 gem installed
Installing ri documentation for uglifier-1.3.0...
unable to convert "\xC2" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for README.md, skipping
Installing RDoc documentation for uglifier-1.3.0...
unable to convert "\xC2" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for README.md, skipping
But when I try to locate the gem, it is not found:
bundle show uglifier
yields:
Could not find gem 'uglifier' in the current bundle
Gemfile includes the following:
group :assets do
gem 'therubyracer'
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
and Gemfile.lock shows that the uglifier gem is installed:
uglifier (1.3.0)
$PATH information:
/usr/local/jdk/bin:/home4/mychairs/perl5/bin:/usr/lib64/qt-3.3/bin:/home4/mychairs/perl5/bin:/ramdisk/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11R6/bin:/home4/mychairs/ruby/gems/bin:/home4/mychairs/ruby/gems:/home4/mychairs/bin
For starters you need to add the gem to your Gemfile at the root of your Rails application. See Bundler.
Simply include the uglifier gem somewhere in the assets group of your Gemfile:
Gemfile
group :assets do
gem 'uglifier'
end
Then you run the bundle install command to install all of the required gems. You can confirm exactly what gems are installed including version information by looking at the Gemfile.lock file.
If you don't already have an assets group then make one. I highly recommend reading up on bundler.
try it with following in the app directory
#first
bundle
#then
bundle install
I took a look about this problem within the list of question but nothing helped.
This is my first question in stackoverflow so please accept my apologies in case I do something wrong. Also I still have a lot of english to improve.
I'm installing Spree following the github instructions
$ gem install spree
$ rails new my_store
$ spree install my_store
when I get this message
...
Admin Password [spree123]
gemfile spree
gemfile spree_usa_epay
gemfile spree_skrill
run bundle install from "./my_store"
git://github.com/spree/spree_usa_epay.git (at 0cb57b4) is not checked out. Please run `bundle install`
precompiling assets
git://github.com/spree/spree_usa_epay.git (at 0cb57b4) is not checked out. Please run `bundle install`
...
Well, as the guide suggests, in case of circular dependency issues do:
$ gem install spree_cmd
$spree install my_store -A
gemfile spree
gemfile spree_usa_epay
gemfile spree_skrill
run bundle install from "./my_store"
git://github.com/spree/spree_usa_epay.git (at 0cb57b4) is not checked out. Please run `bundle install`
precompiling assets
git://github.com/spree/spree_usa_epay.git (at 0cb57b4) is not checked out. Please run `bundle install`
I changed directory to the app and run the command:
$cd my_store
$bundle install
and I get the following error
Bundler could not find compatible versions for gem "rails":
In Gemfile:
spree_usa_epay (>= 0) ruby depends on
rails (<= 3.1.3, >= 3.1.1) ruby
rails (3.2.1)
after this I changed the gem file to work with rails 3.1.3 and coffeescript gems and repeat the whole process again and I get this.
Users/Snake/.rvm/gems/ruby-1.9.3-p0/gems/activerecord- 3.1.3/lib/active_record/base.rb:1088:in `method_missing': undefined method `mass_assignment_sanitizer=' for ActiveRecord::Base:Class (NoMethodError)
from /Users/Snake/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/railtie.rb:59:in `block (3 levels) in <class:Railtie>'
It think it might be something with version of rails a spree but I don't know were to start.
Does anybody had this issue before?
I running Mac OS X 10.5.8
rails 3.2.1
ruby 1.9.3p0 (2011-10-30 revision 33570) [i386-darwin9.8.0]
ImageMagick #6.7.4-6_0+q16
As #Anatoly Ruchka suggested the problem was using rails 3.2.1, so I switched to 3.1.3.
This is what I did, I found a post of #vonconrad where he explain how to create a rail project without touch the installation.
1) I create a directory folder for my project:
$mkdir old_rails313
$cd old_rails313
$touch gemfile
$nano gemfile
2)
I pasted a gemfile definition specifying as you mention the version of rails I want, so it looks like this
source 'http://rubygems.org'
gem 'rails', '3.1.3'
gem 'sqlite3'
group :assets do
gem 'sass-rails', '~> 3.1.5'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem "rspec-rails", ">= 2.8.0.rc1", :group => [:development, :test]
gem "factory_girl_rails", ">= 1.4.0", :group => :test
gem "cucumber-rails", ">= 1.2.0", :group => :test
gem "capybara", ">= 1.1.2", :group => :test
gem "database_cleaner", ">= 0.7.0", :group => :test
gem "launchy", ">= 2.0.5", :group => :test
#gem "devise", ">= 1.5.0"
gem 'spree','1.0.0'
3) then I run
bundle install
bundle exec rails new .
rails g spree:install
rails s
After installing I've got a conflict with the gem 'spree','1.0.0', so I comment it out.
Also I've got a warning but it works:
[DEPRECATION WARNING] Nested I18n namespace lookup under "activerecord.attributes.spree/order" is no longer supported
Thanks a lot
I think you should use rails version 3.1.3 for spree_usa_epay
TO do that you should uninstall all rails what you have on machine
to watch use
gem list -d rails
than
sudo gem uninstall rails -v ...
and create new project with
rails new my_store
than edit Gemfile and paste
gem 'spree', '1.0.0'
and
bundle install
well done
rails server