Warning parser/current is loading parser/ruby22 - ruby

I'm newbie in Ruby, while excecuting a command I got this error.
warning: parser/current is loading parser/ruby22, which recognizes
warning: 2.2-compliant syntax, but you are running 2.3.1.
My Ruby version is 2.3.1
My parser version is 2.4.0.0.
I don't know why parser is loading from ruby22 which is not even installed in my computer.
Any help would be appreciated.

In my case, I was running an old version of Rubocop (which relies on the parser gem). Removing/updating rubocop or whatever gem is using parser may fix your issue.

Related

Ruby 2.7.4 Net Constant Warnings

I'm getting repetitive warnings upon running a ruby script in a crontab, as well as manually in the terminal.
/Users/rich/.rbenv/versions/2.7.4/lib/ruby/2.7.0/net/protocol.rb:66: warning: already initialized constant Net::ProtocRetryError
/Users/rich/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/net-protocol-0.1.2/lib/net/protocol.rb:68: warning: previous definition of ProtocRetryError was here
/Users/rich/.rbenv/versions/2.7.4/lib/ruby/2.7.0/net/protocol.rb:206: warning: already initialized constant Net::BufferedIO::BUFSIZE
/Users/rich/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/net-protocol-0.1.2/lib/net/protocol.rb:208: warning: previous definition of BUFSIZE was here
/Users/rich/.rbenv/versions/2.7.4/lib/ruby/2.7.0/net/protocol.rb:503: warning: already initialized constant Net::NetPrivate::Socket
/Users/rich/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/net-protocol-0.1.2/lib/net/protocol.rb:504: warning: previous definition of Socket was here
I've changed the script to either use net/http or Faraday, the latter I'm assuming requires the first. Having seen this behaviour before recently and way back, this is a reload of the net gem, which is part of the core if I am correct. I'm just not sure why it's reloading.
I'm using rbenv to juggle ruby versions for a couple of reasons, and that won't change. My shebang is #!/Users/rich/.rbenv/shims/ruby but my ruby version is a bit different:
$ which ruby
==> /Users/rich/.rbenv/versions/2.7.4/bin/ruby
$ ruby -v
==> Ruby version: ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [arm64-darwin21]
This slight difference from the shebang and requested versions of ruby might be the issue. I have many scripts that rely on that shebang, which points to the current rbenv version, which is what I want. I change versions from time to time and don't want to hard code that instruction.
Is there a way I can see why this is happening? How can I make these go away? How can I stop reloading core gems that are already loaded?
Bundler was the culprit with some dependency issues and reloading various versions on top of previous Gemfile.lock versions...something like that. Update this way:
bundle update --bundler
I had to add the following 2 lines to the Gemfile to finally eliminate the all the warnings:
gem 'net-http'
gem 'uri', '0.10.0' # force the default version for ruby 2.7

Cannot install RuboCop on RubyMine

I'm opening ruby file via RubyMine. IDE suggests installing RuboCop. I accept it, but after a few seconds it shows:
Following gems were not installed: rubocop (1.0.0): Cancelled
Documentation says its problem with interpreter path. Problem is its already set. Even when i try to add it like documentation says, it won't let me, because its already set.
Any ideas what i can do? I have been using VisualStudio Code without issues before it, but Ruby support is pretty poor, i had to use terminal, while for example python has full support and you can just run program with one button.

Error using module bzip2

I'm running into problems building bzip2-ruby.
Here is the error I am getting while building it...
Can someone help me understand what's going on?
/tmp/ruby/bin/gem -v
2.6.8
/tmp/ruby/bin/ruby -v
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]
In file included from bzip2.c:5:
/tmp/ruby/include/ruby-2.4.0/ruby/backward/rubyio.h:2:2: warning: #warning use "ruby/io.h" instead of "rubyio.h"
bzip2.c:6:21: error: version.h: No such file or directory
bzip2.c: In function ‘bz_find_struct’:
The error is described in https://github.com/brianmario/bzip2-ruby/issues/19 and fixed in the master branch of the gem.
Unfortunately, the fix is not yet released and given that the issue is now almost 4 years old, I'd wager the guess that it won't be released anymore. If you still want to use the gem, you can force to use the version directly from github by adding this to your Gemfile:
gem 'bzip2-ruby', git: 'https://github.com/brianmario/bzip2-ruby.git'
Generally, it is probably a good idea to switch to a gem which is actually maintained. A quick google search pointed e.g. to https://github.com/philr/bzip2-ffi.

ruby-xslt, Centos and undefined symbol xsltLibxmlVersion

I have a rails application using the following environment:
CentOS release 5.7 (Final)
Rails 3.0.9
Rubygems 1.6.2
Ruby 1.9.2
Passenger
Apache2
The Development environment differs and is: Ubuntu 10.04, Ruby 1.8.7 which works like a charm. I can't change the production environment.
I use ruby-xslt, gem version 0.9.8, the problem is when I access the application I get an error:
/usr/local/lib/ruby/gems/1.9.1/gems/ruby-xslt-0.9.8/lib/xml/xslt_lib.so: undefined symbol: xsltLibxmlVersion - /usr/local/lib/ruby/gems/1.9.1/gems/ruby-xslt-0.9.8/lib/xml/xslt_lib.so
The only solution I can find about this is:
http://amitsolanki.com/2010/04/undefined-symbol-xsltlibxmlversion-ruby-xslt-and-centos/
Which does not work for me.
I am stumped and would like to hear your opinions on what to do:
My ideas are as follows:
1) Don't use ruby-xslt - However this is the only ruby based xslt lib I could get to compile in development, which is why I used it. (but am open to suggestions).
2) Hack the ruby-xslt lib to remove the reference to the symbol, recompile and install. (tried but the error still appears so I may not be doing it right, I run "ruby setup.rb" for the gem again after the change but this is pure guesswork.)
3) Change the Ruby Environment to 1.8.7 as in development - don't think this will work as the problem is between the gem ruby-xslt and a linux library libxslt2.so and not the ruby env. (so actually not going to do this)
4) Add the symbol to the libxslt2.so lib, rebuild and install (but not worked with C language for 15 Years)
Any thoughts on this?
Regards
Paul
I solved this by using option number 1 and managed to get an older version of xslt-ruby installed (1.0.1), this involved installing a few libs as well.

Thin Crashes Hard with Ramaze

So, I'm just trying out Ramaze for a new project, and I'm wondering why it won't work with Thin, but will with ramaze start (which is webrick I guess). Here's what it gives me:
/opt/local/lib/ruby1.9/gems/1.9.1/gems/thin-1.2.2/lib/thin/request.rb:50: [BUG] unknown type 0x22 (0xc given)
This is the line it's talking about:
#parser = Thin::HttpParser.new
which isn't too helpful.
Does anyone have any ideas? Thanks!
EDIT: Actually, I remember getting this error a while back when I was trying to install the latest version of the MySQL gem. I had to reinstall it being sure to do a "make clean" before "make install". However, thin was installed from a gem, so I'm not sure how I would be able to do that here...
It means your eventmachine was compiled with Ruby 1.8 but runs with Ruby 1.9.
Do you have a parallel installation of 1.8/1.9?

Resources