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.
Related
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?
I'm executing the file app.rb in my rails project and trying to step through it using the byebug gem, but I get an error saying 'byebug' is an undefined local variable. I'm running the code using the command 'ruby app.rb'. Is there a different way to step through a ruby file when executing it this way via the command line?
$ bundle install
Fetching gem metadata from https://rubygems.org/.....
Resolving dependencies...
Using byebug 6.0.2
Installing pg 0.18.3
Using bundler 1.6.2
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
$ ruby app.rb
app.rb:17:in `block in <main>': undefined local variable or method `byebug' for main:Object (NameError)
from app.rb:15:in `glob'
from app.rb:15:in `<main>'
Looks like I just had to add require "byebug" at the top my app.rb file.
Another debugging option is the debugger gem:
require 'debugger'; debugger
https://github.com/cldwalker/debugger
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.
I have created a gem file similar to below, I'm trying this in windows 7 environment
source :rubygems
group :test do
gem 'cucumber', '1.2.1'
gem 'rspec-expectations', '2.11.2'
end
This is executed in cmd "C:\mysite\ruby test.rb"
System throw following error msg,
test.rb:1:in '<main>' : undefined method 'source' for main:Object (NoMethodError)
I have changed the first line as
source 'http://rubygems.org/'
But still I getting same error. Really appreciate if anyone can give instructions, I'm very new to cucumber & ruby
First install bundler with
gem install bundler
Then go into your project directory. The gem file must be named Gemfile. Then you can just do
bundle install
Also, you should use HTTPS:
source 'https://rubygems.org/'
it seems that you have put "source 'http://rubygems.org/' " line in
'test.rb', which is not allowed, you must have the file Gemfile and
put this code in Gemfile
source 'https://rubygems.org/
group :test do
gem 'cucumber', '1.2.1'
gem 'rspec-expectations', '2.11.2'
end
and do bundle install
I need to reference a local gem from a plain ruby script, without installing the gem. On the trail of How to refer a local gem in ruby?, i tried creating a Gemfile with the following setup:
%w(
custom_gem
another_custom_gem
).each do |dependency|
gem dependency, :path => File.expand_path("../../#{dependency}", __FILE__)
end
and the script looks like this:
require 'custom_gem'
CustomGem::Do.something
When I execute this with:
bundle exec ruby script.rb
I get:
script.rb:1:in `require': cannot load such file -- custom_gem (LoadError) from script.rb:1:in `<main>'
If I leave out the require 'custom_gem' , I get:
script.rb:3:in `<main>': uninitialized constant CustomGem (NameError)
I even tried without bundler, and just writing gem ... :path =>̣ ... in the script itself, but without results. Is there any other way of referencing custom gems from ruby scripts, without installing the gems locally?
Make sure that your gem name as same as in Gemfile (e.g. custom_gem)
# Gemfile
source "https://rubygems.org"
gem "custom_gem", path: "/home/username/path/to/custom_gem"
Don't forget to actually install this gem using bundler
bundle install
After that, the script should be ready to use by bundle exec ruby script.rb
# script.rb
require 'custom_gem'
CustomGem::Do.something
Without using a Gemfile, you can install a local version of a gem by running bundle exec rake install in the gem's root directory and then you can reference it just like any other installed gem.