charmbracelet / soft-serve

The mighty, self-hostable Git server for the command line🍦
MIT License
5.18k stars 132 forks source link

Failing to create new repo #147

Closed flaxplax closed 1 year ago

flaxplax commented 2 years ago

I followed the instructions on how to create a repo. After push I get the following error message

error: failed to push some refs to 'ssh://git:23231/test'

After push I can find the repo in the .repos

But if I ssh into the TUI I cannot see it. If I later try to reload I get the error Error: reference does not exist

I tried this on a ubuntu 20.04 host installed with apt.

aymanbagabas commented 2 years ago

Could you please provide steps to reproduce? These steps work fine for me:

# start a fresh Soft Serve
cd /tmp && mkdir soft-serve && cd /soft-serve
soft serve

# in a different terminal, create a new repository
cd /tmp
mkdir test
cd test
git init
git remote add soft ssh://localhost:23231/test

# create file and push repository
touch file
git add file
git commit -m'new file'
git push soft master

# ssh into server
ssh localhost -p23231
flaxplax commented 2 years ago

My steps are with copy from yours

# Remote host running Soft Serve
cd /tmp && mkdir soft-serve && cd /soft-serve
soft serve

# Client machine, create repo
cd /tmp
mkdir test
cd test
git init
git remote add soft ssh://git:23231/test

# Create file and push to remote
touch file
git add file
git commit -m "add file"
git push soft main # error appears here

# ssh
ssh git -p 23231 # repo does not show here
everdrone commented 2 years ago

I can confirm @flaxplax's error, it's happening to me as well

error: failed to push some refs

Followed these steps, The repo is not created and does not appear in the TUI

aymanbagabas commented 1 year ago

I'm still not able to reproduce your issue. Running the above example using the latest version, v0.4.0 works as expected. What Soft Serve version are you running?

everdrone commented 1 year ago

@aymanbagabas I'm running 0.4.0, the latest version since this started happening. If it could help I'm running soft as a systemd service on a Jetson Nano (ARM)

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.6 LTS
Release:        18.04
Codename:       bionic

$ uname -a
Linux user 4.9.201-tegra #1 SMP PREEMPT Fri Jul 9 08:56:29 PDT 2021 aarch64 aarch64 aarch64 GNU/Linux

The repo is being created on a windows 10 machine on the same local network

I'll try pushing a new repo from a different (macOS) machine today if that can help you reproduce

@flaxplax did you manage to solve? do you have any info on your case?

alxndr13 commented 1 year ago

i also got that issue.

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.5 LTS
Release:    20.04
Codename:   focal

Installed using apt. Running soft version v0.4.4 (7a7e73d)

The repo does get created in the .repo folder, somehow soft does not recognize it. when restarting soft, it gets stuck in the starting process. Deleting helps, but the repo is gone obviously.

soft serve
2022/11/25 10:46:43 error opening repository ".repos/XXX": reference does not exist
2022/11/25 10:46:43 reference does not exist
alxndr13@test:~$ rm -rf .repos/XXX/
alxndr13@test:~$ soft serve
2022/11/25 10:46:50 Starting SSH server on :23231

edit; to rule out the possibility of some filesystem permission shenanigans, i also tried it as root. did not work.

stijnme commented 1 year ago

I have the same issue (running Ubuntu in WSL2), after cloning the local git repo into Soft Serve the same message occur (when pushing for example).

When restarting the server:

2023/01/17 16:12:01 error opening repository "/mnt/c/<more path>/Charm.sh_repos/notes": reference does not exist
2023/01/17 16:12:01 reference does not exist

fyi: I use the env variable SOFT_SERVE_REPO_PATH to sync my repo into the cloud (=backup).

So I manually tried to clone (since it is a local path) the notes repo:

git clone /mnt/c/<more path>/Charm.sh_repos/notes
Cloning into 'notes'...
done.
warning: remote HEAD refers to nonexistent ref, unable to checkout.

So also the git command itself gives errors!

When trying to clone a repo that already exists (created with earlier version):

git clone /mnt/c/<more path>/Charm.sh_repos/demo-treetable/
Cloning into 'demo-treetable'...
done.

Trying with a manual bare clone:

git clone --bare Notes /mnt/c/<more path>/Charm.sh_repos/notes
Cloning into bare repository '/mnt/c/<more path>/Charm.sh_repos/notes'...
done.

Worked, no errors.

Started soft serve, navigated to the notes repo, following error is shown: Bummer no reference. (cached?) Went back to the start screen, opened the repo again: everything works as expected. Creating a bare clone (on the same machine), could be a workaround.

Imho: the issue occurs when pushing the repo for the first time into soft serve.

ItsMeBrianD commented 1 year ago

I encountered this issue today, I was running into it because I was trying to push to a branch before I was pushing to master, which caused some issues.

i.e. I had some repo with

prod
softserve
origin/prod
soft/softserve

This caused issues; I had to set the remote origin of my local branch softserve to soft/master, and then it worked properly.

It seems this is being caused when using a default branch name other than master

alinanorakari commented 1 year ago

I see that master is hardcoded in https://github.com/charmbracelet/soft-serve/blob/main/config/git.go#L229

i've long switched to main as the primary branch since master is an outdated and unspecific term. Even GitHub started rolling this out as a change over a year ago: https://github.com/github/renaming

I would suggest changing this hardcoded string (and any other hardcoded occurrences) to be configurable, and also letting us move to the main naming in the config repository.

bashbunni commented 1 year ago

hi @alinanorakari this is a WIP, there is an open PR to resolve this, but it still isn't ready to merge yet. You can keep track of it here