Ask A Question

Notifications

You’re not receiving notifications from this thread.

Fatal - not a git repository on server (deployed with Capistrano)

Matthew LS asked in Rails

Some time recently, my app started throwing fatal: not a git repository (or any of the parent directories): .git on the server. It shows up if I ever remote in and run a bundle exec command (e.g. RAILS_ENV=production bundle exec rails console) and it also shows up in the Capistrano logs when I deploy. The weird thing is, it doesn't seem to start happening during the deploy until after Capistrano runs bundler:install:

00:08 bundler:config
      01 $HOME/.rbenv/bin/rbenv exec bundle config --local deployment true
    ✔ 01 deploy@web01.moore.edu.au 0.265s
      02 $HOME/.rbenv/bin/rbenv exec bundle config --local path /home/deploy/philoi/shared/bundle
    ✔ 02 deploy@web01.moore.edu.au 0.267s
      03 $HOME/.rbenv/bin/rbenv exec bundle config --local without development:test
    ✔ 03 deploy@web01.moore.edu.au 0.241s
00:10 bundler:install
      The Gemfile's dependencies are satisfied, skipping installation
00:10 deploy:assets:precompile
      01 $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile
      01 fatal: not a git repository (or any of the parent directories): .git
      01 fatal: not a git repository (or any of the parent directories): .git
      01
      01 Rebuilding...
<snip>
00:15 deploy:migrating
      01 $HOME/.rbenv/bin/rbenv exec bundle exec rake db:migrate
      01 fatal: not a git repository (or any of the parent directories): .git
      01 fatal: not a git repository (or any of the parent directories): .git

That seems like a huge clue but I don't know where to look next (particularly since in the above case bundler:install was skipped).

Reading a very old SO question and an even older bundler issue on GitHub I suspect maybe this started happening when I switched from a published gem to pulling it from the main branch on GitHub (the published version doesn't yet support Rails 8).

Does anyone have any suggestions on how to test my suspicions? I suppose I could add a staging environment so I can play around with the Gemfile 🤔

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 87,400+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.