I've pushed gem into rubygems. I can install it, but I can't require it.
irb(main):032:0> require 'jsql'
Traceback (most recent call last):
4: from C:/Ruby25-x64/bin/irb.cmd:19:in `<main>'
3: from (irb):32
2: from C:/Ruby25-x64/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:122:in `require'
1: from C:/Ruby25-x64/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:122:in `require'
LoadError (cannot load such file -- jsql)
I've had this problem once, with mechanize gem.
It seems you've create a gem called jsql which is listed on https://rubygems.org/gems/jsql.
So in orer to use it, you need to install it, either with gem install jsql or add it to the Gemfile of you project, along with other dependencies, and run bundle install
Only after this procedures, your gem will be available for use.
This generally occurs when the gem isn't installed for the ruby version you're using.
It happened to me with the irb gem, so I ran
RBENV_VERSION=2.6.3 gem install irb
I found that helpful note here. But the same could apply for any gem, just check the ruby version with ruby --version and try the above code (replacing irb with whatever gem you want to install)
Related
I am currently referencing code from the AWS Documentation Ruby Example JobStatusNotificationSample.rb
My error comes from the first line: require 'aws-sdk-elastictranscoder'
Which says that I am not able to load this file. In my code, I am already using
require 'aws-sdk-s3'
require 'aws-sdk-sqs'
with no previous issues. I have tried to add in require 'aws-sdk-core' but that did not change the error.
It is my first time working with an AWS implementation on Ruby.
I have an error below when I m using Ruby SDK gem v3.
Traceback (most recent call last):
2: from test_sdk.rb:1:in `<main>'
1: from /home/xxx/.rbenv/versions/2.7.6/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:83:in `require'
/home/xxx/.rbenv/versions/2.7.6/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:83:in `require': cannot load such file -- aws-sdk-s3 (LoadError)
My solution:
In your terminal install aws-sdk
gem install aws-sdk
Then in your ruby file test_sdk.rb, add these in the top of the file
#!/usr/bin/env ruby
require 'rubygems'
require 'aws-sdk-s3'
Then run ruby test_sdk.rb works for my case.
Reference link:
https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingTheMPRubyAPI.html
I'm looking to use a couple of new gems in my project, 'ruby-fftw3' and 'aubio'. The project has been happily working away and being extended but now every time I try and add a new gem it's unavailable when I try and call it.
The gems are listed in the Gemfile:
gem 'aubio'
gem 'ruby-fftw3'
When I run bundle install they are listed:
Using aubio 0.3.1
...
Using ruby-fftw3 1.0.2
Gemfile.lock also contains both items.
However, when I open rails c and try to use the gem they're unavailable:
irb(main):001:0> require 'ruby-fftw3'
Traceback (most recent call last):
1: from (irb):1
LoadError (cannot load such file -- ruby-fftw3)
irb(main):002:0> Aubio
Traceback (most recent call last):
1: from (irb):2
NameError (uninitialized constant Aubio)
It also appears that Bundler.require(:default).collect(&:name) does not contain either gem!
I've gone through the Gemfile and can't see any formatting errors and if there were any I don't think bundle install would create a lock file which included them.
I have installed the caldav-icloud gem. Then I've required it in my environment.rb
require "caldav-icloud"
But if I do rails s I get this error:
/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:in `require': cannot load such file -- caldav-icloud (LoadError)
How can I solve it?
Thanks
To make any gem available to your Rails app, you have to add it to the Gemfile like this:
gem "caldav-icloud"
It is not enough to just install it.
This answer goes into a bit more detail what bundler and the Gemfile do and why this is required.
When I add
require 'soundcloud'
in Rails and start the server using
rails server
I get
...rb:9:in `require': cannot load such file -- soundcloud (LoadError)
the same yields
=> true
in IRB.
I installed Ruby, Rails, etc following http://installrails.com/.
Any ideas what could be causing this?
Why don't you use Bundler?
Add to Gemfile:
gem 'soundcloud'
then run
bundle install
in the root of your project and it all should work automatically.
I am having issue connecting from ROR 3.2 to Oracle database.
irb(main):001:0> gem 'ruby-oci8', "~>2.1.0"
=> true
irb(main):002:0> gem 'activerecord-oracle_enhanced-adapter', '~> 1.4.1'
=> true
irb(main):003:0> exit
rails console
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require':
Please install the oracle_enhanced adapter: `gem install activerecord-o
racle_enhanced-adapter` (cannot load such file -- active_record/connection_adapters/oracle_enhanced_adapter) (LoadError)
I searched the web and it says i should create a gems file located at
https://github.com/rsim/oracle-enhanced/blob/master/Gemfile and then do a bundle install .
But i am new to rails and not sure how to do this any ideas please.
C:\kerbapp>bundle show activerecord-oracle_enhanced-adapter
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-oracle_enhanced-adapter-1.4.1
A rails application since 3.0 comes integrated with package management for gems called bundler (I recommend reading up more here). Any application will see only the gems included in its package list.
Your project should have a Gemfile file - add the gem 'activerecord-oracle_enhanced-adapter', '~> 1.4.1' line there, run bundle command from project root directory, and it should be good to go.
Keep in mind that when working with rails (and any sizable ruby project really) you should be adding all gems this way.