Unable to load a gem that I built - ruby

I referred to this link to build a Ruby gem. After doing:
gem build hola.gemspec
when I try to require the gem in irb, it throws this error:
LoadError (cannot load such file -- word_counter_gem)
Can you tell me what the issue is?

Related

Is the net/http gem not in the default library for Ruby?

I want to create a Gemfile.lock by typing 'bundle install' but my local machine can't find the gem net/http. I've tried typing 'bundle update net/http' & 'bundle --full-index' & 'gem install bundler' but I keep getting this error when I try 'bundle install' again:
Could not find gem 'net/http' in rubygems repository https://rubygems.org/ or installed locally. The source does not contain any versions of 'net/http'
my Gemfile resembles the following:
source "https://rubygems.org"
gem 'open-uri'
gem 'nokogiri'
gem 'net/http'
gem 'pry'
Other solutions to this problem suggest removing the line for gem net/http because net/http is part of the default library for Ruby...however when I do this everything loads fine, and I can create a Gemfile.lock upon typing 'bundle install' but when I run my code I get the following error:
Traceback (most recent call last):
run.rb:4:in `': uninitialized constant Net (NameError)
Did you mean? Set
The line of code this refers to is
response = Net::HTTP.get(url)
I'm running Ruby version 2.6.1
The name of the gem is net-http. It is one of the first hits when you google for "net/http".
However, in Ruby 2.6.1, net/http is still part of the standard library, not a gem. Net/http was only removed from the standard library in Ruby 3.0.
There are two different kinds of standard gems:
Default gems: These gems are part of Ruby and you can always require them directly. You cannot remove them. They are maintained by Ruby core.
Bundled gems: The behavior of bundled gems is similar to normal gems, but they get automatically installed when you install Ruby. They can be uninstalled and they are maintained outside of Ruby core.
Your problem is the wrong name gem ('net-http' instead of 'net/http', you can run gem search ^net to find out remote gems start by 'net').
If the gem is 'default', no need to declare it in Gemfile.
You can check standard default gems on: https://stdgems.org/

Cannot load libxml_ruby.so for libxml-ruby gem

I installed the libxml-ruby gem, with the --platform=x86_64 flag, and whenever I try to require 'xml' I get an error.
Ruby24-x64/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require':
126: The specified module could not be found.
- I:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/libxml-ruby-3.0.0/lib/libxml_ruby.so (LoadError)
I checked, and libxml_ruby.so is in that directory. Any ideas on how to fix this?
I am using Ruby version 2.4.1 on Windows 10.

ruby gem not loading with RubyMine

Ok so inside my Gemfile I have this gemspec
gem 'output', '0.1.0', git: 'ssh://git#git.company.com/pe/gem-output.git', tag: 'master'
When I run bundler install from RubyMine is says it was successful.
but in my ruby code when I try to call Output.write(message) it says:
`message': uninitialized constant Pmt::Output (NameError)`
So then if I do a require 'output' at the top of my file I get this error message:
`require': cannot load such file -- output (LoadError)`
Any advice would be much appreciated.

Building a Ruby Gem Gem::Exception Error

I have made a new gem called hola as based on
http://guides.rubygems.org/make-your-own-gem/
tutorial but this error keeps occuring
This gem is located in the folder
[gentoos#localhost hola]$ ls
bin data doc ext hola-1.0.gem
hola.gemspec lib Rakefile tests
I run the command as instructed on the website
gem install ./hola-1.0.gem
and this error occurs
[gentoos#localhost hola]$ gem install ./hola-1.0.gem
ERROR: While executing gem ... (Gem::Exception)
Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources
I tried installing OpenSSL but still wouldn't

Gem ImageSpec installed but not found

I want to use the ImageSpec gem so have the following in a file:
require 'imagespec'
but get the following load error at runtime:
`require': cannot load such file -- imagespec (LoadError)
gem list ruby-imagespec shows:
*** LOCAL GEMS ***
ruby-imagespec (0.3.1)
but gem which ruby-imagespec gives:
ERROR: Can't find ruby library file or shared library ruby-imagespec
How do I require the file?
You need to use require 'image_spec'. See the init.rb file for the gem.

Resources