After heroku rake db:migrate I get the following error:
rake aborted!
no such file to load -- faker
/app/Rakefile:7
(See full trace by running task with --trace)
(in /app)*
I saw previous answers and I tried to shift require 'faker' from the first line to the line below task :populate => :environment do in my sample_data.rake file. It didn't work.
I commented faker in the gemfile (and it was present only in the dev environment) and I executed a bundle install. It didn't work.
I'm really scared about the fact that I can't use faker with heroku. Could you please help me?
Is faker part of your production gems (outside of any groups) in your Gemfile?
Heroku does not install test or development gems by default.
So, you could, for example, simply change
source 'http://rubygems.org'
gem 'rails', '3.0.7'
gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'mysql'
group :development do
gem 'faker'
end
to
source 'http://rubygems.org'
gem 'rails', '3.0.7'
gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'mysql'
gem 'faker'
Alternatively...
You can instruct Heroku to install development gems by changing the Heroku environment variable BUNDLE_WITHOUT, which lists groups to exclude.
The default is:
heroku config:set BUNDLE_WITHOUT="development:test"
so you might use something like:
heroku config:set BUNDLE_WITHOUT="test"
However, if your application requires the use of faker in its production environment, you should probably just include the gem in the default Gemfile group.
you may also
group :development do
gem 'faker', :require=>false
end
(or)
put the require 'faker' line of you rake file to be inside the task
Related
We have a react-rails app. Unfortunately, the app works on local development but not when deployed to heroku. When going to our default path on the app, we get the following error:
ActionView::Template::Error (undefined method 'directory' for #<Sprockets::Manifest:0x007fef13200aa8>)
We've figured out that it happens at this line in our view:
<%= react_component('NavBar', {}, {prerender: true}) %>
A few things about our app:
It uses browserify to compile our js.jsx.
We precompile using RAILS_ENV=production bundle exec rake assets:precompile after deleting the public/assets folder.
Works locally with both rails s and foreman start
We are using boostrap-sprockets. Even when removed, we still have this issue.
Here is our npm dependencies:
"dependencies": {
"browserify": "^10.2.4",
"browserify-incremental": "^1.5.0",
"classnames": "^2.2.3",
"reactify": "^1.1.0"
}
Here is our Gemfile
source 'https://rubygems.org'
gem 'rails', '4.2.3'
gem 'rails-api'
gem 'spring', :group => :development
gem 'active_model_serializers', '~> 0.10.0.rc1'
gem 'pg'
gem 'devise'
gem 'puma'
gem 'twitter'
gem 'react-rails', '~> 1.0'
gem 'browserify-rails', '~> 0.9.1'
gem 'bootstrap-sass', '~> 3.2.0'
gem 'sass-rails', '~> 5.0', '>= 5.0.4'
gem 'autoprefixer-rails'
group :test do
gem 'rspec-rails'
gem 'pry'
gem 'faker'
gem 'webmock'
end
group :development, :test do
gem 'factory_girl_rails'
end
group :production do
gem 'uglifier'
gem 'rails_12factor'
gem 'rspec'
end
ruby '2.2.4'
We would appreciate all help.
The solution from hours of searching on StackOverflow and github issues seems to be to remove
//= require react_ujs
from your application.js in your assets folder.
I ran into this same issue just today and followed the suggestions in: https://github.com/reactjs/react-rails/issues/443#issuecomment-180544359. I was still running into an error so for now I modified my heroku configurations (config/environments/staging.rb & config/environments/production.rb) to use
config.assets.compile = true
for now and server-side rendering worked fine. The react-rails folks said they have a pull request completed to fix this issue but I dont think it has been released yet.
Potentially relevant: rake assets:precompile undefined method directory? for nil:NilClass
This is an error that occurs when the Rails asset compiler (Sprockets) cannot find a directory that you've specified as the location of an asset for your project. My suggestion is to make sure that all your assets are being successfully deployed to heroku, and then check that your paths are set up correctly when you reference assets in your project for inclusion in a page.
Also see Eric C's answer pertaining to React-Rails specifically.
There was a bug in react-rails 1.6.0 which should be fixed in 1.6.1
Here's the patch:
https://github.com/reactjs/react-rails/pull/478
If the latest version doesn't work for you, please open an issue on the react-rails repo!
I have a Ruby Motion project, and I want to add Interface Builder to it.
I've added the gem:
gem 'ib'
But when I run bundle exec rake ib, I get Don't know how to build task 'ib'
Does any one know what I might be doing wrong? here is my gemfile:
source "https://rubygems.org"
gem "rake"
gem "ProMotion", '~> 2.0'
gem "ProMotion-push", git: 'git#github.com:BananaNeil/ProMotion-push.git', :branch => 'actionable-push-notifications'
gem "cocoapods"
gem "motion-cocoapods"
gem 'xcodeproj'
gem "bubble-wrap-http", git: 'git#github.com:BananaNeil/BubbleWrap-HTTP.git', branch: 'allow_invalid_ssl_certs'
gem "bubble-wrap"
gem "sugarcube" # monkeypatch all the things
gem "motion-yaml"
gem "motion-stump"
gem 'houston'
# Enter debugger with simple syntax
gem 'dbt' #-----> break
# Add pretty print
gem 'motion-pp'
# Handle address book for us
gem 'motion-addressbook'
gem 'ib'
Make sure to require 'ib' inside the Rakefile, either with Bundler or manually for each gem.
And if you use Bundler, you might need to remove the begin/catch guard, because it will silence all import related errors.
I just upgraded Padrino from version 0.10.5 to 0.12.1 and now none of my Rake tasks work anymore.
A simple case I just added:
# PROJECT_ROOT/lib/tasks/example_task.rake
task :example_task do
puts "Is this working?"
end
Running rake example_task gives:
rake aborted!
Don't know how to build task 'example_task'
Running padrino rake example_task gives:
=> Executing Rake example_task ...
/Users/george/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/rake/task_manager.rb:49:in `[]': Don't know how to build task 'example_task' (RuntimeError)
Padrino's docs say that Padrino should automatically detect any *.rake files in lib/tasks, and these worked before I upgraded Padrino. What's the problem?
My Gemfile:
source 'https://rubygems.org'
ruby '2.1.0'
gem 'rake'
gem 'unicorn'
gem 'rack_hoptoad', require: 'rack/hoptoad'
gem 'haml'
gem 'bson_ext'
gem 'mongo'
gem 'mongoid', '~> 3.1.6'
gem 'httparty'
group :development, :test do
gem 'debugger'
gem 'fabrication', '~> 1.3.1'
gem 'zippy'
gem 'rubyzip', '~> 0.9.9'
end
group :test do
gem 'mocha', '~> 0.10.4'
gem 'rspec', '~> 2.8.0'
gem 'capybara', '~> 1.1.2'
gem 'launchy'
gem 'cucumber', '~> 1.1.8'
end
gem 'tilt', '~> 1.4.1'
gem 'padrino', '~> 0.12.1'
gem 'padrino-cookies', '~> 0.1.2'
According to bundle show rake, I'm using rake version 10.3.1.
What am I doing wrong?
Well, that was a waste of a bounty.
I opened an issue on Github and got an answer there. I needed to make the following changes to the top of config/boot.rb... (this is taken from the output of git diff, so note that lines which start with - were removed and lines which start with + were added.)
-begin
- # Require the preresolved locked set of gems.
- require File.expand_path('../../.bundle/environment', __FILE__)
-rescue LoadError
- # Fallback on doing the resolve at runtime.
- require 'rubygems'
- require 'bundler'
- Bundler.setup
-end
-
+require 'rubygems' unless defined?(Gem)
+require 'bundler/setup'
And add these lines to my Rakefile:
+require 'bundler/setup'
+require 'padrino-core/cli/rake'
+
+PadrinoTasks.use(:database)
+PadrinoTasks.use(:mongoid)
+PadrinoTasks.init
Now my rake tasks work as normal. Yay!
Use this pattern and it will work with new version of Padrino without any core changes:
# ./lib/tasks/seed_fonts.rake
namespace :fonts do
desc "Seen the fonts into database table db.fonts"
task :seed_fonts => :environment do
# Do your thing ...
end
end
I go to redeploy my heroku apps with a new gem in Gemfile and it crashes on startup
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require': libruby.so.1.9: cannot open shared object file: No such file or directory - /app/vendor/bundle/ruby/1.9.1/gems/bcrypt-ruby-3.0.1/lib/bcrypt_ext.so (LoadError)
This is happening no matter what branch I deploy (old stable ones...) and only fixes by doing a heroku rollback.
I believe this is caused by heroku recently updating their ruby 1.9.3 because I was having this issue Heroku app crashes with 'libruby.so.1.9: cannot open shared object file' . Removing the nokogiri gem stopped the exception I was getting but then there's still this. More similar errors occur when I add new gems.
The whole problem was solved by deploying to a new heroku app but that's not something I can just do on my production server.
Any ideas on fixing the issue or somehow "refreshing" my app?
my gemfile:
source "https://rubygems.org"
ruby "1.9.3"
gem "rails", "3.2.3"
gem "thin"
# Bundle edge Rails instead:
# gem "rails", :git => "git://github.com/rails/rails.git"
gem "mongoid"
gem "devise"
gem "haml"
gem "sass"
gem "exceptional"
gem "kaminari"
gem "mongoid_search"
#gem "nokogiri"
gem "bson_ext"
gem "heroku-mongo-backup"
gem "aws-s3"
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem "haml-rails", "~> 0.3.4"
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", :platform => :ruby
gem "uglifier", ">= 1.0.3"
end
gem "jquery-rails"
group :test do
gem "mongoid-rspec"
end
# 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 "ruby-debug19", :require => "ruby-debug"
#
group :development do
gem "letter_opener"
end
Just FYI,
After contacting the Heroku support about this issue, you should follow these 3 simple steps:
Install this heroku-repo plugin: heroku plugins:install https://github.com/lstoll/heroku-repo.git
Run the following command: heroku repo:purge_cache
Deploy your app again.
Hope that helps!
This happened to me yesterday as well, was definitely something to do with Heroku.
I found fix and discussion on Twitter: https://twitter.com/bcardarella/status/256822171979100161
Just force-clear the gem file cache(clear gemfile, deploy, restore and deploy) and the app would start smoothly again.
I am trying to test coffee script in my rails 3.1 project, but it doesn't get executed, or generated as javascript in the application.js
I have a controller Page, here is the pages.js.coffee:
test = (input) ->
alert input
test 'hello'
but that alert never get executed at http://127.0.0.1:3000/pages,
in fact, the application.js is just empty!
here is the GemFile in case it would help:
source 'http://rubygems.org'
gem 'rails', '3.1.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
gem 'devise', '1.4.8'
gem 'will_paginate', '~> 3.0.2'
#gem 'nested_form', :git => 'git://github.com/fxposter/nested_form.git'
gem "simple_form"
gem 'kaminari'
gem 'foreigner'
gem "cocoon"
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', " ~> 3.1.0"
gem 'coffee-rails', "~> 3.1.0"
gem 'uglifier'
end
gem "jquery-rails"
gem 'coffee-script'
gem 'haml'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
group :test do
# Pretty printed test output
gem 'turn', :require => false
end
EDIT
I have added those gems also and installed them, but, the coffee script is not executed
gem 'therubyracer'
gem 'coffee-script-source'
gem 'json'
gem 'execjs'
First: Having "coffee-rails" in your :assets group should be enough. Older versions had "coffee-script" in the :assets group.
Second: Where are you keeping your *.js.coffee files? You need to make sure they are in an "assets" folder some place. Start with app/assets/javascripts. If they aren't in your assets folder, they won't make it into the asset pipeline.
If you are doing that already, consider starting a new project and use the default configuration. It should work without any trouble. Compare the working project against the non-working project.
If all else fails, is it possible for you to share your project with us on GitHub?
Please check your config/application.rb, you should find a section like this:
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
#Bundler.require(:default, :assets, Rails.env)
end
I suspect you are not precompiling assets on deploy, even though you have it set to ignore the assets gems.