{"id":7021,"date":"2014-05-17T00:21:14","date_gmt":"2014-05-17T00:21:14","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/05\/17\/why-is-bundler-using-the-wrong-gemspec-file-collection-of-common-programming-errors\/"},"modified":"2014-05-17T00:21:14","modified_gmt":"2014-05-17T00:21:14","slug":"why-is-bundler-using-the-wrong-gemspec-file-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/05\/17\/why-is-bundler-using-the-wrong-gemspec-file-collection-of-common-programming-errors\/","title":{"rendered":"Why is bundler using the wrong gemspec file?-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;ve got a custom gem that has been working just fine with regards to bundling, building, distributing, &amp; 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 <code>bin<\/code> path of the gem that can be used to basically copy files from a <code>template<\/code> folder into a new folder where the user will develop their own gem.<\/p>\n<p>The problem I&#8217;m having is that the <code>template<\/code> folder has a gemspec file named <code>$name$.gemspec<\/code> with similarly named classes\/modules in the file (e.g.: <code>module $Name$<\/code>), where the <code>$name$<\/code> gets replaced with a name provided by the user.<\/p>\n<p>Unfortunately, when I run <code>bundle install<\/code> from my gem&#8217;s top-most path, I get an error:<\/p>\n<pre><code>There was a SyntaxError while evaluating $name$.gemspec:\nC:\/my_gem\/template\/$name$.gemspec:8: syntax error, unexpected tGVAR\n  gem.version = MyGem::$Name$::VERSION\n<\/code><\/pre>\n<p>It looks like Bundler is using the wrong Gemfile, even if I explicitly pass the Gemfile or path via one of the following:<\/p>\n<pre><code>bundle install --gemfile=Gemfile\nbundle install --path=C:\\my_gem\n<\/code><\/pre>\n<p>I also tried updating the <code>gemspec<\/code> line of my Gemfile to no avail:<\/p>\n<pre><code>gemspec name: 'my_gem'\n<\/code><\/pre>\n<p>Lastly, I&#8217;ve ensured that the <code>template<\/code> folder isn&#8217;t even included in <code>my_gem.gemspec<\/code>, but that doesn&#8217;t seem to matter:<\/p>\n<pre><code>gem.files = Dir.glob(\"lib\/**\/*\") + %w(LICENSE.txt README.md)\n<\/code><\/pre>\n<p>Does anyone know why Bundler is trying to read the <code>.\/template\/$name$.gemspec<\/code> instead of <code>.\/my_gem.gemspec<\/code>?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve got a custom gem that has been working just fine with regards to bundling, building, distributing, &amp; 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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7021","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7021","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7021"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7021\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7021"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7021"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7021"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}