I am getting the following error when I make a rest-client request:
<internal:D:/softwares/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:96:in `require': D:/softwares/Ruby30-x64/lib/ruby/gems/3.0.0/gems/mime-types-3.1/lib/mime/types/logger.rb:28: _1 is reserved for numbered parameter (SyntaxError)
Here is my code:
require 'rest-client'
response = RestClient.get 'https://www.linkedin.com/feed/'
puts response
Can anyone solve this one in return thanks for appreciation?
You are having a gem versioning issue. The error you are getting when you require rest-client is:
.../mime-types-3.1/.../logger.rb:28: _1 is reserved for numbered parameter (SyntaxError)
This is a problem in the gem mime-types, which rest-client depends on. Ruby introduced a change in syntax to support 'numbered parameters' in blocks that made _1, _2, ... reserved words. That change meant that people who had named variables matching that style (_1, _2, etc.) got a warning in Ruby 2.7. In Ruby 3.0 (which you are using), that now causes a syntax error.
The version of mime-types you are using (3.1) must have had code of that kind; it worked prior to Ruby 3.0, but now breaks. The good news is that the latest version of mine-types, 3.3.1, works with Ruby 3. You just need to update your gem:
D:> gem update mime-types
Updating installed gems
Updating mime-types
Fetching mime-types-3.3.1.gem
Successfully installed mime-types-3.3.1
If you are using bundler, you might need to change the version in your Gemfile and re-rerun bundle install to trigger the update.
For every require load error execute the below command to install gems for ruby programs.
ruby -S gem install <gem-name>
in my case it is.
ruby -S gem install rest-client
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'm using Rails 3 and I want to use ferret in my app. I installed ferret 0.11.5-mswin32 (because i work on windows 7) and acts_as_ferret 0.4.4.
In my Gemfile I have:
gem 'ferret'
gem 'acts_as_ferret'
Then when I start the server I get this error:
Could not find gem 'ferret (>= 0)' in any of the gem sources listed in your Gemfile.
I have tried with
gem 'ferret', '0.11.5'
gem 'acts_as_ferret', '0.4.4'
and I still get the same error.
What do I need to put my Gemfile to get ferret working?
Thanks
The docs on acts_as_ferret stipulate you need version 0.5 or greater for rails 3, and ferret 0.11.8 (I would use 11.8.4 since it is the only release of the gem in 4 years...and that is a bit of a red flag).
No offense, but why are you using ferret?
A few years ago, that was a good idea, but since then other search engines have been better adopted and supported (sphinx, elastic search, solr).
Has any one come across this error?
NoMethodError (undefined method `new' for LinkedIn:Module)
I think it's related to omniauth and linkedin. Here's my Gemfile:
gem 'omniauth'
gem 'linkedin', :git => "git://github.com/redbeard-tech/linkedin.git", :branch => 'jsapi'
I'm using:
ruby 1.8.7 (2010-01-10 patchlevel 249)
rails 3.0.5
What might be the reason for it?
Check what version of omniauth you are using. We recently ran into this and it was from our dev environment having omniauth 0.3.x and the new environment getting the new 1.0 release. On the omniauth github site it says:
OmniAuth 1.0 has several breaking changes from version 0.x. You can set the dependency to ~> 0.3.2 if you do not wish to make the more difficult upgrade. See the wiki for more information.
I suspect you're being bitten by that.
From the error message it looks like you are calling LinkedIn.new(...), but looking at the documentation it seems like it should be LinkedIn::Client.new('your_consumer_key', 'your_consumer_secret'). LinkedIn is a module, not a class and therefore doesn't have a new method. However, there seems to be class called Client defined within this module, which you have to instantiate.
I'm getting the following error:
Gem::Exception: can't activate hpricot (= 0.6.161, runtime),
already activated hpricot-0.8.3
0.6 is installed locally, 0.8.3 is frozen in my app.
This is my "stacktrace":
Loading production environment (Rails 2.3.10)
/software/ruby-ror-gem-1.3.1/lib/rubygems.rb:149:in `activate':Gem::Exception: can't activate hpricot (= 0.6.161, runtime), already activated hpricot-0.8.3
/e/app/www.example.com/rails/releases/20101117142713/vendor/rails/railties/lib/console_with_helpers.rb:5:NameError: uninitialized constant ApplicationController
How do I figure out which gem or library has a dependency on hpricot 0.6?
I've added the output of user438962's command below:
{"daemons-1.0.9"=>[],
"scgi_dp_rails-0.0.5"=>["preforkdp", "daemons"],
"rails-2.3.10"=>[],
"rwfd-0.1.0"=>[],
"nokogiri-1.3.2"=>["racc", "rexical", "rake-compiler", "hoe"],
"activesupport-2.3.10"=>[],
"rack-1.0.1"=>
["test-spec",
"camping",
"fcgi",
"memcache-client",
"mongrel",
"ruby-openid",
"thin"],
"rack-1.1.0"=>
["test-spec", "camping", "fcgi", "memcache-client", "mongrel", "thin"],
"preforkdp-0.1.2"=>["rwfd"],
"activerecord-2.3.10"=>[],
"hpricot-0.6.161"=>[],
"cgi_multipart_eof_fix-2.5.0"=>[],
"fastthread-1.0.1"=>[],
"gem_plugin-0.2.3"=>[],
"activeresource-2.3.10"=>[],
"ferret-0.11.6"=>["rake"],
"mysql-2.7"=>[],
"actionmailer-2.3.10"=>[],
"actionpack-2.3.10"=>[],
"hpricot-0.8.3"=>[],
"mongrel_upload_progress-0.2.2"=>["mongrel", "gem_plugin"],
"mongrel-1.1.3"=>
["gem_plugin", "daemons", "fastthread", "cgi_multipart_eof_fix"],
"mongrel_cluster-1.0.5"=>["gem_plugin", "mongrel"],
"rake-0.8.4"=>[],
"haml-2.0.9"=>[],
"remvee-mini_magick-1.2.3.4.0"=>[]}
If you use Bundler, you avoid this problem and you have the really great command : bundle viz
This Command generate a graph with all dependencies.
require 'rubygems'
require 'pp'
h = {}
Gem.source_index.each{|g, spec| h[g] = spec.dependencies.map{|d| d.name} }
pp h
I found that rfeedparser is the gem that uses hpricot 0.6.
The problem is that this version (0.6) works with rfeedparser, but emits the warning "Passing no parameters to XML::SaxParser.new is deprecated."
Well, with newer versions of hpricot (at least 0.8.2), this warning seems to have taken effect, because now having that version of hpricot or newer causes "ArgumentError: wrong number of arguments (1 for 0)" when calling FeedParser.parse(url).
Unfortunately, I've found that the only way to make this work with legacy Rails (we have a 2.2.2 app) is to uninstall any hpricot version that's not 0.6.
The issue will be that one of the gems you use depends on hpricot version 0.6.161
and so tries to load it, but that you already have hpricot-0.8.3 loaded. The more recent version might be loaded if you're using hpricot yourself, and have required hpricot for use without specifying a version. If that's the case, you can change your own require to be the same version as the other gem uses (0.6.161).
The other reason the more recent version of hpricot is being loaded, could be that another gem you use depends on that version of hpricot, meaning you can't use the specific versions of those two gems you have because they have clashing requirements for their hpricot version.
Use the methods other users have posted to help you track down the dependencies of the gems you are using.
You could try grepping your load path:
$:.each do |dir|
cmd = %(grep -r hpricot #{dir})
puts cmd
puts `#{cmd}`
end