I am trying to load (require) the httparty gem into a Ruby file but keep getting an error and am unsuccessful.
Below is the error copied:
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- httparty (LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/neilricci/Desktop/test.rb:1:in `<main>'
Below is where the httparty gem file is located on my computer:
/Users/neilricci/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/httparty-0.13.7/lib/httparty.rb
Issue was resolved by installing httparty with sudo, which is weird because I installed httparty as the main admin.
sudo gem install httparty
How are you requiring the HTTParty gem in your code? Sometimes an error occurs when you're including your gems with capital letters, that's to say a require "HTTParty" will be clearly different than require "httparty".
It can produce a 'require': cannot load such file -- HTTParty (LoadError), what's a name difference; possible solution is to refer your gem require in complete lowercase letter.
Another possible cause could be that your ruby version isn't compatible with what the gem needs, maybe you're running your piece of code with a previous version minor than what the gem needs to work; possible solution is to check what's the Ruby version dependency of the gem that's giving you problems, at the time of writing this the last version of HTTParty is the 0.14.0 what requires a version of Ruby equal or more actual than 1.9.3 (>= 1.9.3)
If your HTTParty gem version is old you're going to receive error messages with undefined methods, here the solution is obvious, check what version do you have and uninstall it using sudo gem uninstall httparty-gem and then install the new version using sudo gem install httparty-gem (sudo is to prevent possible future errors with the propietary who has installed the gem), or if you want you can just install it and have those two or more versions of the gem.
In my case I had put require 'httparty' on my class but still give me an error. I tried to Install and Uninstall httparty gem without any progress. Finally I could resolve the problem by adding gem 'httparty' line to my Gemfile file followed by running bundle install from command prompt.
I am using rails 5.2.3 with ruby 2.5.1
Try installing the gem:
gem install httparty
Your code seems to be running in Ruby 2.0.0, but the gem seems to be installed for Ruby 2.2.3.
Make sure your Ruby version is properly selected through rvm or chruby or whatever you personally use to manage your Ruby versions, and make sure the HTTParty is installed for the same version your code is running in.
Remove the code require 'httparty' wherever you have added.
Related
I am getting an error while creating a ruby on rails project. In command, I created a new project by typing rails new club, then bundle. Now, when I try to create my models and controllers by typing and entering rails g resource Club name, I get this error: superclass mismatch for class StringIO (TypeError).
gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:
in `require': superclass mismatch for class StringIO (TypeError)
I don't even has a class named StringIO, so I'm not sure where it came from.
ruby version: 2.6.8
rails: 6.1.4.1
Try reverting to an earlier version of StringIO
gem install stringio -v 0.1.4
gem uninstall stringio # remove 3.0.0 and 3.0.1
None of the above answers worked for me. What happened for me is that I added gem 'rubocop', '~> 0.67.2', require: false to Gemfile and ran bundle install.
This version of rubocop seems to have installed psych as a dependency and then psych has a dependency on stringio and I, correct me if I'm wrong, that must be conflicting with whatever stringio version is being used by bootsnap.
Anyway, to solve it I just deleted the rubocop line I added to Gemfile and added gem 'rubocop', require: false (which installed the latest rubocop version) then ran bundle install again.
As others have said on #jason-lee answer, for many people, this can be fixed just by uninstalling the existing stringio then running bundle install again.
gem uninstall stringio
bundle
I started getting this error after updating my gems. I tried uninstalling ruby and all my gems, updating rvm, but for me the solution appeared to be updating rubygems.
gem update --system
It works for me.
My Error was: The application encountered the following error: superclass mismatch for class StringIO (TypeError)
The problem was caused by this issue
https://www.redmine.org/issues/35435
It might help you. I also removed all gems related to #gem 'sdoc'
It seams like by default sdoc call internally gem 'psych', which is the gem uses the StringIO and both have different version you can check the difference in your GemFile.Lock to see difference between your 2 versions.
The error was gone when I bumped Ruby version to 3.0.4 from 2.7.6
RVM on Ubuntu (path related issue):
Exit all terminals
exit
Then start a new terminal, then:
rvm use [your version]
bundle install
rails c
I am building my first Rails application and want to include FileUtils in order to manage my Google sheets API (I got it to work in a standalone script).
However when I add FileUtils to my gemfile and use bundle install I get the following error:
ERROR: Error installing fileutils:
fileutils requires Ruby version >= 2.5.0dev.
And the most stable version of Ruby is 2.4.1.
So what am I missing?
Can you not use the version in the Standard Library? I'm not sure why you would need to add this to your gem file.
You should be able to use it with any standard Ruby installation:
require 'fileutils'
So what am I missing?
You are missing the fact that the gemification of the stdlib has only just now begun and is targeted at Ruby 2.5/3.0, so naturally that's what those Gems require.
Unless you are on Ruby 2.5, just use the stdlib version.
If you realy need to specify the fileutils gem in your gemfile, use:
gem 'fileutils', '0.7'
as 0.7.1 requires a new Ruby according to
https://rubygems.org/gems/fileutils/versions/0.7.1
I'm making a project and when I run a generate command I get the following error:
fullpath: /Users/adamgoldberg/shopify-sinatra-app/theappearsystemcontrol6
Your Ruby version is 2.3.1, but your Gemfile specified 2.2.2
Bundler::RubyVersionMismatch: Your Ruby version is 2.3.1, but your Gemfile specified 2.2.2
/Users/adamgoldberg/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/definition.rb:417:in `validate_ruby!'
/Users/adamgoldberg/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler.rb:91:in `setup'
/Users/adamgoldberg/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.5/lib/bundler/setup.rb:19:in `<top (required)>'
/Users/adamgoldberg/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/Users/adamgoldberg/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'bundler: failed to load command: rake (/Users/adamgoldberg/.rbenv/versions/2.3.1/bin/rake)
I have to use ruby version 2.3.1 for my project so I have attempted changing my Gemfile version.
my gemfile now contains this:
ruby "~> 2.3"
I have tried all sorts of commands so that the Gemfile recognises that I want to use a different ruby version. I have tried:
bundle update
bundle install
gem bundle install
rbenv rehash
even my Gemfile.lock says it is using 2.3.1:
RUBY VERSION
ruby 2.3.1p112
I have even deleted the project and started again.
Please help
An update: I deleted the project and restarted. here are the exact steps I took from my home directory
ruby -v: #2.3.1
git clone https://github.com/kevinhughes27/shopify-sinatra-app.git
gem install shopify-sinatra-app
shopify-sinatra-app-generator new myshop
and the same error as above appeared:
Your Ruby version is 2.3.1, but your Gemfile specified 2.2.2
My Gemfile looks like this:
source 'https://rubygems.org'
gemspec
it's practically empty... I haven't even specified the ruby version
I then ran
bundle install
bundle update
still the same error appears.
I then specified in my Gemspect the ruby version and it now looks like this:
source 'https://rubygems.org'
ruby "2.3.1"
gemspec
but still the same error appears
I don't think you can use version specifiers like that for the Ruby version. I've never seen any examples with that.
Perhaps try it like this if you want v2.3.1:
ruby "2.3.1"
The attempt you're taking here:
ruby "~> 2.3"
seems like the right approach, but you should use an exact Ruby version:
ruby "2.3.1"
It's worth mentioning that you don't necessarily need to manually specify your ruby version anywhere if you don't want to.
updated answer
i cloned the gem and tried installing it. I got the same error. I figured out where the source of the 2.2.2 dependency is. It's in the gem's source code, which for me is ~/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/shopify-sinatra-app-0.3.0. In examples/Gemfile there is a ruby '2.2.2' line.
I tried removing this line, but there was a different error installing activesupport. I think it's likely that the easiest solution for generating an app with this gem would be to install ruby 2.2.2
Trying to get started with API testing using rest client in ruby, however, hitting issue after issue, any how hopefully someone will be able to help.
I am using RVM ruby-2.0.0-p648
I have rest_client External Lib files, however, when I try to run my script I get the message: WARNING: The rest_client gem is deprecated and will be removed from RubyGems. Please use rest-client gem instead.
Process finished with exit code 0
So in my require I changed to rest-client and installed: gem install rest-client, however it is not showing in my external Libraries?
Anyone hit this issue before with a solution?
Also using rubymine.
Looks like you figured this out, but just to be clear...
You want to update the Gemfile.
Change
gem 'rest_client'
to
gem 'rest-client'
and then run bundle install.
have ruby 1.8.7, gem 1.3.7 and rails 3.0.6. I wanted to add xmpp4r to my project, but i got error just i require this gem. I'm install this gem using gem install xmpp4r. Installation seems successful.But, why error then appear?
P.S. if in console enter the irb and execute require "xmpp4r" result will be true.
P.S.S. OS is Fedora
Rails 3 uses Bundler to manage gem dependencies. When you start a rails 3 application, bundler sets up the require path to only include those gems you have specified in your Gemfile file, and their dependencies; it's not enough to just have the gem installed on your system.
In order to get this working, simply add this line to your Gemfile:
gem 'xmpp4r'