Can't Push to New Space

I’m getting the following errors when trying to push to my new space for the first time.

remote: -------------------------------------------------------------------------
remote: You are not authorized to push to this repo.
remote: Make sure that you are properly logged in.
remote: -------------------------------------------------------------------------
To https://huggingface.co/spaces/Grokgpt/grokgpt
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://huggingface.co/spaces/Grokgpt/grokgpt'

I am logged in with a write token. I don’t have any large files, but I did activate lfs. I have huggingface_hub installed and huggingface-cli. I get the following output from cli whoami.

(hf-grokgpt) larry@Larrys-MacBook-Pro grokgpt % huggingface-cli whoami
Grokgpt
**orgs:** grokgpt-org

I am folllowing the instructions on the Spaces page. I cloned the repo, created a Dockerfile, and did the following:

git add Dockerfile 
git commit -m "Add application file" 
git push

I’ve tried starting over from scratch several times. Still get the same error.

I have an SSH key. I have a GPG key. I’ve got 3 write tokens. I’ve restarted and reset my space a dozen times. Cloned it a dozen times. Here is my .git/config.

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true
        precomposeunicode = true
[remote "origin"]
        url = https://huggingface.co/spaces/Grokgpt/grokgpt
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "main"]
        remote = origin
        merge = refs/heads/main

Shouldn’t be this difficult to push to a repo. I’ve spent way too many hours of my life on it. Maybe I have something misconfigured, but can’t figure out what. Ready to give up on Huggingface spaces.

hi @Grokgpt ,

sorry you’re having issues, one note it seems like you’re on OSX, once had similar issue and it was due to my keychain access misconfigured.

One hack way to solve it is to add your token and user to your .git/config inside your repo

[remote "origin"]
        url = https://USER:TOKEN@huggingface.co/spaces/Grokgpt/grokgpt
        fetch = +refs/heads/*:refs/remotes/origin/*
1 Like

Hi @Grokgpt, sorry for the inconvenience.

Can you do huggingface-cli login (press Enter to add to git credentials) and then huggingface-cli env and copy-paste the output of both commands please?

Thank you in advance

1 Like

(for context, pushing to Huggingface Hub using your SSH key is not yet possible but we are working on that feature)

1 Like

Thanks for getting back to me. I hadn’t gotten a response in awhile and I stopped checking for a day or two. I’ll give this a try!

Thanks, here’s the output:

(hf-grokgpt) larry@Larrys-MacBook-Pro grokgpt % huggingface-cli login

    _|    _|  _|    _|    _|_|_|    _|_|_|  _|_|_|  _|      _|    _|_|_|      _|_|_|_|    _|_|      _|_|_|  _|_|_|_|
    _|    _|  _|    _|  _|        _|          _|    _|_|    _|  _|            _|        _|    _|  _|        _|
    _|_|_|_|  _|    _|  _|  _|_|  _|  _|_|    _|    _|  _|  _|  _|  _|_|      _|_|_|    _|_|_|_|  _|        _|_|_|
    _|    _|  _|    _|  _|    _|  _|    _|    _|    _|    _|_|  _|    _|      _|        _|    _|  _|        _|
    _|    _|    _|_|      _|_|_|    _|_|_|  _|_|_|  _|      _|    _|_|_|      _|        _|    _|    _|_|_|  _|_|_|_|
    
    A token is already saved on your machine. Run `huggingface-cli whoami` to get more information or `huggingface-cli logout` if you want to log out.
    Setting a new token will erase the existing one.
    To login, `huggingface_hub` requires a token generated from https://huggingface.co/settings/tokens .
Token: 
Add token as git credential? (Y/n) y
Token is valid.
Your token has been saved in your configured git credential helpers (osxkeychain).
Your token has been saved to /Users/larry/.cache/huggingface/token
Login successful
(hf-grokgpt) larry@Larrys-MacBook-Pro grokgpt % huggingface-cli env

Copy-and-paste the text below in your GitHub issue.

- huggingface_hub version: 0.13.3
- Platform: macOS-10.16-x86_64-i386-64bit
- Python version: 3.11.2
- Running in iPython ?: No
- Running in notebook ?: No
- Running in Google Colab ?: No
- Token path ?: /Users/larry/.cache/huggingface/token
- Has saved token ?: True
- Who am I ?: Grokgpt
- Configured git credential helpers: osxkeychain
- FastAI: N/A
- Tensorflow: N/A
- Torch: N/A
- Jinja2: N/A
- Graphviz: N/A
- Pydot: N/A
- Pillow: N/A
- hf_transfer: N/A
- ENDPOINT: https://huggingface.co
- HUGGINGFACE_HUB_CACHE: /Users/larry/.cache/huggingface/hub
- HUGGINGFACE_ASSETS_CACHE: /Users/larry/.cache/huggingface/assets
- HF_TOKEN_PATH: /Users/larry/.cache/huggingface/token
- HF_HUB_OFFLINE: False
- HF_HUB_DISABLE_TELEMETRY: False
- HF_HUB_DISABLE_PROGRESS_BARS: None
- HF_HUB_DISABLE_SYMLINKS_WARNING: False
- HF_HUB_DISABLE_IMPLICIT_TOKEN: False
- HF_HUB_ENABLE_HF_TRANSFER: False

Whoa! That worked. Thanks!

1 Like

The hack worked. I didn’t try cleaning up the osxkeychain yet.

1 Like

FYI we now support SSH authentication,

example:

I’m having the same issues not being able to write to a new HF space.

I’ve created a new token with write access, logged in via huggingface-cli and still am unable to write.

Here is the output of huggingface-cli env, I would prefer not to add username:token to the .git/config file.

C02D3C6NMD6M:hello-world dchau$ huggingface-cli login

    _|    _|  _|    _|    _|_|_|    _|_|_|  _|_|_|  _|      _|    _|_|_|      _|_|_|_|    _|_|      _|_|_|  _|_|_|_|
    _|    _|  _|    _|  _|        _|          _|    _|_|    _|  _|            _|        _|    _|  _|        _|
    _|_|_|_|  _|    _|  _|  _|_|  _|  _|_|    _|    _|  _|  _|  _|  _|_|      _|_|_|    _|_|_|_|  _|        _|_|_|
    _|    _|  _|    _|  _|    _|  _|    _|    _|    _|    _|_|  _|    _|      _|        _|    _|  _|        _|
    _|    _|    _|_|      _|_|_|    _|_|_|  _|_|_|  _|      _|    _|_|_|      _|        _|    _|    _|_|_|  _|_|_|_|
    
    A token is already saved on your machine. Run `huggingface-cli whoami` to get more information or `huggingface-cli logout` if you want to log out.
    Setting a new token will erase the existing one.
    To login, `huggingface_hub` requires a token generated from https://huggingface.co/settings/tokens .
Token: 
Add token as git credential? (Y/n) Y
Token is valid.
Your token has been saved in your configured git credential helpers (osxkeychain).
Your token has been saved to /Users/dchau/.cache/huggingface/token
Login successful
C02D3C6NMD6M:hello-world dchau$ git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 12 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 452 bytes | 452.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
remote: -------------------------------------------------------------------------
remote: You are not authorized to push to this repo. 
remote: Make sure that you are properly logged in.
remote: -------------------------------------------------------------------------
To https://huggingface.co/spaces/ducchau/hello-world
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://huggingface.co/spaces/ducchau/hello-world'
C02D3C6NMD6M:hello-world dchau$ huggingface-cli env

Copy-and-paste the text below in your GitHub issue.

- huggingface_hub version: 0.14.1
- Platform: macOS-13.2.1-x86_64-i386-64bit
- Python version: 3.11.3
- Running in iPython ?: No
- Running in notebook ?: No
- Running in Google Colab ?: No
- Token path ?: /Users/dchau/.cache/huggingface/token
- Has saved token ?: True
- Who am I ?: ducchau
- Configured git credential helpers: osxkeychain
- FastAI: N/A
- Tensorflow: N/A
- Torch: N/A
- Jinja2: N/A
- Graphviz: N/A
- Pydot: N/A
- Pillow: N/A
- hf_transfer: N/A
- gradio: N/A
- ENDPOINT: https://huggingface.co
- HUGGINGFACE_HUB_CACHE: /Users/dchau/.cache/huggingface/hub
- HUGGINGFACE_ASSETS_CACHE: /Users/dchau/.cache/huggingface/assets
- HF_TOKEN_PATH: /Users/dchau/.cache/huggingface/token
- HF_HUB_OFFLINE: False
- HF_HUB_DISABLE_TELEMETRY: False
- HF_HUB_DISABLE_PROGRESS_BARS: None
- HF_HUB_DISABLE_SYMLINKS_WARNING: False
- HF_HUB_DISABLE_EXPERIMENTAL_WARNING: False
- HF_HUB_DISABLE_IMPLICIT_TOKEN: False
- HF_HUB_ENABLE_HF_TRANSFER: False

hi @ducchau , thanks for sharing you env. I see you’re on OSX, and as you noticed on this thread there a few folks facing similar issue with OSX.
Perhaps you could try the SSH authentication approach? Hugging Face – The AI community building the future. ? If you add your keys to your settings you can edit the file from your .git/config or reclone the repo git clone git@hf.co:spaces/ducchau/hello-world

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true
        precomposeunicode = true
[remote "origin"]
        url = https://huggingface.co/spaces/ducchau/hello-world
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "main"]
        remote = origin
        merge = refs/heads/main

to

[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
	ignorecase = true
	precomposeunicode = true
[remote "origin"]
	url = git@hf.co:spaces/ducchau/hello-world
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "main"]
	remote = origin
	merge = refs/heads/main