during a local gem install of the gem I created I get a “Unable to resolve dependencies”?

StackOverflow https://stackoverflow.com/questions/9832384

  •  25-05-2021
  •  | 
  •  

Question

why would I get this error when trying to do a local install of the gem I just created. Note I do not want to publish it out on internet, just use it myself internally:

MacBook-Pro:$ sudo gem install ./mylibrary-0.1.0.gem
ERROR:  While executing gem ... (Gem::DependencyError)
    Unable to resolve dependencies: mylibrary requires yaml (>= 0), erb (>= 0), date (>= 0), net/smtp (>= 0)

the key parts of the gemspec are:

Gem::Specification.new do |s|
  s.add_dependency('yaml')
  s.add_dependency('erb')
  s.add_dependency('mechanize')
  s.add_dependency('date')
  s.add_dependency('json')
  s.add_dependency('net/smtp')
  s.add_dependency('mail')
end

Aside: for the moment I've still left the "require 'yaml'" lines in my ruby files. Not quite sure whether I'm supposed to take these out or not when using my gem once I do successfully get it installed localled.

Was it helpful?

Solution

Corrected this answer with madth3's input.

yaml, date, erb and net/smtp are not gems. Remove these as dependencies and you should be good to go.

Gem::Specification.new do |s|
  s.add_dependency('mechanize','~> 2.3')
  s.add_dependency('json',     '~> 1.6.5')
  s.add_dependency('mail',     '~> 2.4.4')
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top