can't require my gem - cannot load such file - ruby

I want to require my gem. I create gemset, сhoose it. After create two files
.ruby-version and .ruby-gemset, next i do bundle init in Gemfile i write
gem 'codebreaker', git: 'https://github.com/somerepo', branch: 'development'
After this, bundle install. When i require 'codebreaker' - i take
<internal:/home/home/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- codebreaker (LoadError)
from <internal:/home/home/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from test.rb:1:in `<main>'
But when i do bundle info codebreaker, i see all description, which i do in gemspec

Related

getting this error while running a ruby script

2: from apk-embed-payload.rb:9:in `<main>'
1: from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
/usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require': cannot load such file -- colorize (LoadError)
It looks to me like you have a require 'colorize' in your code, but the gem colorize is not installed. You can install the gem by running:
gem install colorize
I assume you have gem installed. Otherwise you need to install it as well.

cucumber --tag=#homepage_page --format progress --format html --out=reports/feature.html cannot load such file -- rspec (LoadError)

cucumber --tag=#homepage_page --format progress --format html --out=reports/feature.html cannot load such file -- rspec (LoadError)
When I try to generate the HTML reports, I am getting this error:
cannot load such file -- rspec (LoadError)
/Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/Users/eun081/Documents/Ajay/PROJECTS/COMPLETED/Updated/Automation/features/support/env.rb:1:in `<top (required)>'
/Library/Ruby/Gems/2.0.0/gems/cucumber-2.4.0/lib/cucumber/rb_support/rb_language.rb:96:in `load'
/Library/Ruby/Gems/2.0.0/gems/cucumber-2.4.0/lib/cucumber/rb_support/rb_language.rb:96:in `load_code_file'
/Library/Ruby/Gems/2.0.0/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:142:in `load_file'
/Library/Ruby/Gems/2.0.0/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:84:in `block in load_files!'
/Library/Ruby/Gems/2.0.0/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:83:in `each'
/Library/Ruby/Gems/2.0.0/gems/cucumber-2.4.0/lib/cucumber/runtime/support_code.rb:83:in `load_files!'
/Library/Ruby/Gems/2.0.0/gems/cucumber-2.4.0/lib/cucumber/runtime.rb:253:in `load_step_definitions'
/Library/Ruby/Gems/2.0.0/gems/cucumber-2.4.0/lib/cucumber/runtime.rb:61:in `run!'
/Library/Ruby/Gems/2.0.0/gems/cucumber-2.4.0/lib/cucumber/cli/main.rb:32:in `execute!'
/Library/Ruby/Gems/2.0.0/gems/cucumber-2.4.0/bin/cucumber:8:in `<top (required)>'
/usr/local/bin/cucumber:22:in `load'
/usr/local/bin/cucumber:22:in `<main>'
Here is my
RubyGems Environment:
- RUBYGEMS VERSION: 2.6.11
- RUBY VERSION: 2.0.0 (2015-12-16 patchlevel 648) [universal.x86_64 darwin16]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.0.0
- USER INSTALLATION DIRECTORY: /Users/eun081/.gem/ruby/2.0.0
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- SPEC CACHE DIRECTORY: /Users/eun081/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-16
- GEM PATHS:
- /Library/Ruby/Gems/2.0.0
- /Users/eun081/.gem/ruby/2.0.0
- /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-document"
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/eun081/.rvm/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Users/eun081/.rvm/bin
Here is my env.rb:-
require 'rspec'
require 'watir-webdriver'
require 'cucumber'
require 'rake'
require 'spreadsheet'
require 'yaml'
require 'page-object'
require 'yaml'
Here is my gem file:-
source "http://rubygems.org"
gem of "rake"
gem "cucumber"
gem "rspec"
#gem "watir-webdriver"
gem 'selenium-webdriver','~>2.53.0'
gem 'watir-webdriver','~>0.9.1'
gem 'spreadsheet'
gem 'rubyXL'
gem 'roo'
gem 'page-object'
gem 'require_all'
gem 'faker'
gem 'parallel_tests', '~> 2.2', '>= 2.2.2'
gem 'nokogiri', '1.3.3'
The answer was in the very first comment 'is rspec installed?' From the list of gems you give in your comments it looks a lot like you have some parts of rspec installed, but not the base rspec gem itself.
You need to run the command gem install rspec (or if you are in the directory with the gem file you listed, you should be able to just run Bundle Install, but it does need to be from that directory, for bundler to find the gemfile)
Clearly you believe you have rspec installed as you have maintained that when asked about it, but the error indicates otherwise. If you need more proof that this is the issue, see below.
On a clean system just now without rspec installed, my original gem list output showed no gems with rspec in the name..
I then ran gem install rspec, and after that was done when I ran gem list rspec I got the following
C:\Users\chuckv>gem list rspec
*** LOCAL GEMS ***
rspec (3.6.0)
rspec-core (3.6.0)
rspec-expectations (3.6.0)
rspec-mocks (3.6.0)
rspec-support (3.6.0)
I can then start an IRB session and do require 'rspec' and it works like thus..
C:\Users\chuckv>irb
irb(main):001:0> require 'rspec'
=> true
If I run gem uninstall rspec then it removes JUST the base rspec gem, leaving the others, creating a gem list output that looks similar to what you put in the comments. If I start an IRB session and do require 'rspec' then I get basically the same error you did (sans the cucumber call stack)
C:\Users\chuckv>gem list rspec
*** LOCAL GEMS ***
rspec-core (3.6.0)
rspec-expectations (3.6.0)
rspec-mocks (3.6.0)
rspec-support (3.6.0)
C:\Users\chuckv>irb
irb(main):001:0> require 'rspec'
LoadError: cannot load such file -- rspec
from C:/Ruby22/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from C:/Ruby22/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from (irb):1
from C:/Ruby22/bin/irb:11:in `<main>'
If I then run gem install rspec I am back to having rspec in the output of gem list rspec and the require command works once again.

in `require': no such file to load -- active_record (LoadError)

I hope that vcap-service-base of cloudfoundry can visit database of cloud_controller, then I need provisioner.rb in vcap-service-base to require 'active_record'.
So I added "gem "activerecord" "in the Gemfile of vcap-service-base and then ran 'bundle install'.
In the provisioner.rb, I added "require 'active_record'",while starting cloudfoundry, it always threw an error:in `require': no such file to load -- active_record (LoadError), as below:
/root/cloudfoundry/.deployments/devbox/deploy/rubies/ruby-1.9.2-p180/lib/ruby/gems/1.9.1/bundler/gems/vcap-services-base-1077d35ef73b/lib/base/provisioner.rb:9:in `require': no such file to load -- active_record (LoadError)
from /root/cloudfoundry/.deployments/devbox/deploy/rubies/ruby-1.9.2-p180/lib/ruby/gems/1.9.1/bundler/gems/vcap-services-base-1077d35ef73b/lib/base/provisioner.rb:9:in `<top (required)>'
from /root/cloudfoundry/.deployments/devbox/deploy/rubies/ruby-1.9.2-p180/lib/ruby/gems/1.9.1/bundler/gems/vcap-services-base-1077d35ef73b/lib/vcap_services_base.rb:4:in `require'
from /root/cloudfoundry/.deployments/devbox/deploy/rubies/ruby-1.9.2-p180/lib/ruby/gems/1.9.1/bundler/gems/vcap-services-base-1077d35ef73b/lib/vcap_services_base.rb:4:in `<top (required)>'
from /root/cloudfoundry/vcap/bin/../services/mysql/bin/mysql_node:7:in `require'
from /root/cloudfoundry/vcap/bin/../services/mysql/bin/mysql_node:7:in `<main>'
According to the error, it was LoadError.
But when I searched the gem "active_record" in /root/cloudfoundry/.deployments/devbox/deploy/rubies/ruby-1.9.2-p180/lib/ruby/gems/1.9.1/gems, it was there exactly.
Now I am confused whether it is the LoadError or I missed something important.
Why in vcap-service-base, can "require 'active_record'" not be found ?
When deploying any rails-3 app on cloud foundry, we need to follow the below steps.
If any gems are using inside the app, they should do bundle package and then again bundle install.
In config/environments/production.rb file, modify the line
config.serve_static_assets = false
to
config.serve_static_assets = true
Pre-Compile the assets using the below command
bundle exec rake assets:precompile
Push the app to vmc by following command.
vmc push --runtime ruby19

Referencing a local gem with RVM and Bundler?

I want to work on a supporting library while building an application while using RVM and Bundler to manage my application environment.
In my Gemfile is
# forked and cloned to local directory
gem 'feedzirra', :path => '../../feedzirra'
Then on command line:
$ bundle install
..
Using feedzirra (0.2.0.rc2) from source at /Users/ryan/dev/feedzirra
..
$ bundle show feedzirra
/Users/ryan/dev/feedzirra
$ gem which feedzirra
ERROR: Can't find ruby library file or shared library feedzirra
irb:
1.9.3p194 :001 > require 'feedzirra'
LoadError: cannot load such file -- feedzirra
from /Users/ryan/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/ryan/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from (irb):1
from /Users/ryan/.rvm/rubies/ruby-1.9.3-p194/bin/irb:16:in `<main>'
What am I missing?
you need to run it in context of bundler:
bundle exec gem which feedzirra
or
bundle exec irb

Ruby refuses to acknowledge that I've installed Rubygems... Why?

C:\Users\wipe\Quora-Personal-Analytics>ruby hello.rb
hello
C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original
_require': no such file to load -- bundler/setup (LoadError)
from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in
`require'
from hello.rb:4
C:\Users\wipe\Quora-Personal-Analytics>ruby require 'date'
ruby: No such file or directory -- require (LoadError)
C:\Users\wipe\Quora-Personal-Analytics>ruby require 'rubygems'
ruby: No such file or directory -- require (LoadError)
C:\Users\wipe\Quora-Personal-Analytics>
===
I'm using Ruby 1.8.7. Also, this worked before (on the same computer).
The require statements all do work when I try things from interactive ruby.So they all are installed. But I need the command line.
==
Edit: Here are the contents of Hello.rb
puts "hello"
require 'rubygems'
require 'bundler/setup'
require 'date'
require 'watir'
require 'optparse'
And some new error:
C:\Users\wipe\Quora-Personal-Analytics>ruby require 'rubygems'
ruby: No such file or directory -- require (LoadError)
C:\Users\wipe\Quora-Personal-Analytics>ruby hello.rb
hello
←[31mCould not find OptionParser-0.5.1 in any of the sources←[0m
←[33mRun `bundle install` to install missing gems.←[0m
C:\Users\wipe\Quora-Personal-Analytics>ruby bundle install
ruby: No such file or directory -- bundle (LoadError)
C:\Users\wipe\Quora-Personal-Analytics>ruby -e "require 'date'"
C:\Users\wipe\Quora-Personal-Analytics>ruby -e "require 'rubygems'"
C:\Users\wipe\Quora-Personal-Analytics>ruby QuoraStats.rb "firstname-lastname"
C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original
_require': no such file to load -- httparty (LoadError)
from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in
`require'
from ./lib/Content.rb:1
from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in
`gem_original_require'
from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in
`require'
from QuoraStats.rb:10
Somehow, ruby bundle install doesn't work very well:
C:\Users\wipe\Quora-Personal-Analytics>ruby bundle install
ruby: No such file or directory -- bundle (LoadError)
It looks like you don't have bundler installed. Try running gem install bundler, and then rerun ruby hello.rb.
Also, the two last commands you're typing won't work. ruby require 'date' is going to try to run the file "require" and pass it the argument 'date', not execute require 'date'. To just execute one line of ruby, use the -e flag, like this:
ruby -e "require 'date'"
Your stacktrace says
`gem_original
_require': no such file to load -- bundler/setup (LoadError)
Did you make sure bundler is actually installed? If not, try
gem install bundler
and retry.
Edit:
With the new errors you receive, simply try running
`bundle install`
then try again.

Resources