obsidian-git icon indicating copy to clipboard operation
obsidian-git copied to clipboard

Large File Storage

Open zharinov opened this issue 4 years ago • 24 comments

@denolehov, thank you for this plugin!

I tried to use git-lfs feature for my images sub-folder and here is error in my console:

This repository is configured for Git LFS but 'git-lfs' was not found on your path.
If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/pre-push.

Basically, hook content looks like this:

#!/bin/sh
command -v git-lfs && git lfs pre-push "$@"

I wonder if this can be fixed just by passing parent PATH via this option.

More context: Obsidian: 0.9.14 OS: macOS Big Sur

To reproduce, I guess it would be enough to follow this setup. Also, maybe I'll be able to figure out obsidian plugin development setup and debug it on my own.

UPD. As I can see, obsidian process doesn't contain /usr/local/bin directory in its PATH, i.e. it uses system-wide git command instead of homebrew-installed one.

zharinov avatar Nov 14 '20 21:11 zharinov

Hey, I will look into this closer to next weekend. Sorry for the late reply.

denolehov avatar Nov 22 '20 22:11 denolehov

Similar issue to #21, but in the case of git-lfs, I don't think there is a git-config option to set the path to git-lfs. So perhaps the best would be to introduce two new plugin settings: "Path to git" and "Path to git-lfs", that can be used to override the system defaults? Never mind, you can tell simpleGit to use a specific git binary, but it will still use the git-lfs binary on PATH, so I'm not really sure what would be a good way to make this configurable. Modifying the PATH variable would of course work, but it seems a bit outside the scope of this plugin to do.

danmichaelo avatar Nov 29 '20 19:11 danmichaelo

I've encountered the same issue.

My solution was to manually update the .git/hooks installed by git-lfs (post-commit, post-checkout, post-merge, and pre-push) and add the following line at the top of each one:

PATH="$PATH:/usr/local/bin"

(This assumes that the git-lfs binary resides in /usr/local/bin, which is the case if you installed it through brew by example.)

This will update the PATH variable for the scope of the script and not impact your "usual" PATH, and as such can be considered safe.

sascha-wolf avatar Apr 20 '21 20:04 sascha-wolf

Tried the above recommendation but still got errors.

Cannot add files: git-lfs
filter-process: git-lfs: command not found
fatal: the remote end hung up unexpectedly

I checked git-lfs location with which and it was usr/local/bin, added that path line in the top of each hook.. though was I supposed to update them some other way first, or is that what sascha-wolf meant by manually updating? Any other ideas what could be causing it to fail?

frankreporting avatar Jun 12 '21 22:06 frankreporting

This is still an issue as of 2021-09-01

cor avatar Sep 01 '21 11:09 cor

I had the same issue as @frankreporting when I installed git-lfs using homebrew (location was /opt/homebrew/bin).

To resolve it, I installed the package at https://git-lfs.github.com/ and ran install.sh, which installed git-lfs to /usr/local/bin (you may also be able to just move the binary).

After that, I was able to add PATH=$PATH:/usr/local/bin to the git hooks and after restarting Obsidian everything worked.

mracette avatar Dec 09 '21 01:12 mracette

I've encountered the same issue.

My solution was to manually update the .git/hooks installed by git-lfs (post-commit, post-checkout, post-merge, and pre-push) and add the following line at the top of each one:

PATH="$PATH:/usr/local/bin"

(This assumes that the git-lfs binary resides in /usr/local/bin, which is the case if you installed it through brew by example.)

This will update the PATH variable for the scope of the script and not impact your "usual" PATH, and as such can be considered safe.

@sascha-wolf Why should I do that? My git-lfs binary is already in the path.

bevsxyz avatar Dec 14 '21 21:12 bevsxyz

@sascha-wolf Why should I do that? My git-lfs binary is already in the path.

If it works for you, you don't. It didn't for me, git-lfs wasn't in the PATH of the script execution.

sascha-wolf avatar Jan 18 '22 11:01 sascha-wolf

Like @frankreporting and @mracette, I was having the same issue where it still wasn't working even after I added PATH="$PATH:/usr/local/bin" to the top of each git hook.

I didn't want to download and install git-lfs manually since I wanted to maintain the management by Homebrew. I was specifically getting an error message about filter-process, and I realized that was part of the filters Git LFS defines in the .gitconfig.

I updated my global .gitconfig to refer to /usr/bin/local/git-lfs instead of just git-lfs on all of the filter lines. That combined with adding PATH="$PATH:/usr/local/bin" to the top of each git hook fixed it for me!

That section of my global .gitconfig now looks like:

[filter "lfs"]
	process = /usr/local/bin/git-lfs filter-process
	required = true
	clean = /usr/local/bin/git-lfs clean -- %f
	smudge = /usr/local/bin/git-lfs smudge -- %f

christyray avatar Jan 20 '22 21:01 christyray

Thanks @christyray, your tip solved it for me!

You can put that section also inside the .git/config file of the Obsidian repo itself, if you don't want to change your global .gitconfig file.

finn-matti avatar Feb 27 '22 12:02 finn-matti

If you don't want to modify gitconfig or git hooks you can create git.sh file in the root dir of your vault or anywhere else you want then specify it as a git command in "Obsidian Git" settings.

#!/bin/bash

# Implementation of git command with Homebrew binaries added to the PATH.
# Needed to make Obsidian Git plugin work with git-lfs. To use this file specify 
# the global global path to this file in "Custom Git binary path" setting of "Obsidian Git".

export PATH=$PATH:/usr/local/bin
/usr/local/bin/git "$@"

Works well for me!

AlekseiCherkes avatar Jul 28 '22 09:07 AlekseiCherkes

Like @frankreporting and @mracette, I was having the same issue where it still wasn't working even after I added PATH="$PATH:/usr/local/bin" to the top of each git hook.

I didn't want to download and install git-lfs manually since I wanted to maintain the management by Homebrew. I was specifically getting an error message about filter-process, and I realized that was part of the filters Git LFS defines in the .gitconfig.

I updated my global .gitconfig to refer to /usr/bin/local/git-lfs instead of just git-lfs on all of the filter lines. That combined with adding PATH="$PATH:/usr/local/bin" to the top of each git hook fixed it for me!

That section of my global .gitconfig now looks like:

[filter "lfs"]
	process = /usr/local/bin/git-lfs filter-process
	required = true
	clean = /usr/local/bin/git-lfs clean -- %f
	smudge = /usr/local/bin/git-lfs smudge -- %f

works for me

dwSun avatar Sep 23 '22 02:09 dwSun

I've added a setting to add paths to the PATH env var. Can one of you try the new setting?

Vinzent03 avatar Nov 02 '22 09:11 Vinzent03

I've added a setting to add paths to the PATH env var. Can one of you try the new setting?

@Vinzent03 - The new setting doesn't appear to be updating my path, at least based on the output of process.env.PATH in the console. But, Obsidian now (and possibly for a while - I haven't checked this recently) seems to be using the PATH variable I have set in .zshrc, and that fixed the issues I was having with Git LFS being located.

christyray avatar Nov 02 '22 14:11 christyray

Same problem, add lfs config to .gitconfig and create git.sh file cannot work

TYZRPVX avatar Nov 03 '22 15:11 TYZRPVX

@Vinzent03 Seems to work for me. Little notch: the path should be specified with the trailing /. Obsidian Git treats it as a path to file (not directory) otherwise.

AlekseiCherkes avatar Nov 03 '22 16:11 AlekseiCherkes

@AlekseiCherkes You mean the settings description should be improved?

Vinzent03 avatar Nov 03 '22 16:11 Vinzent03

I've added a setting to add paths to the PATH env var. Can one of you try the new setting?

work for me.

Obsidian Git - Advanced - Additional PATH environment variable paths - append /usr/local/bin

TYZRPVX avatar Nov 04 '22 03:11 TYZRPVX

@AlekseiCherkes You mean the settings description should be improved?

@Vinzent03 I don't know what's happend exactly, but everything is OK on my side now. I wasn't able to reproduce the issue.

AlekseiCherkes avatar Nov 06 '22 15:11 AlekseiCherkes

I've added a setting to add paths to the PATH env var. Can one of you try the new setting?

In my case, I had to add /opt/homebrew/bin/ and it worked.

fxsalazar avatar Dec 26 '22 23:12 fxsalazar

News:

Add /opt/homebrew/bin or your git-lfs path in obsidian-git setting Additional PATH environment variable paths can solve this.

obsidian-git don't use my zsh $PATH.

icefed avatar Nov 13 '23 02:11 icefed

I've added a setting to add paths to the PATH env var. Can one of you try the new setting?

In my case, I had to add /opt/homebrew/bin/ and it worked.

This also worked for me. Thank you!

frankreporting avatar Feb 25 '24 05:02 frankreporting

Adding

/opt/homebrew/bin

in

Obsidian Git > Advanced > Additional PATH environment variable paths

worked for me 👌

Adding /opt/homebrew/bin in Obsidian Git > Advanced > Additional PATH environment variable paths

Git LFS commit and push now work on Obsidian with git-lfs installed with Homebrew

JV-conseil avatar Mar 04 '24 14:03 JV-conseil

Adding

/opt/homebrew/bin

in

Obsidian Git > Advanced > Additional PATH environment variable paths

worked for me 👌

Adding /opt/homebrew/bin in Obsidian Git > Advanced > Additional PATH environment variable paths

Git LFS commit and push now work on Obsidian with git-lfs installed with Homebrew

This also worked for me

rlkennedyreid avatar Mar 25 '24 11:03 rlkennedyreid