piotrmurach/tty

teletype new causes 'fatal: not a git repository (or any of the parent directories): .git' which is not really fatal

jayjlawrence opened this issue · 1 comments

Describe the problem

Running teletype new project will cause the following error to be emitted under ruby 2.5.1 on MacOS:

fatal: not a git repository (or any of the parent directories): .git

Steps to reproduce the problem

$ teletype new fubar

Cause

There is a call to Gem::Specification.load. This load invokes 'git ls-files' to expand the 'spec.files' value. Despite having a Dir.chdir in the generated spec code it is still in the wrong directory when this runs.

This is the code generated

  # Specify which files should be added to the gem when it is released.
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
  spec.files         = Dir.chdir(File.expand_path('..', __FILE__)) do
    `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
  end

Putting a Dir.chdir in the calling code mitigates this issue.

Fix

( I couldn't get the gem package built properly so I will not put in a PR. Instead offer the following edit)

In lib\tty\commands\new.rb

      def add_required_libs_to_gemspec
        Dir.chdir target_path do
   ....
       end
     end

Describe your environment

  • OS version: MacOS 10.14
  • Ruby version: 2.5.1 and 2.3.7
  • TTY version: 0.8.1

Thanks for reporting! This is already fixed in the master branch.