Missing File in Gem after Build
One of the things bundler did for you is start a local git repo to version-manage your gem code. Check that you have added the file in git
git add lib/gem_name/missing_file.rb
Bundler generated gems use git internally to track "membership" of source files for the gem. You can see this in the .gemspec where it uses backticks to call out to git and generate a file list:
gem.files = `git ls-files`.split($/)
Note this also means you should pay attention to what you list in .gitignore
Single file from gem missing after bundle install, included when using gem install
So the root cause of the issue was the existence of the vendor/cache
from bundler, which included a version of the gem with some faulty namings. As the gem version was not bumped while troubleshooting the issue, bundler always used the cached version.
Even though the gem was uninstalled from the system completely, it was still available in the local vendor/cache
. Upon bundle install
in that folder, bundler realized it had that gem available and used it from the cache.
That's also why the issue didn't appear with gem install
, since with that the vendor/cache
created by bundle gets ignored.
Ruby Gem .gem is empty after 'gem build'
On Windows operating system the following two lines would not obviously work:
s.files = `find *`.split("\n").uniq.sort.select{|f| !f.empty? }
s.test_files = `find spec/*`.split("\n")
They are used to produce arrays of files (sources and tests) out of your current directory structure. Both call a system to execute find
command which does unlikely happen to exist in Windows. To overcome the issue (since your gem
is relatively small) just list all the files manually, or use Dir#[]
or use any unix to build the gem
. Something like that should work (not tested):
s.files = Dir['./**/*'] # .select { |f| ... } # condition to include file
Skipping some files when building new gem
Remove config.yml
from s.files
in your project.gemspec
file inside your project and the file wont show up in your .gem-file.
s.files = `git ls-files`.split($/)
s.files -= ["spec/config.yml"]
Gem development can't add new file
Typically you'd add all the class/module files to the load path in the spec_helper.rb
file:
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
require "your_gem"
need to build gemspec and install gem everytime in make a change in gem file
Yes, it is possible to test your gem functionality without build and install it every time. Just specify path
option in your application Gemfile
(not in your gem):
gem 'your gem name', path: 'path to your gem directory'
After that you can just restart application to reload changes in your gem.
Here is more details about path
option.
I added the gem in rails, but it still says gem missing?
Now that Rails 3 is using bundler, you need to make it explicit that you want access to a specific gem in your app. To do this, go into your Gemfile
(in the root directory of your project) add this line:
gem 'omniauth'
then run bundle install
in the project directory, and you should be good to go. bundle install
simply makes sure that all gems and dependencies are installed on the current system. Good luck!
Related Topics
How to Convert Boolean Values to Integers
How to Split a String by Commas Except Inside Parenthesis, Using a Regular Expression
Is Regexp.Last_Match Thread Safe
Ruby-Rails Serve Ftp File Direct to Client
Use Ruby Array for a JavaScript Array in Erb. Escaping Quotes
What Does "Temps.Each(&:Valid)" Mean in Ruby
Cast Between String and Classname
How to Handle Method Order in Ruby
Ruby Inside JavaScript Block [Slim Template]
How to Extract a Single Character (As a String) from a Larger String in Ruby
How to Get Http Headers Before Downloading with Ruby's Openuri
Can One Yaml Object Refer to Another
Can't Convert String into Integer in Ruby/Ruby-On-Rails