Gitea: Rejecting changes as Gitea environment not set. [after updating to v1.16.0] #8498

Closed
opened 2025-11-02 08:08:56 -06:00 by GiteaMirror · 7 comments
Owner

Originally created by @dehghani-mehdi on GitHub (Feb 4, 2022).

Gitea Version

1.16.0

Git Version

No response

Operating System

Windows 10

How are you running Gitea?

Using command-line

Database

No response

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Description

After updating to version 1.16.0, I got following error:

remote: Gitea: Rejecting changes as Gitea environment not set.
remote: If you are pushing over SSH you must push with a key managed by
remote: Gitea or set your environment appropriately.

Screenshots

No response

Originally created by @dehghani-mehdi on GitHub (Feb 4, 2022). ### Gitea Version 1.16.0 ### Git Version _No response_ ### Operating System Windows 10 ### How are you running Gitea? Using command-line ### Database _No response_ ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Description After updating to version 1.16.0, I got following error: > remote: Gitea: Rejecting changes as Gitea environment not set. >remote: If you are pushing over SSH you must push with a key managed by >remote: Gitea or set your environment appropriately. ### Screenshots _No response_
GiteaMirror added the type/questionissue/needs-feedbackissue/not-a-bug labels 2025-11-02 08:08:56 -06:00
Author
Owner

@zeripath commented on GitHub (Feb 4, 2022):

From what version did you upgrade?

Have you resynchronized your hooks?

How are you pushing to the gitea repo?

@zeripath commented on GitHub (Feb 4, 2022): From what version did you upgrade? Have you resynchronized your hooks? How are you pushing to the gitea repo?
Author
Owner

@dehghani-mehdi commented on GitHub (Feb 5, 2022):

From what version did you upgrade?

v1.15.6

Have you resynchronized your hooks?

I don't know what is that exactly, but I don't think so.

How are you pushing to the gitea repo?

I use file system, e.g: file://...

For now, I resolved the issue by deleting all hooks.

@dehghani-mehdi commented on GitHub (Feb 5, 2022): >From what version did you upgrade? v1.15.6 > Have you resynchronized your hooks? I don't know what is that exactly, but I don't think so. > How are you pushing to the gitea repo? I use file system, e.g: file://... For now, I resolved the issue by deleting all hooks.
Author
Owner

@zeripath commented on GitHub (Feb 5, 2022):

I use file system, e.g: file://...

Well there's your problem.

You are not allowed to push to Gitea's repos directly on the filesystem. You need to use http(s) or ssh to interact with Gitea's repos.

For now, I resolved the issue by deleting all hooks.

And now you're going to have multiple other problems - Gitea is not going to be told about updates to its repositories. Nor is it going to do any authentication/authorization.

Restore the hooks, use the http(s) or ssh endpoints. Repush an empty commit to get Gitea to update its knowledge of the repos.

If you persist in not having the hooks in place you're moving in to an unsupported configuration. At the very least you will need to restore them and work out how to set up the pushing environment so that Gitea can be told how to update things.

Realistically if you cannot work that out - you should not be doing it.

@zeripath commented on GitHub (Feb 5, 2022): > I use file system, e.g: file://... Well there's your problem. You are not allowed to push to Gitea's repos directly on the filesystem. You need to use http(s) or ssh to interact with Gitea's repos. > For now, I resolved the issue by deleting all hooks. And now you're going to have multiple other problems - Gitea is not going to be told about updates to its repositories. Nor is it going to do any authentication/authorization. Restore the hooks, use the http(s) or ssh endpoints. Repush an empty commit to get Gitea to update its knowledge of the repos. If you persist in not having the hooks in place you're moving in to an unsupported configuration. At the very least you will need to restore them and work out how to set up the pushing environment so that Gitea can be told how to update things. Realistically if you cannot work that out - you should not be doing it.
Author
Owner

@dehghani-mehdi commented on GitHub (Feb 5, 2022):

I'm afraid, we can not use http(s) or ssh.

I had not this problem with prev. version.

I have one question, in which situation Gitea will generate hooks again? I mean, I'm okay with deleting the hooks, I just want to tell Gitea not to generate hooks again, is that necessary? if so, how can I do that?

@dehghani-mehdi commented on GitHub (Feb 5, 2022): I'm afraid, we can not use http(s) or ssh. I had not this problem with prev. version. I have one question, in which situation Gitea will generate hooks again? I mean, I'm okay with deleting the hooks, I just want to tell Gitea not to generate hooks again, is that necessary? if so, how can I do that?
Author
Owner

@zeripath commented on GitHub (Feb 6, 2022):

You should have had this problem with 1.14+ but somehow you've avoided updating your hooks...

There will be multiple other issues that you may not be aware of because of doing this. Gitea cannot work without these hooks in place and pushing to its repositories without the correct configuration will cause things to break.


It does not make any sense that you cannot use http given you're willing to run Gitea itself.


However, I'll give you a hint as to what kind of environment you need to have set for Gitea to be able work over file pushing but you would need to tell each person who wants to push to that repository to set their environment correctly.

37ead26e36/models/helper_environment.go (L58-L72)

Now ... a lot of that could be set in another hook that would run before the gitea hook... (There are a lot of letters that come before g) However, some of it pertains to the specfic user that is pushing to gitea. So that will need to be done before that. Similarly you will need to do all of your own permissions checks.

If you cannot work out how to make this work from that hint you should not be doing this.

In either case this is unsupported.

You must push to Gitea's repos over http or ssh. Pushing directly to Gitea's repos is not permitted - they belong to Gitea and Gitea alone must manage them.

@zeripath commented on GitHub (Feb 6, 2022): You should have had this problem with 1.14+ but somehow you've avoided updating your hooks... There will be multiple other issues that you may not be aware of because of doing this. Gitea cannot work without these hooks in place and pushing to its repositories without the correct configuration will cause things to break. --- It does not make any sense that you cannot use http given you're willing to run Gitea itself. --- However, I'll give you a hint as to what kind of environment you need to have set for Gitea to be able work over file pushing but you would need to tell each person who wants to push to that repository to set their environment correctly. https://github.com/go-gitea/gitea/blob/37ead26e36073342edd1c36fa7cd3503297d2ce9/models/helper_environment.go#L58-L72 Now ... a lot of that could be set in another hook that would run before the gitea hook... (There are a lot of letters that come before g) However, some of it pertains to the specfic user that is pushing to gitea. So that will need to be done before that. Similarly you will need to do all of your own permissions checks. If you cannot work out how to make this work from that hint you should not be doing this. In either case this is unsupported. You must push to Gitea's repos over http or ssh. Pushing directly to Gitea's repos is not permitted - they belong to Gitea and Gitea alone must manage them.
Author
Owner

@zeripath commented on GitHub (Feb 8, 2022):

@dehghani-mehdi I forgot that I made an option for the push with environment set. You should restore the hooks and then set:

[security]
ONLY_ALLOW_PUSH_IF_GITEA_ENVIRONMENT_SET=false

but if you set this you're running into an unsupported configuration

@zeripath commented on GitHub (Feb 8, 2022): @dehghani-mehdi I forgot that I made an option for the push with environment set. You should restore the hooks and then set: ```ini [security] ONLY_ALLOW_PUSH_IF_GITEA_ENVIRONMENT_SET=false ``` but if you set this you're running into an unsupported configuration
Author
Owner

@zebulon-86 commented on GitHub (Mar 4, 2022):

@dehghani-mehdi I forgot that I made an option for the push with environment set. You should restore the hooks and then set:

[security]
ONLY_ALLOW_PUSH_IF_GITEA_ENVIRONMENT_SET=false

but if you set this you're running into an unsupported configuration

I have a problem similar to

remote: Gitea: Rejecting changes as Gitea environment not set.
remote: If you are pushing over SSH you must push with a key managed by
remote: Gitea or set your environment appropriately.

! [remote rejected] v4.1.16 -> v4.1.16 (pre-receive hook declined)

I successfully solved the problem with this method!Thank you for sharing!

@zebulon-86 commented on GitHub (Mar 4, 2022): > @dehghani-mehdi I forgot that I made an option for the push with environment set. You should restore the hooks and then set: > > ```ini > [security] > ONLY_ALLOW_PUSH_IF_GITEA_ENVIRONMENT_SET=false > ``` > > but if you set this you're running into an unsupported configuration I have a problem similar to ```ini remote: Gitea: Rejecting changes as Gitea environment not set. remote: If you are pushing over SSH you must push with a key managed by remote: Gitea or set your environment appropriately. ! [remote rejected] v4.1.16 -> v4.1.16 (pre-receive hook declined) ``` I successfully solved the problem with this method!Thank you for sharing!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#8498