Using jruby 1.5.1
In a pretty simple cronjob that uses gems:
dbi
dbd-jdbc
jdbc-mysql
It also uses a pure Java JDBC driver in a jar, jtds-1.2.5.jar
Every time I run it, I get this in STDERR (which is annoying my cronjob monitoring utilty which thinks anything on stderr may be a problem)
/usr/local/rvm/gems/jruby-1.6.5.1/gems/deprecated-2.0.1/lib/deprecated.rb:199 warning: already initialized constant Deprecate
?? Any ideas? What's going on, what can I do about it? Not sure which of these gems depends on 'deprecated' library or what version, any easy way to find out?
Ah, okay, figured it out:
[rochkind#catalyst pull_reserves]$ gem dependency dbi
Gem dbi-0.4.5
deprecated (= 2.0.1)
But 0.4.5 is the most recent version of 'dbi', and it is locked to 2.0.1 of 'deprecated'. There is a more recent 3.0.0 version of deprecated.
Okay... not sure what my question is now, except if anyone can figure out more about what's going on, and what my actual options are. I guess report as an issue to 'dbi' gem, hoping it's got some maintainers who care, I dunno.
more update: Okay, and there's already an issue filed for this, from August. https://github.com/erikh/ruby-dbi/pull/8 Looks like the gem is not very maintained. sigh. sometimes ruby community really frustrates me.
I think this is what you need:
Suppress Warnings From Ruby
A comment there mentions the Rails method to silence warnings, but I don't think you're using Rails.
EDIT: I found slightly cleaner code here:
https://mislav.net/2011/06/ruby-verbose-mode/
EDIT: Note: A commenter below seems to disagree with the blog entry mentioned above. I'm not expressing agreement or disagreement with the blog entry and I'm not opinionating on the goodness or badness of Ruby's verbose mode, merely crediting the author for the slightly cleaner code I found there.
I think this is what you'd do:
module Kernel
def silence_warnings
with_warnings(nil) { yield }
end
def with_warnings(flag)
old_verbose, $VERBOSE = $VERBOSE, flag
yield
ensure
$VERBOSE = old_verbose
end
end unless Kernel.respond_to? :silence_warnings
# assuming the warning is being generated when the dbi module is loaded...
silence_warnings { require 'dbi' }
Related
ruby - 2.7.2
rails - 6.0
paperclip - 6.1.0
I am getting following warning in my console, while using paperclip gem with ruby 2.7.2
/Users/***/.rvm/gems/ruby-2.7.2/gems/paperclip-6.1.0/lib/paperclip/url_generator.rb:68: warning: URI.escape is obsolete
I know there are no maintainers for paperclip and it is deprecated but I cannot use active storage as I found paperclip is the easiest and best way for implementing attachments. How can I solve this warning ?
When you say "solve" the warning it's not quite clear what you might consider to be an acceptable solution. But you could:
a) Ignore the warning so long as you are sticking with these versions of Ruby and Rails, as it does not mean that anything is broken.
b) Write some code to suppress this specific warning, though I'd probably not do this as you'd increase the chance of forgetting about the issue, and then ending up with a more acute and time-sensitive problem down the road, if you upgraded part of your system to where URI.escape was no longer available.
c) Do what I've done in my Rails application, which is switch to a forked and maintained version of Paperclip, KT-Paperclip. If you wanted to update to the minimum version number that addresses these deprecation warnings, you'd choose 6.4.
Wellll the right answer is to do something better for your codebase as #UptDogTT suggests... but if you just need a get-it-done answer, this monkey patch adds URI.escape back using equivalent functionality. Add it as an initializer:
module URI
def self.escape url
URI::Parser.new.escape url
end
end
My question is about the ruby-doc.org documentation, but also relates to the ri documentation lookup inside ruby.
I've already read dozens of similar questions/answers about the ri not working and giving "nothing known" messages and I've tried to follow some of that old advice. It just seems that those old answers aren't applicable to me.
One was to install the rdoc --all --ri from the ruby root directory. I tried that and it failed (unable to convert to UTF8 or something like that).
Another suggested that the rubyinstaller for windows installer just doesn't contain that info anymore and I should use the online documentation, which, when I goto http://ruby-doc.org/downloads/ I discover that the version I am using (2.4.4) does not exist.
This is odd, because the rubyinstaller site specifically says that if I'm new to Ruby(which I am), I should install 2.4.4. You'd think that if any version had good documentation, it would be that one. Instead, it seems to be missing entirely.
This all started because I am trying to learn Ruby and am watching the Lynda.com course on Ruby by Kevin Skoglund, which was recorded many versions ago and in that course he refers to the ri command from the shell, which in my version doesn't work. see below:
ruby --version
ruby 2.4.4p296 (2018-03-28 revision 63013) [x64-mingw32]
ri --version
ri.cmd 5.0.0
ri String
Nothing known about String
Now, if it's not available within ruby using ri, and I have to use online documentation, AND it's missing for my version, which happens to be the version recommended for new users, … you see my frustration.
Here's what I really want...
1. I want to use ri and have it work.
2. If that's just not possible, I'd like to know where the documentation for my version is online, because it's not where it's supposed to be.
Any help is appreciated. If it involves installing anything, letting me know HOW to do that is also appreciated. As I mentioned, I'm new.
Since you are using the RubyInstaller, I will assume that you are on Windows.
I will open this by saying that I am not 100% on this, but I am pretty condfident in this answer.
The "Use 2.4, not 2.5" was due to errors with Ruby Gem when Ruby 2.5
was first released, as I happen to be on a Windows machine installing
Ruby at that exact time, and that was the reasoning at that point not
to use the newest 2.5 version.
The above mentioned reason has since been corrected.
Realistically, if you are beginner, as long as you using documentation that is close to your version (2.0+ - 2.4-ish), it will be fine. Now obviously, and I shouldn't have to provide this disclaimer, though I will so to avoid the inevitable down-votes if I don't, this is not 100% perfect solution and there will be very small differences. As a beginner, the likelihood of you encountering any of these differences are extremely low, low enough not to even worry about. There are missing and poorly documented sections of every language, and Ruby is no exception. Typically these are less used classes (though Ruby Fiddle is an exception that I hate how poorly documented it is), and will have no effect on your learning process as you learn the fundamentals and core of the language.
To my recollection, the "core" is rather well documented, and so long as you use documentation from 2.0+ (the closer to 2.4 the better), you should be completely fine, and it is exactly the same. The "standard library" may be slightly more hit or miss, and your mileage may vary a little more, yet still nothing too extreme.
So, to address the second part of your question, do not worry too hard about finding the EXACT version of documentation you are using. It may not even exist online, though the installer should have provided a CHM help file (there will be shortcut for it with the shortcuts for Ruby, IRB, etc.
As for "why" ri is not working, I am not 100% sure yet again. I am on ArchLinux, and RDoc doesn't even built. Honestly, RDoc is being left by the wayside for newer (and IMO better) document engine, namely YARD. A possible solution that I do, and prefer, is to install the YARD gem right after I install Ruby:
gem install yard
And then set YARD to generate my documentation with this in CMD:
yard config --gem-install-yri
If you decide to take this route, much more can be learned about it here.
The benefit with it is that it also supports RDoc and is backwards compatible.
When I run my Rails app in WEBrick on Ubuntu, after upgrading to ruby-1.9.3-p327, I receive the following error:
[rake --tasks] /home/dsilver/.rvm/gems/ruby-1.9.3-p327/gems/em-dir-watcher-0.9.4/lib/em-dir-watcher.rb:7: Use RbConfig instead of obsolete and deprecated Config.
Any idea what's going on?
I've seen some posts connecting this to ImageMagick on Windows. I am on Ubuntu, but the app does use ImageMagick, and the ImageMagick functionality appears to have broken since the ruby upgrade from 1.9.2 to 1.9.3. I suspect a connection.
Thanks!
The Config module has been renamed to RbConfig. It’s still possible to use the old name, for backwards compatibility, but Ruby issues a warning if you do.
The em-dir-watcher gem uses the old name, and so you see the warning when it’s loaded. Someone has already sent a pull request fixing this, however the last update to em-dir-watcher was over two years ago so it might not get merged.
This is a warning that is generated, not an error, so your code should actually still work okay. If you really want to get rid of the warning you could add something like this before you require 'em-dir-watcher':
Object.send :remove_const, :Config
Config = RbConfig
This defines Config to be the same as RbConfig, which is what Ruby does anyway, but prevents the warning.
You can do (not recommended):
Go to the file ../lib/ruby/1.9/rbconfig/obsolete.rb
Edit the file, the change is commenting the line #warn ...
With that change, eliminated the advice "warn"
I'm trying to prettify my rdoc documentation, using version 3.5.3. I'm not a fan of the built-in darkfish theme, so I tried to find a way to replace it with the one used by the official Rails API documentation at http://api.rubyonrails.org/, but I've had no luck finding it in any readily available form. I've searched all over github, among other things.
What I've found so far is
https://github.com/mislav/hanna
which might be slightly out of date, and it's fork
https://github.com/rdoc/hanna-nouveau
Both are nice, but not quite what I want. So before I start fiddling with those templates, does anyone know if the template used by the Rails API docs is available as a gem somewhere?
Thanks!
I know this is very late, but it looks like the new version of Rails uses something called sdoc, which enhances the output with JavaScript searching, and is a little cleaner IMO. Doing a simple "gem install sdoc" will get what you need, then just use rdoc.options << '-f' << 'sdoc'.
The github project appears to be at https://github.com/voloko/sdoc/
By the way, thanks for the question! Without the initial answer posted, I'd have never found where to look, and been stuck with that horrible darkfish theme for my own projects!
This looks like it. Ignore the instructions that say to do a gem install horo --pre -- that'll actually give you an older beta version. Just do gem install horo and you'll get the current 1.0.3 version (Edit: I sent a pull request to update the instructions, which has already been accepted).
https://github.com/tenderlove/horo
By the way, I found this by looking at the Rails source code and viewing the Rakefile to see the RDoc options. Specifically, line 67 shows rdoc.options << '-f' << 'horo'.
When I load andand in Ruby 1.9 I get the warning
andand.rb:111: warning: undefining 'object_id' may cause serious problem
Does anyone know a way, other than modifying andand to not remove object_id, to avoid this warning?
Thanks!
You're in luck - it was just patched with a fix for this issue.
Unfortunately, as of 2011-03, the gem has not been published with this patch in place. However, there is a fork which sole purpose is to have that patch: ryansch-andand
Good news! Version v1.3.3 was pushed to RubyGems on 2012-03-28, and includes this fix.