basecamp / kamal

Deploy web apps anywhere.
https://kamal-deploy.org
MIT License
9.39k stars 359 forks source link

Error running kamal setup in sub directory of git repo #799

Closed gingermusketeer closed 1 month ago

gingermusketeer commented 1 month ago

I have a git repo with front-end and back-end folders. I started out with kamal in the root of the repo but decided that I only wanted to use it for the back-end so moved the config files etc into there. As soon as I did that I ran into the following error:

 INFO [bc4a5275] Running /usr/bin/env mkdir -p .kamal/locks on IP_ADDRESS
  INFO [bc4a5275] Finished in 0.079 seconds with exit status 0 (successful).
Acquiring the deploy lock...
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
  Finished all in 3.8 seconds
  ERROR (RuntimeError): Exception while executing on host IP_ADDRESS: Can't use commit hash as version, no git repository found in /workdir

To reproduce:

  1. Move .kamal, .env and config/deploy.yml into a sub directory.
  2. Run kamal setup

Is this expected?

acidtib commented 1 month ago

its expected, kamal needs to be able to run git commands. you can see here the code that targets the error you are getting

https://github.com/basecamp/kamal/blob/12cad5458a4fdc14ffb182ae99673a0136852ab3/lib/kamal/configuration.rb#L337

gingermusketeer commented 1 month ago

In a subdirectory of a git repo the commands should work?

Understand if this is a limitation that isn’t worth solving for now but perhaps improving the error message is? I found fatal: not a git repository (or any parent up to mount point /) to be a bit misleading.

dhh commented 1 month ago

We have not designed Kamal to work for subdirectories like this. If you'd like to explore making that work, please do investigate, then open a PR if you tackle it.