New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with loading FactoryGirl #1989

Closed
Quintasan opened this Issue Nov 3, 2015 · 3 comments

Comments

Projects
None yet
2 participants
@Quintasan

Quintasan commented Nov 3, 2015

I'm trying to integrate FactoryGirl into Padrino via a plugin but it fails in weird situations.

If you try to open up a console with bundle exec padrino console it works flawlessly but I can't execute any migrations. For example bundle exec padrino rake sq:migrate:up yields:

╭─quintasan@tyria  ~/Sauce/pwr/inzynierka/api ‹ruby-2.2.1@inzynierka› ‹master*› 
╰─$ bundle exec padrino rake sq:migrate:up                                                                                                                 1 ↵
=> Executing Rake sq:migrate:up ...
/home/quintasan/Sauce/pwr/inzynierka/api/lib/factory_girl.rb:5:in `<top (required)>': uninitialized constant FactoryGirl (NameError)
        from /home/quintasan/.rvm/gems/ruby-2.2.1@global/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `require'
        from /home/quintasan/.rvm/gems/ruby-2.2.1@global/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
        from /home/quintasan/.rvm/gems/ruby-2.2.1@global/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `each'
        from /home/quintasan/.rvm/gems/ruby-2.2.1@global/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `block in require'
        from /home/quintasan/.rvm/gems/ruby-2.2.1@global/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `each'
        from /home/quintasan/.rvm/gems/ruby-2.2.1@global/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `require'
        from /home/quintasan/.rvm/gems/ruby-2.2.1@global/gems/bundler-1.10.6/lib/bundler.rb:134:in `require'
        from /home/quintasan/Sauce/pwr/inzynierka/api/config/boot.rb:8:in `<top (required)>'
        from /home/quintasan/.rvm/gems/ruby-2.2.1@inzynierka/gems/padrino-core-0.12.5/lib/padrino-core/cli/rake_tasks.rb:26:in `require'
        from /home/quintasan/.rvm/gems/ruby-2.2.1@inzynierka/gems/padrino-core-0.12.5/lib/padrino-core/cli/rake_tasks.rb:26:in `block in <top (required)>'
        from /home/quintasan/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/rake-10.4.2/lib/rake/task.rb:240:in `call'
        from /home/quintasan/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
        from /home/quintasan/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
        from /home/quintasan/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
        from /home/quintasan/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
        from /home/quintasan/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
        from /home/quintasan/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
        from /home/quintasan/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/rake-10.4.2/lib/rake/task.rb:201:in `block in invoke_prerequisites'
        from /home/quintasan/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/rake-10.4.2/lib/rake/task.rb:199:in `each'
        from /home/quintasan/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/rake-10.4.2/lib/rake/task.rb:199:in `invoke_prerequisites'
        from /home/quintasan/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/rake-10.4.2/lib/rake/task.rb:178:in `block in invoke_with_call_chain'
        from /home/quintasan/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
        from /home/quintasan/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
        from /home/quintasan/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
        from /home/quintasan/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/rake-10.4.2/lib/rake/application.rb:150:in `invoke_task'
        from /home/quintasan/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
        from /home/quintasan/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `each'
        from /home/quintasan/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `block in top_level'
        from /home/quintasan/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/rake-10.4.2/lib/rake/application.rb:115:in `run_with_threads'
        from /home/quintasan/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/rake-10.4.2/lib/rake/application.rb:100:in `top_level'
        from /home/quintasan/.rvm/gems/ruby-2.2.1@inzynierka/gems/padrino-core-0.12.5/lib/padrino-core/cli/base.rb:23:in `rake'
        from /home/quintasan/.rvm/gems/ruby-2.2.1@inzynierka/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
        from /home/quintasan/.rvm/gems/ruby-2.2.1@inzynierka/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
        from /home/quintasan/.rvm/gems/ruby-2.2.1@inzynierka/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
        from /home/quintasan/.rvm/gems/ruby-2.2.1@inzynierka/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
        from /home/quintasan/.rvm/gems/ruby-2.2.1@inzynierka/gems/padrino-core-0.12.5/bin/padrino:9:in `<top (required)>'
        from /home/quintasan/.rvm/gems/ruby-2.2.1@inzynierka/bin/padrino:23:in `load'
        from /home/quintasan/.rvm/gems/ruby-2.2.1@inzynierka/bin/padrino:23:in `<main>'

I tried debugging it with pry but when I try require "factory_girl" i get false instead of true.

To check it out just create a padrino project and apply the plugin. Am I doing it wrong or there is a problem?

@Quintasan

This comment has been minimized.

Show comment
Hide comment
@Quintasan

Quintasan Dec 30, 2015

I have managed to narrow it down to FactoryGirl constant not being defined despite FactoryGirl being loaded. Changing the plugin to

begin
  require 'factory_girl'
  Object.constants.include?(:FactoryGirl)
rescue LoadError
end

yields false.

Unfortunately I have no idea where to look now. Any ideas?

Quintasan commented Dec 30, 2015

I have managed to narrow it down to FactoryGirl constant not being defined despite FactoryGirl being loaded. Changing the plugin to

begin
  require 'factory_girl'
  Object.constants.include?(:FactoryGirl)
rescue LoadError
end

yields false.

Unfortunately I have no idea where to look now. Any ideas?

@Quintasan

This comment has been minimized.

Show comment
Hide comment
@Quintasan

Quintasan Dec 30, 2015

PR #88 @ padrino-recipes fixes this issue.

There remains one question - why is LOAD_PATH including "." when doing rake tasks but not when starting console?

Quintasan commented Dec 30, 2015

PR #88 @ padrino-recipes fixes this issue.

There remains one question - why is LOAD_PATH including "." when doing rake tasks but not when starting console?

@ujifgc

This comment has been minimized.

Show comment
Hide comment
@ujifgc

ujifgc Jan 15, 2016

Member

It's not including ".", it includes "lib" when you run padrino rake instead of rake:

$LOAD_PATH.unshift(File.expand_path("lib"))

I will remove this unshift soon. Thanks for your report.

Member

ujifgc commented Jan 15, 2016

It's not including ".", it includes "lib" when you run padrino rake instead of rake:

$LOAD_PATH.unshift(File.expand_path("lib"))

I will remove this unshift soon. Thanks for your report.

@ujifgc ujifgc added the bug label Jan 15, 2016

ujifgc added a commit that referenced this issue Jan 27, 2016

@ujifgc ujifgc added this to the 0.14.0 milestone Feb 7, 2016

@ujifgc ujifgc closed this Mar 21, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment