Skip to content
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

Could not find command activerecord #9

Open
harrylove opened this issue Jan 28, 2015 · 18 comments
Open

Could not find command activerecord #9

harrylove opened this issue Jan 28, 2015 · 18 comments

Comments

@harrylove
Copy link

Executing neo4apis activerecord --help from the terminal on Mac 10.10.1 results in message "Could not find command activerecord"

neo4apis-activerecord gem installed with RVM.

@cheerfulstoic
Copy link
Contributor

Somebody else was having this problem, and I just realized how to debug it. Looking at it now

@cheerfulstoic
Copy link
Contributor

Ok, I just released a 0.5.1 version of neo4apis which I think will fix the problem. A couple of notes:

Make sure to update the version of the base neo4apis gem. You may need to uninstall / reinstall the gems to make sure

This fix will only work for rubygems, not any other gem package managers. I wanted to get something out there, but if you use something else let me know and we can see if we can find a solution.

Last, when you run the command you're likely to get the following message:

NOTE: Specification.all called from /Users/brian/.rvm/gems/ruby-2.2.0/gems/neo4apis-0.5.1/bin/neo4apis:8:in `<top (required)>'

I'm not sure why that's outputting, but I'll look at it later.

Thanks! Let me know if that worked for you

@harrylove
Copy link
Author

Thanks for looking at it.

The specification warning note comes from here: https://github.com/rubygems/rubygems/blob/master/lib/rubygems/specification.rb#L820

When I run the command now I get the warning message followed by this:

WARN: Unresolved specs during Gem::Specification.reset:
      minitest (~> 5.1)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
Importing tables: [table list]
/Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/faraday_middleware-0.9.1/lib/faraday_middleware.rb:25:in `block in <module:FaradayMiddleware>': cannot load such file -- faraday_middleware/request/encode_json (LoadError)
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/faraday-0.9.1/lib/faraday.rb:215:in `call'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/faraday-0.9.1/lib/faraday.rb:215:in `block in load_middleware'
    from /Users/harry/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/faraday-0.9.1/lib/faraday.rb:197:in `middleware_mutex'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/faraday-0.9.1/lib/faraday.rb:214:in `load_middleware'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/faraday-0.9.1/lib/faraday.rb:188:in `lookup_middleware'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/faraday-0.9.1/lib/faraday/rack_builder.rb:203:in `use_symbol'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/faraday-0.9.1/lib/faraday/rack_builder.rb:92:in `request'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4j-core-4.0.1/lib/neo4j-server/cypher_session.rb:30:in `block in create_connection'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/faraday-0.9.1/lib/faraday/connection.rb:91:in `initialize'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/faraday-0.9.1/lib/faraday.rb:70:in `new'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/faraday-0.9.1/lib/faraday.rb:70:in `new'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4j-core-4.0.1/lib/neo4j-server/cypher_session.rb:28:in `create_connection'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4j-core-4.0.1/lib/neo4j-server/cypher_session.rb:48:in `open'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4j-core-4.0.1/lib/neo4j-server/cypher_session.rb:5:in `block in <module:Server>'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4j-core-4.0.1/lib/neo4j/session.rb:111:in `call'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4j-core-4.0.1/lib/neo4j/session.rb:111:in `create_session'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4j-core-4.0.1/lib/neo4j/session.rb:98:in `open'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4apis-activerecord-0.6.1/lib/neo4apis/cli/activerecord.rb:94:in `neo4apis_client'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4apis-activerecord-0.6.1/lib/neo4apis/cli/activerecord.rb:66:in `import_models_or_tables'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4apis-activerecord-0.6.1/lib/neo4apis/cli/activerecord.rb:52:in `all_models'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/thor-0.19.1/lib/thor/invocation.rb:115:in `invoke'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/thor-0.19.1/lib/thor.rb:235:in `block in subcommand'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4apis-0.5.1/bin/neo4apis:14:in `<top (required)>'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/bin/neo4apis:23:in `load'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/bin/neo4apis:23:in `<main>'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/bin/ruby_executable_hooks:15:in `eval'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/bin/ruby_executable_hooks:15:in `<main>'

@cheerfulstoic
Copy link
Contributor

Interesting, it looks like you ran the all_models command. Is this in an existing ruby app with ActiveRecord models? What was the full command that you ran?

@harrylove
Copy link
Author

Correct. Rails 4.2 app.

neo4apis activerecord all_models --import-all-associations

@cheerfulstoic
Copy link
Contributor

Oh, right, forgot to ask: What port is your neo4j server running on? If it's something other than 7474 than you need to use the --neo4j-url argument.

I doubt that's it though...

@subvertallchris Could you have a look since you've worked with Faraday more than me (and it's way past my bedtime ;)? The last line in our world is this:

https://github.com/neo4jrb/neo4j-core/blob/master/lib/neo4j-server/cypher_session.rb#L30

@harrylove
Copy link
Author

If it helps, here's the Gemfile.lock

GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (4.2.0)
      actionpack (= 4.2.0)
      actionview (= 4.2.0)
      activejob (= 4.2.0)
      mail (~> 2.5, >= 2.5.4)
      rails-dom-testing (~> 1.0, >= 1.0.5)
    actionpack (4.2.0)
      actionview (= 4.2.0)
      activesupport (= 4.2.0)
      rack (~> 1.6.0)
      rack-test (~> 0.6.2)
      rails-dom-testing (~> 1.0, >= 1.0.5)
      rails-html-sanitizer (~> 1.0, >= 1.0.1)
    actionview (4.2.0)
      activesupport (= 4.2.0)
      builder (~> 3.1)
      erubis (~> 2.7.0)
      rails-dom-testing (~> 1.0, >= 1.0.5)
      rails-html-sanitizer (~> 1.0, >= 1.0.1)
    activejob (4.2.0)
      activesupport (= 4.2.0)
      globalid (>= 0.3.0)
    activemodel (4.2.0)
      activesupport (= 4.2.0)
      builder (~> 3.1)
    activerecord (4.2.0)
      activemodel (= 4.2.0)
      activesupport (= 4.2.0)
      arel (~> 6.0)
    activesupport (4.2.0)
      i18n (~> 0.7)
      json (~> 1.7, >= 1.7.7)
      minitest (~> 5.1)
      thread_safe (~> 0.3, >= 0.3.4)
      tzinfo (~> 1.1)
    arel (6.0.0)
    awesome_print (1.6.1)
    binding_of_caller (0.7.2)
      debug_inspector (>= 0.0.1)
    builder (3.2.2)
    byebug (3.5.1)
      columnize (~> 0.8)
      debugger-linecache (~> 1.2)
      slop (~> 3.6)
    celluloid (0.16.0)
      timers (~> 4.0.0)
    choice (0.1.7)
    coffee-rails (4.1.0)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0, < 5.0)
    coffee-script (2.3.0)
      coffee-script-source
      execjs
    coffee-script-source (1.8.0)
    columnize (0.9.0)
    connection_pool (2.1.1)
    debug_inspector (0.0.2)
    debugger-linecache (1.2.0)
    erubis (2.7.0)
    execjs (2.2.2)
    faker (1.4.3)
      i18n (~> 0.5)
    font-awesome-rails (4.3.0.0)
      railties (>= 3.2, < 5.0)
    globalid (0.3.0)
      activesupport (>= 4.1.0)
    guard-compat (1.2.1)
    guard-minitest (2.4.2)
      guard-compat (~> 1.2)
      minitest (>= 3.0)
    haml (4.0.6)
      tilt
    hike (1.2.3)
    hitimes (1.2.2)
    i18n (0.7.0)
    jbuilder (2.2.6)
      activesupport (>= 3.0.0, < 5)
      multi_json (~> 1.2)
    jquery-rails (4.0.3)
      rails-dom-testing (~> 1.0)
      railties (>= 4.2.0)
      thor (>= 0.14, < 2.0)
    jquery-ui-rails (5.0.3)
      railties (>= 3.2.16)
    json (1.8.2)
    kaminari (0.16.2)
      actionpack (>= 3.0.0)
      activesupport (>= 3.0.0)
    loofah (2.0.1)
      nokogiri (>= 1.5.9)
    mail (2.6.3)
      mime-types (>= 1.16, < 3)
    mime-types (2.4.3)
    mini_portile (0.6.2)
    minitest (5.5.1)
    multi_json (1.10.1)
    nested_form (0.3.2)
    newrelic_rpm (3.9.9.275)
    nokogiri (1.6.6.2)
      mini_portile (~> 0.6.0)
    pg (0.18.1)
    rack (1.6.0)
    rack-pjax (0.8.0)
      nokogiri (~> 1.5)
      rack (~> 1.1)
    rack-protection (1.5.3)
      rack
    rack-test (0.6.3)
      rack (>= 1.0)
    rails (4.2.0)
      actionmailer (= 4.2.0)
      actionpack (= 4.2.0)
      actionview (= 4.2.0)
      activejob (= 4.2.0)
      activemodel (= 4.2.0)
      activerecord (= 4.2.0)
      activesupport (= 4.2.0)
      bundler (>= 1.3.0, < 2.0)
      railties (= 4.2.0)
      sprockets-rails
    rails-deprecated_sanitizer (1.0.3)
      activesupport (>= 4.2.0.alpha)
    rails-dom-testing (1.0.5)
      activesupport (>= 4.2.0.beta, < 5.0)
      nokogiri (~> 1.6.0)
      rails-deprecated_sanitizer (>= 1.0.1)
    rails-erd (1.1.0)
      activerecord (>= 3.0)
      activesupport (>= 3.0)
      choice (~> 0.1.6)
      ruby-graphviz (~> 1.0.4)
    rails-html-sanitizer (1.0.1)
      loofah (~> 2.0)
    rails_admin (0.6.6)
      builder (~> 3.1)
      coffee-rails (~> 4.0)
      font-awesome-rails (>= 3.0, < 5)
      haml (~> 4.0)
      jquery-rails (>= 3.0, < 5)
      jquery-ui-rails (~> 5.0)
      kaminari (~> 0.14)
      nested_form (~> 0.3)
      rack-pjax (~> 0.7)
      rails (~> 4.0)
      remotipart (~> 1.0)
      safe_yaml (~> 1.0)
      sass-rails (>= 4.0, < 6)
    railties (4.2.0)
      actionpack (= 4.2.0)
      activesupport (= 4.2.0)
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (10.4.2)
    rdoc (4.2.0)
    redis (3.2.0)
    redis-namespace (1.5.1)
      redis (~> 3.0, >= 3.0.4)
    remotipart (1.2.1)
    ruby-graphviz (1.0.9)
    safe_yaml (1.0.4)
    sass (3.4.10)
    sass-rails (5.0.1)
      railties (>= 4.0.0, < 5.0)
      sass (~> 3.1)
      sprockets (>= 2.8, < 4.0)
      sprockets-rails (>= 2.0, < 4.0)
      tilt (~> 1.1)
    sdoc (0.4.1)
      json (~> 1.7, >= 1.7.7)
      rdoc (~> 4.0)
    sidekiq (3.3.1)
      celluloid (>= 0.16.0)
      connection_pool (>= 2.1.1)
      json
      redis (>= 3.0.6)
      redis-namespace (>= 1.3.1)
    sinatra (1.4.5)
      rack (~> 1.4)
      rack-protection (~> 1.4)
      tilt (~> 1.3, >= 1.3.4)
    slop (3.6.0)
    spring (1.2.0)
    sprockets (2.12.3)
      hike (~> 1.2)
      multi_json (~> 1.0)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    sprockets-rails (2.2.4)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      sprockets (>= 2.8, < 4.0)
    thor (0.19.1)
    thread_safe (0.3.4)
    tilt (1.4.1)
    timers (4.0.1)
      hitimes
    turbolinks (2.5.3)
      coffee-rails
    tzinfo (1.2.2)
      thread_safe (~> 0.1)
    uglifier (2.7.0)
      execjs (>= 0.3.0)
      json (>= 1.8.0)
    web-console (2.0.0)
      activemodel (~> 4.0)
      binding_of_caller (>= 0.7.2)
      railties (~> 4.0)
      sprockets-rails (>= 2.0, < 4.0)

PLATFORMS
  ruby

DEPENDENCIES
  awesome_print
  byebug
  faker
  guard-minitest
  jbuilder
  jquery-rails
  newrelic_rpm
  pg
  rails (= 4.2.0)
  rails-erd
  rails_admin
  sass-rails
  sdoc
  sidekiq
  sinatra (>= 1.3.0)
  spring
  turbolinks
  uglifier
  web-console

@harrylove
Copy link
Author

I use the default 7474 as the neo4j port.

@cheerfulstoic
Copy link
Contributor

I'm looking, but I can't quite figure it out. It seems to be something in the faraday_middleware gem, but as far as I can see it should work fine. I'm also testing it and it's working for me. How many tables were in that table list, BTW?

Did you add neo4apis-activerecord to your Gemfile or did you use gem install neo4apis-activerecord?

@harrylove
Copy link
Author

There are about 20 tables. I installed the gem via RubyGems. Trying again with the gem in my Gemfile, I get a new error.

NOTE: Specification.all called from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4apis-0.5.1/bin/neo4apis:8:in `<top (required)>'
Importing tables: [table list]
/Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/activerecord-4.2.0/lib/active_record/associations/preloader/association.rb:107:in `association_key_type': undefined method `type_for_attribute' for :part:Symbol (NoMethodError)
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/activerecord-4.2.0/lib/active_record/associations/preloader/association.rb:103:in `key_conversion_required?'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/activerecord-4.2.0/lib/active_record/associations/preloader/association.rb:60:in `owners_by_key'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/activerecord-4.2.0/lib/active_record/associations/preloader/association.rb:78:in `associated_records_by_owner'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/activerecord-4.2.0/lib/active_record/associations/preloader/collection_association.rb:13:in `preload'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/activerecord-4.2.0/lib/active_record/associations/preloader/association.rb:20:in `run'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/activerecord-4.2.0/lib/active_record/associations/preloader.rb:146:in `block (2 levels) in preloaders_for_one'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/activerecord-4.2.0/lib/active_record/associations/preloader.rb:144:in `each'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/activerecord-4.2.0/lib/active_record/associations/preloader.rb:144:in `map'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/activerecord-4.2.0/lib/active_record/associations/preloader.rb:144:in `block in preloaders_for_one'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/activerecord-4.2.0/lib/active_record/associations/preloader.rb:143:in `each'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/activerecord-4.2.0/lib/active_record/associations/preloader.rb:143:in `flat_map'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/activerecord-4.2.0/lib/active_record/associations/preloader.rb:143:in `preloaders_for_one'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/activerecord-4.2.0/lib/active_record/associations/preloader.rb:115:in `preloaders_on'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/activerecord-4.2.0/lib/active_record/associations/preloader.rb:103:in `block in preload'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/activerecord-4.2.0/lib/active_record/associations/preloader.rb:102:in `each'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/activerecord-4.2.0/lib/active_record/associations/preloader.rb:102:in `flat_map'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/activerecord-4.2.0/lib/active_record/associations/preloader.rb:102:in `preload'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/activerecord-4.2.0/lib/active_record/relation.rb:644:in `block in exec_queries'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/activerecord-4.2.0/lib/active_record/relation.rb:643:in `each'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/activerecord-4.2.0/lib/active_record/relation.rb:643:in `exec_queries'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/activerecord-4.2.0/lib/active_record/relation.rb:514:in `load'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/activerecord-4.2.0/lib/active_record/relation.rb:243:in `to_a'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/activerecord-4.2.0/lib/active_record/relation/batches.rb:117:in `find_in_batches'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/activerecord-4.2.0/lib/active_record/relation/batches.rb:50:in `find_each'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4apis-activerecord-0.6.1/lib/neo4apis/cli/activerecord.rb:76:in `block (2 levels) in import_models_or_tables'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4apis-activerecord-0.6.1/lib/neo4apis/cli/activerecord.rb:67:in `each'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4apis-activerecord-0.6.1/lib/neo4apis/cli/activerecord.rb:67:in `block in import_models_or_tables'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4apis-0.5.1/lib/neo4apis/base.rb:54:in `batch'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4apis-activerecord-0.6.1/lib/neo4apis/cli/activerecord.rb:66:in `import_models_or_tables'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4apis-activerecord-0.6.1/lib/neo4apis/cli/activerecord.rb:52:in `all_models'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/thor-0.19.1/lib/thor/invocation.rb:115:in `invoke'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/thor-0.19.1/lib/thor.rb:235:in `block in subcommand'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4apis-0.5.1/bin/neo4apis:14:in `<top (required)>'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/bin/neo4apis:23:in `load'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/bin/neo4apis:23:in `<main>'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/bin/ruby_executable_hooks:15:in `eval'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/bin/ruby_executable_hooks:15:in `<main>'

@harrylove
Copy link
Author

I also tried importing a single model which references another model. Here are the migrations:

class CreateCompanies < ActiveRecord::Migration
  def change
    create_table :companies do |t|
      t.string :name
      t.timestamps
    end
  end
end
class CreateDealers < ActiveRecord::Migration
  def change
    create_table :dealers do |t|
      t.references :company, index: true
      t.integer :rank, default: 1  
      t.timestamps
    end
  end
end

And then I ran this command from the terminal:
neo4apis activerecord models Dealer --import-all-associations

The result was this:

NOTE: Specification.all called from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4apis-0.5.1/bin/neo4apis:8:in `<top (required)>'
Importing tables: dealers
/Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4apis-0.5.1/lib/neo4apis/base.rb:35:in `add_node': No UUID specified for label `Company` (ArgumentError)
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4apis-activerecord-0.6.1/lib/neo4apis/activerecord.rb:49:in `add_model_node'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4apis-activerecord-0.6.1/lib/neo4apis/activerecord.rb:37:in `add_model_relationship'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4apis-activerecord-0.6.1/lib/neo4apis/activerecord.rb:22:in `block (2 levels) in model_importer'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4apis-activerecord-0.6.1/lib/neo4apis/activerecord.rb:17:in `each'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4apis-activerecord-0.6.1/lib/neo4apis/activerecord.rb:17:in `block in model_importer'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4apis-0.5.1/lib/neo4apis/base.rb:62:in `instance_exec'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4apis-0.5.1/lib/neo4apis/base.rb:62:in `import'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4apis-activerecord-0.6.1/lib/neo4apis/cli/activerecord.rb:77:in `block (3 levels) in import_models_or_tables'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/activerecord-4.2.0/lib/active_record/relation/batches.rb:51:in `block (2 levels) in find_each'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/activerecord-4.2.0/lib/active_record/relation/batches.rb:51:in `each'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/activerecord-4.2.0/lib/active_record/relation/batches.rb:51:in `block in find_each'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/activerecord-4.2.0/lib/active_record/relation/batches.rb:124:in `find_in_batches'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/activerecord-4.2.0/lib/active_record/relation/batches.rb:50:in `find_each'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4apis-activerecord-0.6.1/lib/neo4apis/cli/activerecord.rb:76:in `block (2 levels) in import_models_or_tables'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4apis-activerecord-0.6.1/lib/neo4apis/cli/activerecord.rb:67:in `each'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4apis-activerecord-0.6.1/lib/neo4apis/cli/activerecord.rb:67:in `block in import_models_or_tables'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4apis-0.5.1/lib/neo4apis/base.rb:54:in `batch'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4apis-activerecord-0.6.1/lib/neo4apis/cli/activerecord.rb:66:in `import_models_or_tables'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4apis-activerecord-0.6.1/lib/neo4apis/cli/activerecord.rb:36:in `models'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/thor-0.19.1/lib/thor/invocation.rb:115:in `invoke'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/thor-0.19.1/lib/thor.rb:235:in `block in subcommand'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/gems/neo4apis-0.5.1/bin/neo4apis:14:in `<top (required)>'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/bin/neo4apis:23:in `load'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/bin/neo4apis:23:in `<main>'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/bin/ruby_executable_hooks:15:in `eval'
    from /Users/harry/.rvm/gems/ruby-2.2.0@dealerdbsql/bin/ruby_executable_hooks:15:in `<main>'

@cheerfulstoic
Copy link
Contributor

First off, thanks for your help! This is really useful.

There errors are looking more tractable! I'm looking deeper, but I have a couple of questions first:

Can you share the model (or a stripped down version) of the one from your app when you just tried to import one?

For the second thing that you tried, do you also have ActiveRecord models for the dealers/companies tables? If not, then neo4apis-activerecord is probably trying to generate models, but it's not generating one for Company since you didn't specify it.

I actually need to sit down and fix that. Right now on the command like if you specify models or tables, it actually (mostly) does the same thing and lets you specify either models or tables and it uses the ActiveSupport#Inflectors module to get what it needs. I should be more strict about that because if you haven't defined a model is your ruby application, it shouldn't try to generate one.

@cheerfulstoic
Copy link
Contributor

Is parts one of your tables? I'm trying to figure out why it seems to think that @klass is equal to :part on this line:

https://github.com/rails/rails/blob/master/activerecord/lib/active_record/associations/preloader/association.rb#L107

I don't think I'll be able to fix it tonight and I'll be busy this weekend, but I'll take another look again soon. Thanks!

@harrylove
Copy link
Author

Yes, parts is a table in the original import. Except for one join table, every table has an associated AR model defined in the usual Rails way.

@harrylove
Copy link
Author

Also, I appreciate your help with this, but please don't drop everything to fix my problem. I have other ways of getting the data into Neo4j and was really just interested in seeing what the results were when I tried your gem. That said, I'm happy to continue debugging if you'd like to explore some more.

@subvertallchris
Copy link

Ah! Sorry, I didn't see when you tagged me cause it was the day I was out and about. The faraday_middleware thing was cleared up by modifying your gemfile, right?

@cheerfulstoic
Copy link
Contributor

Ok, back to this, and sorry for the lack of response ;)

I've made a number of improvements, most of which probably won't help. But I've also added a --debug flag, so could you try again with that flag set and post the output if it doesn't work?

Thanks!

@harrylove
Copy link
Author

Using version 0.6.0.
Running neo4apis activerecord models Dealer --import-all-associations
Error: Could not find command "activerecord".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants