Why is bundler using the wrong gemspec file?-Collection of common programming errors
I’ve got a custom gem that has been working just fine with regards to bundling, building, distributing, & implementing. The gem is the core of a framework from which other gems are derived. Since most derived gems will have the same basic structure, I want to include a Ruby script in the bin
path of the gem that can be used to basically copy files from a template
folder into a new folder where the user will develop their own gem.
The problem I’m having is that the template
folder has a gemspec file named $name$.gemspec
with similarly named classes/modules in the file (e.g.: module $Name$
), where the $name$
gets replaced with a name provided by the user.
Unfortunately, when I run bundle install
from my gem’s top-most path, I get an error:
There was a SyntaxError while evaluating $name$.gemspec:
C:/my_gem/template/$name$.gemspec:8: syntax error, unexpected tGVAR
gem.version = MyGem::$Name$::VERSION
It looks like Bundler is using the wrong Gemfile, even if I explicitly pass the Gemfile or path via one of the following:
bundle install --gemfile=Gemfile
bundle install --path=C:\my_gem
I also tried updating the gemspec
line of my Gemfile to no avail:
gemspec name: 'my_gem'
Lastly, I’ve ensured that the template
folder isn’t even included in my_gem.gemspec
, but that doesn’t seem to matter:
gem.files = Dir.glob("lib/**/*") + %w(LICENSE.txt README.md)
Does anyone know why Bundler is trying to read the ./template/$name$.gemspec
instead of ./my_gem.gemspec
?