I've been using the yaml_db gem for a long time to dump the database to yaml and then reload it later if needed. On a fresh project, though, on rake db:load I got the error message:
NoMethodError: undefined method `load_documents' for Psych:Module
Did you mean? load_stream
/Users/user/.rvm/gems/ruby-2.5.0/gems/yaml_db-0.6.0/lib/yaml_db.rb:61:in `load_documents'
I am submitting the solution I finally came up with as an answer, but I'm not really happy with it. If anyone has a better solution or a suggestion of something better than the yaml_db gem for dumping and reloading the database, I'd be happy to listen.
I'm running Rails 5.1.4 on Ruby 2.5.0
The solution I came up with was to put the 'psych' gem in my Gemfile before yaml_db and set it to an earlier release:
gem 'psych', '~> 2.2.1'
gem 'yaml_db'
This issue is caused by load_documents being deprecated in Psych and finally removed in ruby 2.5. There's an open PR on yaml_db that fixes this issue, so hopefully future versions will not require you to use this work-around.
Your current solution is probably the easiest for now (short of downgrading your ruby version, which is probably a worse idea).
Related
I upgraded our app to Rails 6.1.4.4 and Ruby 3.0.2. I have this old gem
gem 'acts_as_commentable'
Locked at version 4.0.2. The gem does not appear to be supported anymore, which is a shame because when I start up my app or console, I now get this error
$ rails c
Your Gemfile lists the gem rspec-rails (>= 0) more than once.
You should probably keep only one of them.
Remove any duplicate entries and specify the gem only once.
While it's not a problem now, it could cause errors if you change the version of one of them later.
/Users/myuser/.rvm/gems/ruby-3.0.2/gems/hash_dot-2.5.0/lib/hash.rb:19:in `method_missing': undefined method `arity' for {:as=>:commentable, :dependent=>:destroy}:Hash (NoMethodError)
from /Users/myuser/.rvm/gems/ruby-3.0.2/gems/activerecord-6.1.4.4/lib/active_record/associations/builder/association.rb:53:in `build_scope'
from /Users/myuser/.rvm/gems/ruby-3.0.2/gems/activerecord-6.1.4.4/lib/active_record/associations/builder/association.rb:47:in `create_reflection'
from /Users/myuser/.rvm/gems/ruby-3.0.2/gems/activerecord-6.1.4.4/lib/active_record/associations/builder/association.rb:32:in `build'
from /Users/myuser/.rvm/gems/ruby-3.0.2/gems/activerecord-6.1.4.4/lib/active_record/associations.rb:1458:in `has_many'
from /Users/myuser/.rvm/gems/ruby-3.0.2/gems/acts_as_commentable-4.0.2/lib/commentable_methods.rb:58:in `acts_as_commentable'
…
Is there any simple replacement for this gem or way to monkey-patch this error so I can start up the app?
Looking over the forks, I found this one that appears to work for me using Rails 6.0.6 and Ruby 3.0.5.
https://github.com/alazycoder101/acts_as_commentable.git
I have not tested it extensively yet, but at least the basic functionality seems to be working for me. Hope this helps.
For clarity, to use that fork you would use the following line in your Gemfile:
gem 'acts_as_commentable', git: 'https://github.com/alazycoder101/acts_as_commentable.git'
This morning I forked the activemerchant Ruby gem b/c of a change I needed for my app. My gemfile used to be...
gem 'activemerchant', '~> 1.53.0'
Now it's...
gem 'activemerchant', :github => 'ajporterfield/active_merchant'
However, after running bundle update activemerchant and restarting my Rails server, I'm getting and uninitialized constant ActiveMerchant::Billing::PaypalExpressGateway error.
I am using the Paypal gateway, but my change was a one-liner in the BluePay gateway so I don't think I caused the error with my code change.
Is there an obvious step I'm missing in order to reference a gem from Github in my gemfile?
I'm using Rails 4, Ruby 2.
Thanks!
After revisiting this, I realized my mistake. I had already forked the activemerchant gem - a long time ago. So to fix, I deleted my forked repo and re-forked. Everything's working for me as expected now.
I use Ruby Mine 6.3, ruby 2.1 and Rails 4.0.3.
Which gems need to debug application with Ruby Mine, I tried use these gems:
gem 'debugger'
gem 'debugger-xml'
But application crashed with exit code 127 at breakpoint, and print this:
.rvm/gems/ruby-2.1.0/extensions/x86_64-linux/2.1.0/debugger-1.6.6/ruby_debug.so:
undefined symbol: rb_vm_get_sourceline
UPDATE
I updated RubyMine to 6.3.1, dropped 'debugger', 'debugger-xml' (in Gemfile only 'ruby-debug-ide') and Debugging works!
I advise bunch of "better_errors" and "binding_of_caller".
You can read about this here: https://github.com/charliesome/better_errors
I'm usually use this gems:
https://gist.github.com/MrEmelianenko/11078561
To enhance your console, use pry-rails, better with pry-doc.
To debug in program, like using breakpoint, step in/over, you can use pry-byebug or pry-debugger.
p.s. this is my way to debug rails app in terminal, I'm not sure if it is ok with Ruby Mine. Hope this can help.
I always liked pry. And its very useful with easy to learn screencast
This is my debugging stack for my Ruby 2 & Rails 3/4 apps ;)
group :development do
gem 'pry'
gem 'pry-nav'
gem 'pry-rescue'
gem 'pry-stack_explorer'
gem 'pry-doc'
end
Hope it helps
As you mentioned, you need ruby-debug-ide, but not debugger or debugger-xml.
For Rubymine/IDea + Ruby plugin with Ruby 2.0/2.1, also try the debase gem along with ruby-debug-ide to speed up debugging. Earlier versions had some trouble, but it works well, as of 2014-04-21.
You already found your answer but I'd like to add small notes
Rubymine has an issue with the debugger gem, or probably it's the gems clashing(maybe), rubymine uses fast-debugger (ruby-debug-ide) and I think it doesn't like debugger, old versions suggested adding debugger-xml but from my trials that didn't really work so well, and current version kinda tolerates debugger a bit, but sometimes it freezes during breakpoints.
My teammates use debugger, so it's pushed to the repo, what I do is whenever I need to debug I just delete the debugger line from my Gemfile and wait for rubymine to detect that Gemfile change (about a second or two) and start my debugging session, I only put it back when I check the diff before pushing.
I've googled this to death and I'm just going around in circles.
I'm on a Windows Server 2008r
I installed and put the following in my Gemfile
gem 'ruby-odbc' # I think the version is the.9999 one?
gem 'tiny_tds', "~> 0.6.1"
gem 'activerecord-sqlserver-adapter' # I've tried a few versions of this 3.2.8 and 4.0
I get varying errors depending on how many times i've bundle installed or updated
Errors include activesupport and activerecord versions not found. They are installed
Or I get alias_method errors.
Can someone just point me in the right direction of what I should do. Some discussions seem to think that there is nothing that works at the moment. Would downgrading to an older Rails work? If so how and which version?
activerecord-sqlserver-adapter hasn't been released for Rails 4.0 yet but the gem is 95% ready. You can use put it in your Gemfile like this:
gem 'activerecord-sqlserver-adapter', github: 'rails-sqlserver/activerecord-sqlserver-adapter'
For a description of the outstanding work take a look at Failed Tests & Segfault on this pull request.
I create rails app deployed on Heroku.
also, exception_notification gem enabled.
when it is on development setup ActionMailer to Gmail,
everything is fine and sends a notification from Gmail address.
but when it comes to production environment on Heroku,
I get following error when server trying to send a email.
ActionView::Template::Error (code converter not found (UTF-8 to UTF-16))
Could anyone tell me what's happening here?
The issue was raised on the main repository (see here), but so far was not addressed.
You might want to take a look at this fork to the exception_notification gem, specifically this commit which tries to deal with the problem:
https://github.com/alanjds/exception_notification/commit/048fc6be972189e62ca3b9453d19233ec5773016
To use this fork I pointed the gem to it, like so:
Gemfile:
gem 'exception_notification', git: 'git://github.com/alanjds/exception_notification.git'
This solved the issue for me.
Quick adjustment to solution by hananamar, otherwise you'll get an error:
gem 'exception_notification', :git => 'git://github.com/alanjds/exception_notification.git', :require => 'exception_notifier'
I know this is an old post but since I got the same issue some days ago, I wanted to share here that I solved it by forcing the latest version of the gem on my Heroku app.
gem 'exception_notification', '3.0.1'
I guess the problem was with version 3.0.0 and it is fixed on 3.0.1.