Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku db:migrate and faker

Tags:

heroku

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?

like image 578
Max Bond Avatar asked Dec 17 '22 14:12

Max Bond


1 Answers

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.

like image 170
Michelle Tilley Avatar answered Dec 28 '22 22:12

Michelle Tilley