We're working with an older Carrierwave installation and had an issue that caused many of our avatars to be deleted from the S3 bucket but they're still being referenced by Carrierwave. How can I safely clear out these broken instances without breaking our other user's avatars?
Version information:
Ruby 2.1.0
carrierwave-0.5.8
excon-0.32.0
fog-0.7.2
railties-3.2.18
I can't upgrade the gems any further at this point because there are other dependencies that will introduce breaking changes.
I've tried to instance.remove_avatar! functionality but that fails with the following error.
irb(main):041:0> t.remove_avatar!
Digest::Digest is deprecated; use Digest
[excon][WARNING] Invalid Excon request keys: :host
/app/vendor/bundle/ruby/2.1.0/gems/excon-0.32.0/lib/excon/connection.rb:389:in `validate_params'
/app/vendor/bundle/ruby/2.1.0/gems/excon-0.32.0/lib/excon/connection.rb:225:in `request'
/app/vendor/bundle/ruby/2.1.0/gems/fog-0.7.2/lib/fog/core/connection.rb:20:in `request'
/app/vendor/bundle/ruby/2.1.0/gems/fog-0.7.2/lib/fog/storage/aws.rb:323:in `request'
/app/vendor/bundle/ruby/2.1.0/gems/fog-0.7.2/lib/fog/storage/requests/aws/delete_object.rb:20:in `delete_object'
/app/vendor/bundle/ruby/2.1.0/gems/fog-0.7.2/lib/fog/storage/models/aws/file.rb:58:in `destroy'
/app/vendor/bundle/ruby/2.1.0/gems/carrierwave-0.5.8/lib/carrierwave/storage/fog.rb:178:in `delete'
/app/vendor/bundle/ruby/2.1.0/gems/carrierwave-0.5.8/lib/carrierwave/uploader/remove.rb:15:in `block in remove!'
/app/vendor/bundle/ruby/2.1.0/gems/carrierwave-0.5.8/lib/carrierwave/uploader/callbacks.rb:17:in `with_callbacks'
/app/vendor/bundle/ruby/2.1.0/gems/carrierwave-0.5.8/lib/carrierwave/uploader/remove.rb:14:in `remove!'
/app/vendor/bundle/ruby/2.1.0/gems/carrierwave-0.5.8/lib/carrierwave/mount.rb:365:in `remove!'
/app/vendor/bundle/ruby/2.1.0/gems/carrierwave-0.5.8/lib/carrierwave/mount.rb:205:in `remove_avatar!'
(irb):41:in `irb_binding'
/app/vendor/ruby-2.1.0/lib/ruby/2.1.0/irb/workspace.rb:86:in `eval'
/app/vendor/ruby-2.1.0/lib/ruby/2.1.0/irb/workspace.rb:86:in `evaluate'
/app/vendor/ruby-2.1.0/lib/ruby/2.1.0/irb/context.rb:380:in `evaluate'
/app/vendor/ruby-2.1.0/lib/ruby/2.1.0/irb.rb:492:in `block (2 levels) in eval_input'
/app/vendor/ruby-2.1.0/lib/ruby/2.1.0/irb.rb:624:in `signal_status'
/app/vendor/ruby-2.1.0/lib/ruby/2.1.0/irb.rb:489:in `block in eval_input'
/app/vendor/ruby-2.1.0/lib/ruby/2.1.0/irb/ruby-lex.rb:247:in `block (2 levels) in each_top_level_statement'
/app/vendor/ruby-2.1.0/lib/ruby/2.1.0/irb/ruby-lex.rb:233:in `loop'
/app/vendor/ruby-2.1.0/lib/ruby/2.1.0/irb/ruby-lex.rb:233:in `block in each_top_level_statement'
/app/vendor/ruby-2.1.0/lib/ruby/2.1.0/irb/ruby-lex.rb:232:in `catch'
/app/vendor/ruby-2.1.0/lib/ruby/2.1.0/irb/ruby-lex.rb:232:in `each_top_level_statement'
/app/vendor/ruby-2.1.0/lib/ruby/2.1.0/irb.rb:488:in `eval_input'
/app/vendor/ruby-2.1.0/lib/ruby/2.1.0/irb.rb:397:in `block in start'
/app/vendor/ruby-2.1.0/lib/ruby/2.1.0/irb.rb:396:in `catch'
/app/vendor/ruby-2.1.0/lib/ruby/2.1.0/irb.rb:396:in `start'
/app/vendor/bundle/ruby/2.1.0/gems/railties-3.2.18/lib/rails/commands/console.rb:47:in `start'
/app/vendor/bundle/ruby/2.1.0/gems/railties-3.2.18/lib/rails/commands/console.rb:8:in `start'
/app/vendor/bundle/ruby/2.1.0/gems/railties-3.2.18/lib/rails/commands.rb:41:in `<top (required)>'
script/rails:6:in `require'
script/rails:6:in `<main>'
=> [:remove_versions!]
I've opened up an issue on Carrierwave's Github tracker as well.
I'm going to close the issue as we were able to work around.
I'd forgotten to mentioned that we are also using the carrierwave-mongoid. Which I think saved our butt.
By setting the instance avatar manually then resaving the model and ignoring the Excon error we forced the models to use their default image.
So in this case, given we have an instance of a model named t.
> t[:avatar] = nil
> t.save rescue nil
This changed the avatar.url to resolve as the default image.
Related
Disclaimer: I know there are a couple of questions regarding this issue, but I followed all the answers. posted in those questions and I am still getting the error.
I have a rails app setup using Postgres and am trying to switch to mongoid. Here are the steps I took:
drop databases
add 'mongoid', '~> 7.0.5' and delete 'pg' gem
remove all references to active_record and active_storage
remove spring gems (known to cause issues)
update all models to be compatible with mongodb
delete config/database.yml and /db directory
switch devise and database-cleaner to use mongoid
After following all of the above steps, I am still getting the error when starting the server:
Could not load database configuration - No such file - [config/database.yml]
This doesn't make any sense, because rails should not be loading active record at all, and therefore should not be loading the database config file.
I would really appreciate if someone could be debug this issue.
You can view the source code of my app under the branch mongodb
Edit: I disabled bootsnap and devise and got the stack trace down to this: (It looks like active_record is still being loaded)
Puma caught this error: Cannot load database configuration:
Could not load database configuration. No such file - ["config/database.yml"] (RuntimeError)
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/railties-6.0.3.2/lib/rails/application/configuration.rb:241:in `database_configuration'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/railtie.rb:200:in `block (2 levels) in <class:Railtie>'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:71:in `class_eval'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:71:in `block in execute_hook'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:61:in `with_execution_control'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:66:in `execute_hook'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:51:in `each'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/base.rb:327:in `<module:ActiveRecord>'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/base.rb:27:in `<top (required)>'
/Users/afamily/.rvm/rubies/ruby-2.7.1/lib/ruby/gems/2.7.0/gems/zeitwerk-2.3.0/lib/zeitwerk/kernel.rb:23:in `require'
/Users/afamily/.rvm/rubies/ruby-2.7.1/lib/ruby/gems/2.7.0/gems/zeitwerk-2.3.0/lib/zeitwerk/kernel.rb:23:in `require'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/query_cache.rb:31:in `run'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/execution_wrapper.rb:28:in `before'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:428:in `block in make_lambda'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:200:in `block (2 levels) in halting'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:605:in `block (2 levels) in default_terminator'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:604:in `catch'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:604:in `block in default_terminator'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:201:in `block in halting'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:513:in `block in invoke_before'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:513:in `each'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:513:in `invoke_before'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:134:in `run_callbacks'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/execution_wrapper.rb:111:in `run!'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/execution_wrapper.rb:73:in `block in run!'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/execution_wrapper.rb:70:in `tap'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/execution_wrapper.rb:70:in `run!'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/actionpack-6.0.3.2/lib/action_dispatch/middleware/executor.rb:12:in `call'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/actionpack-6.0.3.2/lib/action_dispatch/middleware/static.rb:126:in `call'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/rack-2.2.3/lib/rack/sendfile.rb:110:in `call'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/actionpack-6.0.3.2/lib/action_dispatch/middleware/host_authorization.rb:82:in `call'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/webpacker-4.2.2/lib/webpacker/dev_server_proxy.rb:23:in `perform_request'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/rack-proxy-0.6.5/lib/rack/proxy.rb:57:in `call'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/railties-6.0.3.2/lib/rails/engine.rb:527:in `call'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/puma-4.3.5/lib/puma/configuration.rb:228:in `call'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/puma-4.3.5/lib/puma/server.rb:713:in `handle_request'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/puma-4.3.5/lib/puma/server.rb:472:in `process_client'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/puma-4.3.5/lib/puma/server.rb:328:in `block in run'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/puma-4.3.5/lib/puma/thread_pool.rb:134:in `block in spawn_thread'
I believe this is the same issue as https://github.com/rails/spring/issues/601, in your case originating from devise here:
/home/sandbox/agilely/vendor/bundle/ruby/2.7.0/gems/devise-4.7.2/lib/devise/models/confirmable.rb:52:in `block in <module:Confirmable>'
If you remove devise from your application and you are able to load console successfully, I suggest reporting this issue to devise.
I have two models using the same uploader in a rails project with carrierwave
class Brand < ActiveRecord::Base
mount :avatar, AvatarUploader
end
class Profile < ActiveRecord::Base
mount :avatar, AvatarUploader
end
Then when I try to copy one image to another model
profile.avatar = brand.avatar
profile.save!
it fails with the following stacktrace
undefined method `content_length' for nil:NilClass
usr/lib64/ruby/gems/1.9.1/gems/carrierwave-0.9.0/lib/carrierwave/storage/fog.rb:238:in `size'
/usr/lib64/ruby/gems/1.9.1/gems/carrierwave-0.9.0/lib/carrierwave/uploader/proxy.rb:57:in `size'
/usr/lib64/ruby/gems/1.9.1/gems/carrierwave-0.9.0/lib/carrierwave/sanitized_file.rb:95:in `size'
/usr/lib64/ruby/gems/1.9.1/gems/carrierwave-0.9.0/lib/carrierwave/sanitized_file.rb:135:in `empty?'
/usr/lib64/ruby/gems/1.9.1/gems/carrierwave-0.9.0/lib/carrierwave/uploader/cache.rb:119:in `cache!'
/usr/lib64/ruby/gems/1.9.1/gems/carrierwave-0.9.0/lib/carrierwave/mount.rb:327:in `cache'
/usr/lib64/ruby/gems/1.9.1/gems/carrierwave-0.9.0/lib/carrierwave/mount.rb:179:in `avatar='
/usr/lib64/ruby/gems/1.9.1/gems/carrierwave-0.9.0/lib/carrierwave/orm/activerecord.rb:38:in `avatar='
/usr/share/nginx/cranberrychic/releases/20140213171925/app/services/brand_into_user_converter.rb:42:in `copy_avatar'
/usr/share/nginx/cranberrychic/releases/20140213171925/app/services/brand_into_user_converter.rb:13:in `convert'
(irb):64:in `block (2 levels) in irb_binding'
/usr/lib64/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/usr/lib64/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/transactions.rb:208:in `transaction'
/usr/lib64/ruby/gems/1.9.1/gems/newrelic_rpm-3.6.0.78/lib/new_relic/agent/method_tracer.rb:486:in `block in transaction_with_trace_ActiveRecord_self_name_transaction'
/usr/lib64/ruby/gems/1.9.1/gems/newrelic_rpm-3.6.0.78/lib/new_relic/agent/method_tracer.rb:235:in `trace_execution_scoped'
/usr/lib64/ruby/gems/1.9.1/gems/newrelic_rpm-3.6.0.78/lib/new_relic/agent/method_tracer.rb:481:in `transaction_with_trace_ActiveRecord_self_name_transaction'
(irb):62:in `block in irb_binding'
/usr/lib64/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/relation/delegation.rb:6:in `each'
/usr/lib64/ruby/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/relation/delegation.rb:6:in `each'
(irb):59:in `irb_binding'
/usr/lib64/ruby/1.9.1/irb/workspace.rb:80:in `eval'
/usr/lib64/ruby/1.9.1/irb/workspace.rb:80:in `evaluate'
/usr/lib64/ruby/1.9.1/irb/context.rb:254:in `evaluate'
/usr/lib64/ruby/1.9.1/irb.rb:159:in `block (2 levels) in eval_input'
/usr/lib64/ruby/1.9.1/irb.rb:273:in `signal_status'
/usr/lib64/ruby/1.9.1/irb.rb:156:in `block in eval_input'
/usr/lib64/ruby/1.9.1/irb/ruby-lex.rb:243:in `block (2 levels) in each_top_level_statement'
/usr/lib64/ruby/1.9.1/irb/ruby-lex.rb:229:in `loop'
/usr/lib64/ruby/1.9.1/irb/ruby-lex.rb:229:in `block in each_top_level_statement'
/usr/lib64/ruby/1.9.1/irb/ruby-lex.rb:228:in `catch'
/usr/lib64/ruby/1.9.1/irb/ruby-lex.rb:228:in `each_top_level_statement'
/usr/lib64/ruby/1.9.1/irb.rb:155:in `eval_input'
/usr/lib64/ruby/1.9.1/irb.rb:70:in `block in start'
/usr/lib64/ruby/1.9.1/irb.rb:69:in `catch'
/usr/lib64/ruby/1.9.1/irb.rb:69:in `start'
/usr/lib64/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/commands/console.rb:47:in `start'
/usr/lib64/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/commands/console.rb:8:in `start'
/usr/lib64/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:41:in `<top (required)>'
script/rails:6:in `require'
script/rails:6:in `<main>'
To me is a bug of carrierwave with fog storage, because in development with the file storage everything works as expected. When I try to copy an image from a model to another in any way possible with carrierwave, it fails with the same error
My carrierwave version is 0.9.0
and rails version is 3.2.13 and ruby 1.9.3-p327
I believe you doing it wrong
profile.avatar = brand.avatar
will not work because profile.avatar= need a file object and brand.avatar don't give you a file object (it return you a uploader i.e avatar object)
I believe your looking for this approach
profile.remote_avatar_url = brand.avatar.url
profile.save!
Considering the brand.avatar.url give you a url from where carrierwave can download the file
More information about remote_{uploader}_url can also be found in Carrierwave Readme
Hope this help
I'm trying to introduce some concurrency into my project.
I'm playing with the parallel gem now, and am having a problem creating an object inside of a parallel process.
Parallel.map(["a"], :in_processes => 8) do |i|
ActiveRecord::Base.connection_pool.with_connection do
User.create
end
end
Results in:
/Users/tyler/.rvm/gems/ruby-1.9.3-p392#arcsite_mysql/gems/parallel-0.8.1/lib/parallel.rb:279:in `dump': no _dump_data is defined for class Binding (TypeError)
from /Users/tyler/.rvm/gems/ruby-1.9.3-p392#arcsite_mysql/gems/parallel-0.8.1/lib/parallel.rb:279:in `process_incoming_jobs'
from /Users/tyler/.rvm/gems/ruby-1.9.3-p392#arcsite_mysql/gems/parallel-0.8.1/lib/parallel.rb:257:in `block in worker'
from /Users/tyler/.rvm/gems/ruby-1.9.3-p392#arcsite_mysql/gems/parallel-0.8.1/lib/parallel.rb:250:in `fork'
from /Users/tyler/.rvm/gems/ruby-1.9.3-p392#arcsite_mysql/gems/parallel-0.8.1/lib/parallel.rb:250:in `worker'
from /Users/tyler/.rvm/gems/ruby-1.9.3-p392#arcsite_mysql/gems/parallel-0.8.1/lib/parallel.rb:238:in `block in create_workers'
from /Users/tyler/.rvm/gems/ruby-1.9.3-p392#arcsite_mysql/gems/parallel-0.8.1/lib/parallel.rb:237:in `each'
from /Users/tyler/.rvm/gems/ruby-1.9.3-p392#arcsite_mysql/gems/parallel-0.8.1/lib/parallel.rb:237:in `create_workers'
from /Users/tyler/.rvm/gems/ruby-1.9.3-p392#arcsite_mysql/gems/parallel-0.8.1/lib/parallel.rb:201:in `work_in_processes'
from /Users/tyler/.rvm/gems/ruby-1.9.3-p392#arcsite_mysql/gems/parallel-0.8.1/lib/parallel.rb:106:in `map'
from (irb):15:in `irb_binding'
from /Users/tyler/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/irb/workspace.rb:80:in `eval'
from /Users/tyler/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/irb/workspace.rb:80:in `evaluate'
from /Users/tyler/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/irb/context.rb:254:in `evaluate'
from /Users/tyler/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/irb.rb:159:in `block (2 levels) in eval_input'
from /Users/tyler/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/irb.rb:273:in `signal_status'
from /Users/tyler/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/irb.rb:156:in `block in eval_input'
from /Users/tyler/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/irb/ruby-lex.rb:243:in `block (2 levels) in each_top_level_statement'
from /Users/tyler/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `loop'
from /Users/tyler/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `block in each_top_level_statement'
from /Users/tyler/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `catch'
from /Users/tyler/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `each_top_level_statement'
from /Users/tyler/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/irb.rb:155:in `eval_input'
from /Users/tyler/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/irb.rb:70:in `block in start'
from /Users/tyler/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/irb.rb:69:in `catch'
from /Users/tyler/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/irb.rb:69:in `start'
from /Users/tyler/.rvm/gems/ruby-1.9.3-p392#arcsite_mysql/gems/railties-3.2.13/lib/rails/commands/console.rb:47:in `start'
from /Users/tyler/.rvm/gems/ruby-1.9.3-p392#arcsite_mysql/gems/railties-3.2.13/lib/rails/commands/console.rb:8:in `start'
from /Users/tyler/.rvm/gems/ruby-1.9.3-p392#arcsite_mysql/gems/railties-3.2.13/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Parallel::DeadWorker: Parallel::DeadWorker
from /Users/tyler/.rvm/gems/ruby-1.9.3-p392#arcsite_mysql/gems/parallel-0.8.1/lib/parallel.rb:51:in `rescue in work'
from /Users/tyler/.rvm/gems/ruby-1.9.3-p392#arcsite_mysql/gems/parallel-0.8.1/lib/parallel.rb:48:in `work'
from /Users/tyler/.rvm/gems/ruby-1.9.3-p392#arcsite_mysql/gems/parallel-0.8.1/lib/parallel.rb:216:in `block (4 levels) in work_in_processes'
from /Users/tyler/.rvm/gems/ruby-1.9.3-p392#arcsite_mysql/gems/parallel-0.8.1/lib/parallel.rb:352:in `with_instrumentation'
from /Users/tyler/.rvm/gems/ruby-1.9.3-p392#arcsite_mysql/gems/parallel-0.8.1/lib/parallel.rb:215:in `block (3 levels) in work_in_processes'
from /Users/tyler/.rvm/gems/ruby-1.9.3-p392#arcsite_mysql/gems/parallel-0.8.1/lib/parallel.rb:210:in `loop'
from /Users/tyler/.rvm/gems/ruby-1.9.3-p392#arcsite_mysql/gems/parallel-0.8.1/lib/parallel.rb:210:in `block (2 levels) in work_in_processes'
from /Users/tyler/.rvm/gems/ruby-1.9.3-p392#arcsite_mysql/gems/parallel-0.8.1/lib/parallel.rb:65:in `block (2 levels) in in_threads'
Any variation of the parallel block seems to result in the same error. Removing the call to create allows the program to function as expected.
Looks like what you are returning is not dumpable, so either return nil or use Parallel.each alternatively Maybe the with_connection does not actually return the user object but something weird ... You can also try to return user.attributes instead of the full user object
http://ruby.zigzo.com/2012/01/29/the-parallel-gem-and-postgresql-oh-and-rails/
According to the above Mario's post, PostgreSQL does not allow using the same connection for more than one thread. I am wondering if the MySQL is the same, plus MySQL may put lock while accessing it. Here is the solution for parallel working on PostgreSQL: ActiveRecord::Base.connection.reconnect!
This issue is intermittent, but pressing the up-arrow to get a previously entered command I'll get an error such as:
/Users/me/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-2.3.14/lib/active_support/whiny_nil.rb:52:in `method_missing': undefined method `force_encoding' for nil:NilClass (NoMethodError)
from /Users/me/.rvm/gems/ruby-1.9.3-p194/gems/rb-readline-0.4.2/lib/rbreadline.rb:3801:in `_rl_col_width'
from /Users/me/.rvm/gems/ruby-1.9.3-p194/gems/rb-readline-0.4.2/lib/rbreadline.rb:2944:in `update_line'
from /Users/me/.rvm/gems/ruby-1.9.3-p194/gems/rb-readline-0.4.2/lib/rbreadline.rb:3486:in `block in rl_redisplay'
from /Users/me/.rvm/gems/ruby-1.9.3-p194/gems/rb-readline-0.4.2/lib/rbreadline.rb:3481:in `each'
from /Users/me/.rvm/gems/ruby-1.9.3-p194/gems/rb-readline-0.4.2/lib/rbreadline.rb:3481:in `rl_redisplay'
from /Users/me/.rvm/gems/ruby-1.9.3-p194/gems/rb-readline-0.4.2/lib/rbreadline.rb:4618:in `_rl_internal_char_cleanup'
from /Users/me/.rvm/gems/ruby-1.9.3-p194/gems/rb-readline-0.4.2/lib/rbreadline.rb:4679:in `readline_internal_charloop'
from /Users/me/.rvm/gems/ruby-1.9.3-p194/gems/rb-readline-0.4.2/lib/rbreadline.rb:4743:in `readline_internal'
from /Users/me/.rvm/gems/ruby-1.9.3-p194/gems/rb-readline-0.4.2/lib/rbreadline.rb:4765:in `readline'
from /Users/me/.rvm/gems/ruby-1.9.3-p194/gems/rb-readline-0.4.2/lib/readline.rb:40:in `readline'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/input-method.rb:115:in `gets'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:139:in `block (2 levels) in eval_input'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:273:in `signal_status'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:138:in `block in eval_input'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:188:in `call'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:188:in `buf_input'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:103:in `getc'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/slex.rb:205:in `match_io'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/slex.rb:75:in `match'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:286:in `token'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:262:in `lex'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:233:in `block (2 levels) in each_top_level_statement'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `loop'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `block in each_top_level_statement'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `catch'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `each_top_level_statement'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:155:in `eval_input'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:70:in `block in start'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:69:in `catch'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:69:in `start'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/bin/irb:16:in `<main>'
Looks like the issue is in readline? How to resolve the issue? According to bundle list I have this version of readline:
rb-readline (0.4.2)
Update: New error after updating with rvm pkg install readline per answer:
>/Users/me/.rvm/gems/ruby-1.9.3-p194/gems/rb-readline-0.4.2/lib/rbreadline.rb:2730:in `[]': no implicit conversion from nil to integer (TypeError)
from /Users/me/.rvm/gems/ruby-1.9.3-p194/gems/rb-readline-0.4.2/lib/rbreadline.rb:2730:in `update_line'
from /Users/me/.rvm/gems/ruby-1.9.3-p194/gems/rb-readline-0.4.2/lib/rbreadline.rb:3486:in `block in rl_redisplay'
from /Users/me/.rvm/gems/ruby-1.9.3-p194/gems/rb-readline-0.4.2/lib/rbreadline.rb:3481:in `each'
from /Users/me/.rvm/gems/ruby-1.9.3-p194/gems/rb-readline-0.4.2/lib/rbreadline.rb:3481:in `rl_redisplay'
from /Users/me/.rvm/gems/ruby-1.9.3-p194/gems/rb-readline-0.4.2/lib/rbreadline.rb:4618:in `_rl_internal_char_cleanup'
from /Users/me/.rvm/gems/ruby-1.9.3-p194/gems/rb-readline-0.4.2/lib/rbreadline.rb:4679:in `readline_internal_charloop'
from /Users/me/.rvm/gems/ruby-1.9.3-p194/gems/rb-readline-0.4.2/lib/rbreadline.rb:4743:in `readline_internal'
from /Users/me/.rvm/gems/ruby-1.9.3-p194/gems/rb-readline-0.4.2/lib/rbreadline.rb:4765:in `readline'
from /Users/me/.rvm/gems/ruby-1.9.3-p194/gems/rb-readline-0.4.2/lib/readline.rb:40:in `readline'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/input-method.rb:115:in `gets'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:139:in `block (2 levels) in eval_input'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:273:in `signal_status'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:138:in `block in eval_input'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:188:in `call'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:188:in `buf_input'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:103:in `getc'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/slex.rb:205:in `match_io'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/slex.rb:75:in `match'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:286:in `token'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:262:in `lex'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:233:in `block (2 levels) in each_top_level_statement'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `loop'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in `block in each_top_level_statement'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `catch'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in `each_top_level_statement'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:155:in `eval_input'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:70:in `block in start'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:69:in `catch'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:69:in `start'
from /Users/me/.rvm/rubies/ruby-1.9.3-p194/bin/irb:16:in `<main>'
And I still get the old error, as well.
It's clearly a problem with rb-readline.
I usually install readline as an rvm package:
rvm pkg install readline
And don't use any readline specific stuff in my Gemfile.
You may also have a look at:
Problems with the rails console, RVM and readline
I encountered this today.
I believe that this occurs because readline is trying to parse some of the text on the console line. Some text doesn't play nicely.
So why the up key?
This happened to be after I pasted a load of 'stuff' to set a variable. I obviously got something wrong in that pasting because the console crashed.
What do all IT professionals do after something crashes? Try it again. Whats the quickest way to try the last command you wrote in the rails console? The up key.
A good work around for this is to simply not hit the up key or clear the history to remove the offending line.
i have a problems with running braid on ruby 1.9.2. The problem is with fattr gem
$ braid
/opt/local/lib/ruby1.9/gems/1.9.1/gems/fattr-2.1.0/lib/fattr.rb:85:in `block (2 levels) in fattrs': wrong number of arguments (1 for 0) (ArgumentError)
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/fattr-2.1.0/lib/fattr.rb:90:in `instance_eval'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/fattr-2.1.0/lib/fattr.rb:90:in `call'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/fattr-2.1.0/lib/fattr.rb:90:in `block (2 levels) in fattrs'
from (eval):3:in `call'
from (eval):3:in `arity!'
from (eval):4:in `arity'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/main-4.2.0/lib/main/parameter.rb:105:in `sanity_check!'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/main-4.2.0/lib/main/parameter.rb:101:in `initialize'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/main-4.2.0/lib/main/parameter.rb:53:in `block in create'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/main-4.2.0/lib/main/parameter.rb:53:in `instance_eval'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/main-4.2.0/lib/main/parameter.rb:53:in `create'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/main-4.2.0/lib/main/program/class_methods.rb:193:in `option'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/main-4.2.0/lib/main/program/class_methods.rb:92:in `set_default_options!'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/main-4.2.0/lib/main/program/class_methods.rb:65:in `block in build'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/main-4.2.0/lib/main/program/class_methods.rb:63:in `module_eval'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/main-4.2.0/lib/main/program/class_methods.rb:63:in `build'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/main-4.2.0/lib/main/factories.rb:16:in `run'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/main-4.2.0/lib/main/factories.rb:25:in `Main'
from /opt/local/lib/ruby1.9/gems/1.9.1/gems/braid-0.6.2/bin/braid:13:in `<top (required)>'
from /opt/local/bin/braid:19:in `load'
from /opt/local/bin/braid:19:in `<main>'
Do you know any solution for this problem?
This is a common problem on the main fattr branch/gem. Someone has patched it though the main branch hasn't pulled the changes yet. Try removing the fattr gem installed with braid and replacing it with this version https://github.com/kitop/fattr.
Update: The main branch has now been updated for 1.9.2.