gbtb / nix-stable-diffusion

Flake for running SD on NixOS
113 stars 21 forks source link

Some patches don't apply cleanly #8

Closed turion closed 1 year ago

turion commented 1 year ago
$ nix develop .#webui.amd
HEAD ist jetzt bei 737eb28 typo: cmd_opts.embedding_dir to cmd_opts.embeddings_dir
error: Anwendung des Patches fehlgeschlagen: launch.py:86
error: launch.py: Patch konnte nicht angewendet werden
error: Anwendung des Patches fehlgeschlagen: modules/paths.py:19
error: modules/paths.py: Patch konnte nicht angewendet werden

Translation: Patches couldn't be applied.

gbtb commented 1 year ago

Hello. I tried to reproduce this issue myself, on a clean clone of this repository. Basically, doing this two commands:

git clone https://github.com/gbtb/nix-stable-diffusion --recursive nixsdtest
nix develop .#webui.amd

And it works for me :) But, I have a hypothesis why this could happen to you - line endings. If you look in the webui.patch, you can see that it has some weird bits replacing just empty lines. This patch was auto-generated by git, and I didn't bother to fix it because it worked for me and I hate to deal with line-endings. So, I suggest you to hand-edit this file to keep only meaningful parts and see if it works. Or, you could just manually comment those lines in your local submodule and disable patch application in flake.nix

jb55 commented 1 year ago

I just did the same commands above and get:

$ git clone https://github.com/gbtb/nix-stable-diffusion --recursive nixsdtest
$ nix develop .#webui.amd
HEAD is now at 737eb28 typo: cmd_opts.embedding_dir to cmd_opts.embeddings_dir
error: patch failed: launch.py:86
error: launch.py: patch does not apply
error: patch failed: modules/paths.py:19
error: modules/paths.py: patch does not apply
jb55 commented 1 year ago

patching manually seems to have more info:

patching file launch.py
Hunk #1 FAILED at 86 (different line endings).
Hunk #2 FAILED at 103 (different line endings).
Hunk #3 FAILED at 143 (different line endings).
Hunk #4 FAILED at 176 (different line endings).
4 out of 4 hunks FAILED -- saving rejects to file launch.py.rej
patching file modules/paths.py
Hunk #1 FAILED at 19 (different line endings).
1 out of 1 hunk FAILED -- saving rejects to file modules/paths.py.rej
jb55 commented 1 year ago

I fixed the patch here:

https://jb55.com/s/8a3f5a2b86f337c8.txt

gbtb commented 1 year ago

I fixed the patch here:

https://jb55.com/s/8a3f5a2b86f337c8.txt

Cool! Git shows some whitespace trailing warnings, but applies it properly. Anyway, it's should be better because this patch works for me and for you, so I committed it to the repo.

Thank you.

turion commented 1 year ago

Weird, it still doesn't work for me:

$ nix develop .#webui.amd
HEAD ist jetzt bei 737eb28 typo: cmd_opts.embedding_dir to cmd_opts.embeddings_dir
/nix/store/25q7hs3jp7y076ndkkd83j20mn75xqgk-webui.patch:50: trailing whitespace.
    ('@taming_transformers@', 'taming', 'Taming Transformers', []),            
/nix/store/25q7hs3jp7y076ndkkd83j20mn75xqgk-webui.patch:51: trailing whitespace.
    ('@codeformer@', 'inference_codeformer.py', 'CodeFormer', []),             
/nix/store/25q7hs3jp7y076ndkkd83j20mn75xqgk-webui.patch:52: trailing whitespace.
    ('@blip@', 'models/blip.py', 'BLIP', []),                                  
/nix/store/25q7hs3jp7y076ndkkd83j20mn75xqgk-webui.patch:53: trailing whitespace.
    ('@k_diffusion@', 'k_diffusion/sampling.py', 'k_diffusion', ["atstart"]),  
Fehler: Anwendung des Patches fehlgeschlagen: launch.py:176
Fehler: launch.py: Patch konnte nicht angewendet werden
Fehler: Anwendung des Patches fehlgeschlagen: modules/paths.py:19
Fehler: modules/paths.py: Patch konnte nicht angewendet werden

It's a different place this time, though.

jb55 commented 1 year ago

I got those warnings but it applies for me

jb55 commented 1 year ago

oh yeah weird the patch in the latest branch doesn't apply for me, but the one I posted here does.

jb55 commented 1 year ago

@gbtb are you on windows? do you have some git config that converts line endings? doing:

curl https://jb55.com/s/8a3f5a2b86f337c8.txt | git am

should apply it cleanly (I think?)

gbtb commented 1 year ago

The thing is, I'm on NixOS :slightly_smiling_face: I haven't touched any git configs regarding whitespaces, crlf, etc. and this is the only repo I have with troubles like this. This is what git config --list returns from inside this repo:

init.defaultbranch=master
user.email=goodbetterthebeast3@gmail.com
user.name=gbtb
core.autocrlf=input
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
submodule.InvokeAI.url=https://github.com/invoke-ai/InvokeAI
submodule.InvokeAI.active=true
remote.origin.url=https://github.com/gbtb/nix-stable-diffusion.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
submodule.stable-diffusion-webui.active=true
submodule.stable-diffusion-webui.url=https://github.com/AUTOMATIC1111/stable-diffusion-webui

Identical to any other repo I have, including nixpkgs, to which I've commited multiple times :man_shrugging:

turion commented 1 year ago

I don't have an autocrlf setting, not sure whether that is relevant. How does your config look like when you enter the stable-diffusion-webui submodule though? I find this setting here:

core.whitespace=cr-at-eol

Maybe that is relevant? It might be that this setting, together with your setting, works, but it doesn't anymore when exchanging the patch with people who don't have an autocrlf setting? Just a wild guess.

gbtb commented 1 year ago

I cloned fresh copy of webui locally and it doesn't have core.whitespace=cr-at-eol setting, but it present in the my existing submodule. I think it's left from my previous patch attempt, which was superseded by jb55 patch. You can unset it or re-download submodule completely just in case.

gbtb commented 1 year ago

I've decided to give up on patching webui in-place for 2.0 version. Now I have my patched fork - https://github.com/gbtb/stable-diffusion-webui