I have a migration I am trying to run to generate postgresql schemas using pg_power.
class CreateSchemas < ActiveRecord::Migration
def change
create_schema 'deprecated'
create_schema 'leaf'
create_schema 'mmp'
create_schema 'mmp_static'
create_schema 'nass'
create_schema 'static'
end
end
When I run the migration, I get the following error
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
** Invoke db:_dump (first_time)
** Execute db:_dump
** Invoke db:schema:dump (first_time)
** Invoke environment
** Invoke db:load_config
** Execute db:schema:dump
rake aborted!
undefined method `[]' for nil:NilClass
/Users/Pro777/.bundler/ruby/2.0.0/pg_power-36a643247425/lib/pg_power/schema_dumper/extension_methods.rb:17:in `block in dump_extensions'
/Users/Pro777/.bundler/ruby/2.0.0/pg_power-36a643247425/lib/pg_power/schema_dumper/extension_methods.rb:15:in `map'
/Users/Pro777/.bundler/ruby/2.0.0/pg_power-36a643247425/lib/pg_power/schema_dumper/extension_methods.rb:15:in `dump_extensions'
/Users/Pro777/.bundler/ruby/2.0.0/pg_power-36a643247425/lib/pg_power/schema_dumper/extension_methods.rb:6:in `header_with_extensions'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/schema_dumper.rb:26:in `dump'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/schema_dumper.rb:21:in `dump'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/railties/databases.rake:244:in `block (4 levels) in <top (required)>'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/railties/databases.rake:243:in `open'
/Library/Ruby/Gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/railties/databases.rake:243:in `block (3 levels) in <top (required)>'
I should say I'm using ruby 2.0, rails 4.0, and the rails4 branch of pg_power.
The library was tested with Ruby <= 1.9.3 (you are using 2.0) and ActiveRecord 3.
It was tested with Rails 3.1.x and 3.2.x, Ruby 1.8.7 REE and 1.9.3.
Moreover, there seems to be some incompatibilities with Rails 4.
The library doesn't use public ActiveRecord API but uses monkey patching (alias_method_chain). I won't be surprise if the exception is because the library does not currently work with Rails 4.
In order to fix the issue you should look what changed in the ActiveRecord internals from Rails 3 to Rails 4 and update the corresponding overrides in the Gem. It may be a small or huge effort, depending on the amount of changes.
I encourage you find an alternative and report the issue in the official issue tracker.
When you was trying to run pg_power against rails4, it really didn't work well.
Now, pg_power supports rails4, you must use 2.X.X version.
Related
When running rubymine debug getting Test framework quit unexpectedly error.
Testing started at 11:41 AM ...
/bin/bash -c "env RBENV_VERSION=2.7.0 /home/workstation/.rbenv/libexec/rbenv exec bundle exec ruby /home/workstation/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/ruby-debug-ide-0.8.0.beta19/bin/rdebug-ide --key-value --step-over-in-blocks --disable-int-handler --evaluation-timeout 10 --evaluation-control --time-limit 100 --memory-limit 0 --rubymine-protocol-extensions --port 41145 --host 0.0.0.0 --dispatcher-port 37297 -- /home/workstation/.rbenv/versions/2.7.0/bin/rspec /home/workstation/workspace/railsprojects/labx/spec/requests/api/v1/sellers_request_spec.rb --require teamcity/spec/runner/formatter/teamcity/formatter --format 'Spec::Runner::Formatter::TeamcityFormatter' --example 'Api::V1::Sellers POST register'"
/home/workstation/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/debase-0.3.0.beta19/lib/debase.rb:7:in `require': cannot load such file -- debase_internals (LoadError)
from /home/workstation/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/debase-0.3.0.beta19/lib/debase.rb:7:in `<top (required)>'
from /home/workstation/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/ruby-debug-ide-0.8.0.beta19/lib/ruby-debug-ide.rb:9:in `require'
from /home/workstation/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/ruby-debug-ide-0.8.0.beta19/lib/ruby-debug-ide.rb:9:in `<top (required)>'
from /home/workstation/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/ruby-debug-ide-0.8.0.beta19/bin/rdebug-ide:8:in `require_relative'
from /home/workstation/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/ruby-debug-ide-0.8.0.beta19/bin/rdebug-ide:8:in `<main>'
Process finished with exit code 1
Versions
ruby: 2.7.0, rspec-rails: 4.0.0.pre, rails: 6-0-stable, Rubymine
2019.3.1
Only debug is failing if I run tests normally without debug it works fine. What could be the issue?
I'm struggling trying to get the configuration of rails-api with the mongo_mapper gem.
I'm using rails v 4.1.1
gemfile looks as follows
source 'https://rubygems.org'
gem 'mongo'
gem 'mongo_mapper', :git => "git://github.com/mongomapper/mongomapper.git", :tag => "v0.13.0.beta2"
gem 'bson_ext'
gem 'railties'
I ran rails-api new test-app --skip-active-record which generates a simple file structure.
.
├── Gemfile
├── Gemfile.lock
├── README.rdoc
├── Rakefile
└── config.ru
After that, per the instructions on the README for mongo_mapper I specified the correct version in my gemfile so that it's compatible with Rails 4.
gem 'mongo_mapper', :git => "git://github.com/mongomapper/mongomapper.git", :tag => "v0.13.0.beta2"
According to
- http://mongomapper.com/documentation/getting-started/rails.html
- How can I get mongo mapper to generate the config/mongo.yml file in Rails 4
I should then be able to run bundle exec rails generate mongo_mapper:config. It was here I started running into issues.
I first realized I need railsties gem since it wasn't even letting me run rails generate.
$ bundle exec rails generate mongo_mapper:config
/Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.6.1/lib/bundler/rubygems_integration.rb:248:in `block in replace_gem': railties is not part of the bundle. Add it to Gemfile. (Gem::LoadError)
from /Users/colinhhart/.rbenv/versions/2.1.0/bin/rails:22:in `<main>'
After adding that gem it allowed me to run bundle exec rails generate mongo_mapper:config but doesn't actually have access to that mongo generator. The output from the command is the standard rails help info including usage, options etc.
Usage:
rails new APP_PATH [options]
Options:
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
# Default: /Users/colinhhart/.rbenv/versions/2.1.0/bin/ruby
-m, [--template=TEMPLATE] # Path to some application template (can be a filesystem path or URL)
What I've tried so far
I've tried building out what the generator is supposed to build as is described in this guide
http://technicaldebt.com/getting-started-with-ruby/mongomapper-ith-rails-quickstart/
But then realized that even if I build that out there's obviously still some "glue" that I'm missing, which ties everything together. I built it out just in case and of course it still didn't work.
I've made sure to bundle and and reload the terminal appropriately.
Like I said, I'm pretty sure there's something necessary that gets skipped when I build the rails-api without active record.
Any thoughts on this? Would greatly appreciate the help.
For what it's worth this is the full output when I ran rails-api new my_app --skip-active-record.
$ rails-api new pitfworld_wide_atrocities_db --skip-active-record
create
create README.rdoc
create Rakefile
create config.ru
create .gitignore
create Gemfile
(erb):19:in `template': undefined method `name' for []:Array (NoMethodError)
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/2.1.0/erb.rb:850:in `eval'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/2.1.0/erb.rb:850:in `result'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/actions/file_manipulation.rb:116:in `block in template'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:53:in `call'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:53:in `render'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:62:in `block (2 levels) in invoke!'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:62:in `open'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:62:in `block in invoke!'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/actions/empty_directory.rb:116:in `call'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/actions/empty_directory.rb:116:in `invoke_with_conflict_check'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:60:in `invoke!'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/actions.rb:94:in `action'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:25:in `create_file'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/actions/file_manipulation.rb:115:in `template'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/generators/rails/app/app_generator.rb:17:in `template'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/generators/rails/app/app_generator.rb:45:in `gemfile'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/generators/app_base.rb:133:in `build'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/generators/rails/app/app_generator.rb:176:in `create_root_files'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `block in invoke_all'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `each'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `map'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `invoke_all'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/group.rb:232:in `dispatch'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/commands/application.rb:17:in `<top (required)>'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:73:in `require'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:73:in `require'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/cli.rb:14:in `<top (required)>'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:73:in `require'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:73:in `require'
from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rails-api-0.2.1/bin/rails-api:4:in `<top (required)>'
from /Users/colinhhart/.rbenv/versions/2.1.0/bin/rails-api:23:in `load'
from /Users/colinhhart/.rbenv/versions/2.1.0/bin/rails-api:23:in `<main>'
Solution
I came across that rails-api issue right as I was writing this post and it turned out that that was the issue, after banging my head forever thinking it was a mongo issue.
The issue has been fixed and closed but hasn't yet been released and will probably be released in rails-api v0.2.2.
Ultimately, I decided to just go into the rails-api source code and apply the changes locally.
I'm trying to learn to use Capistrano 3 by following the DOCS and I've written a simple task to test my understanding.
The task is created in the default task dir in lib/capistrano/tasks:
desc "Check status of web server"
task :nginx_status do
on roles(:web) do |host|
execute 'service nginx status'
end
end
My config/deploy/staging.rb file contains the following:
set :stage, :staging
role :web, "192.168.0.11"
role :app, "192.168.0.11"
role :db, "192.168.0.11", primary:true
server '192.168.0.11', user: 'vagrant', roles: %w{web app}
Capfile
# Load DSL and Setup Up Stages
require 'capistrano/setup'
# Includes default deployment tasks
require 'capistrano/deploy'
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
My deploy.rb contains an app name and a repo url to github.
When I run cap staging nginx_status I get the following error:
** Invoke staging (first_time)
** Execute staging
** Invoke load:defaults (first_time)
** Execute load:defaults
cap aborted!
Don't know how to build task 'nginx_status'
/Users/H/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.1/lib/rake/task_manager.rb:62:in `[]'
/Users/H/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.1/lib/rake/application.rb:149:in `invoke_task'
/Users/H/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.1/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/H/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.1/lib/rake/application.rb:106:in `each'
/Users/H/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.1/lib/rake/application.rb:106:in `block in top_level'
/Users/H/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.1/lib/rake/application.rb:115:in `run_with_threads'
/Users/H/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.1/lib/rake/application.rb:100:in `top_level'
/Users/H/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.1/lib/rake/application.rb:78:in `block in run'
/Users/H/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.1/lib/rake/application.rb:176:in `standard_exception_handling'
/Users/H/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.1/lib/rake/application.rb:75:in `run'
/Users/H/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/capistrano-3.2.1/lib/capistrano/application.rb:15:in `run'
/Users/H/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/capistrano-3.2.1/bin/cap:3:in `<top (required)>'
/Users/H/.rbenv/versions/2.1.1/bin/cap:23:in `load'
/Users/H/.rbenv/versions/2.1.1/bin/cap:23:in `<main>'
I also noticed that if I ran cap -vT the task nginx_status is not in the list(?)
On a side note, are SSH keys a must to connect to remote servers?
UPDATE 1
I found that if I place my task in config/deploy.rb it works. So the question I now have is how do you run tasks from the task dir?
UPDATE 2
So as per the Capfile the tasks dir is looked at by the following:
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
So I changed the task extension to .rake and it worked. However the documentation says it should be .cap
"We'll dive into those more later, but add those lines to a file in ./lib/capistrano/tasks, call it something like access_check.cap"
Take a look at this commit.
They've switched from .cap to .rake 3 months ago.
The whole idea is to make capistrano3 fully rake-compatible. Just use .rake extension for you tasks.
>sudo rake neo4j:create --trace [ 6:18PM]
rake aborted!
Don't know how to build task 'neo4j:create'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/task_manager.rb:49:in []'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:115:ininvoke_task'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:ineach'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:94:in top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:instandard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:88:in top_level'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:66:inrun'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:133:in standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/application.rb:63:inrun'
/usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/bin/rake:33
/usr/bin/rake:19:in `load'
/usr/bin/rake:19
What may be the probable reason for this error. I am following the maxdemarzi introduction to neo4j and d3.js.
I will be thankful if some one can suggest the solution
https://github.com/maxdemarzi/d3_js_intro
I've updated the project so it works now. Please run:
git pull # Get the latest code
bundle install # Update the project gems
rake neo4j:reset_yes_i_am_sure # Reset the Neo4j Server
rake neo4j:create
Ping me if you still have trouble.
Regards,
Max
Trying to install and run a simple Neo4j app from Max Demarzi's "d3_js_intro" app on GitHub. Issuing the command rake neo4j:install, I get the message shown below. Questions:
Q: What is the root cause of wget failing to get the file; a file that appears to exist in exactly the place expected? (Note: the URL following the error message "No such file or directory" is valid; that file exists there... so message is incorrect. Why?) A: the root cause was that wget is not installed on a Mac OSX machine. If you are running a Mac OSX machine, you too will need to install wget.
I've tried:
I've manually downloaded the file (http://dist.neo4j.org/neo4j-community-1.7-unix.tar.gz) that the wget was failing to get.
extracting the file to the app root directory.
Questions related to manually recovering from this problem:
Q: Does the manually-extracted directory need to be named anything special? (i.e.: "Neo4j", "neo4j", etc.). A: It would have to be called "neo4j", but the fix (below) eliminates the need to do this.
Q: What configuration files would I need to modify (and how) in order to get the app to see the neo4j server? A: the fix below eliminates the need to deal with this.
The gem files reads:
source 'http://rubygems.org'
gem 'sinatra'
gem 'neography'
gem 'haml'
gem 'json'
group :test do
gem 'rspec'
gem 'rack-test'
gem 'net-http-spy'
end
The Rakefile reads:
require 'neography/tasks'
require './d3.rb'
namespace :neo4j do
task :create do
create_graph
end
end
Thanks for anything you can provide
- HisHighnessDog
rake neo4j:install --trace
** Invoke neo4j:install (first_time)
** Execute neo4j:install
Installing Neo4j-community-1.7
rake aborted!
No such file or directory - wget http://dist.neo4j.org/neo4j-community-1.7-unix.tar.gz
/Users/tomjones/.rvm/gems/ruby-1.9.3-p194/gems/neography-0.0.26/lib/neography/tasks.rb:44:in ``'
/Users/tomjones/.rvm/gems/ruby-1.9.3-p194/gems/neography-0.0.26/lib/neography/tasks.rb:44:in `block (2 levels) in <top (required)>'
...
...
/Users/tomjones/.rvm/gems/ruby-1.9.3-p194/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/tomjones/.rvm/gems/ruby-1.9.3-p194/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/Users/tomjones/.rvm/gems/ruby-1.9.3-p194/bin/rake:23:in `load'
/Users/tomjones/.rvm/gems/ruby-1.9.3-p194/bin/rake:23:in `<main>'
Tasks: TOP => neo4j:install
Should I be concerned that the Rakefile does not contain a task entry for 'install', while the command I'm running is rake neo4j:install?
Solution: the root cause for the error message is that (OSX machine default): wget is not installed.
Recovery: Install and configure wget:
curl -O http://ftp.gnu.org/gnu/wget/wget-1.14.tar.gz
tar -xzvf wget-1.13.tar.gz
cd wget-1.14
./configure --with-ssl=openssl
make
sudo make install
which wget (to confirm wget is now installed)
Use the current wget download from gnu org's website.
You have to download, unzip and start a Neo4j server. The version is not relevant in this case. Go to http://neo4j.org/download for instruction and download links.