Search code examples
rubysecurityrubygemsbundler

Skipping some files when building new gem


I've never built my own gem before, so this is a totally new experience. I've built a library for my employer, which has to connect to a database of ours in order to run some of my tests. I want to make sure this config.yml file isn't included in the gem when I publish it. I've added it to the .gitignore file, as I know to do that, but is there some other change I have to make to the .gemspec maybe? Or does bundler only include files it knows about when releasing the library to the public? Just trying to be cautious, first time publishing open source code!


Specification after @Oleander replied:

Running git ls-files in the command line doesn't include the file I want to remove, and my spec.require_paths in the .gemspec file reads like this: ["lib"]. The spec directory isn't there. Does that mean the config.yml file won't be included when I release the gem?


Solution

  • 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"]