sublime_merge icon indicating copy to clipboard operation
sublime_merge copied to clipboard

LFS not working on Apple Silicon with Monterey

Open mihakrajnc opened this issue 2 years ago • 6 comments

Version info

  • OS: macOS 12.3
  • Build: 2068

Description

Trying to do any operation (commit / switch branch) in a project using git-lfs does not work, and always fails with: 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/post-checkout'.

Working with the repository from the command line works as expected. I have Git Binary set to "system".

It could to be related to this issue: #147

Steps to reproduce

Steps to reproduce the behavior:

  1. Use an M1 Mac (in my case an M1 Pro MacBook)
  2. Install git-lfs with Homebrew and make sure it's set up.
  3. Clone a project that uses LFS using the terminal
  4. Open the project is Sublime Merge and try to make a commit / switch a branch.

Expected behavior

Operations should be performed normally without errors.

mihakrajnc avatar Mar 17 '22 12:03 mihakrajnc

Small note, if I start Sublime Merge from terminal with open -n ./Sublime\ Merge.app the lfs issue is gone. I'm not completely sure what that means though.

mihakrajnc avatar Mar 17 '22 22:03 mihakrajnc

Hi @mihakrajnc,

Thanks for reporting this issue and apologies for the delay - I will investigate this further.

Could you please share the following when you have a spare moment:

  • The output of which git-lfs from the terminal
  • The Sublime Merge Debug Information for the repository mentioned
    • This can be accessed in Sublime Merge via the application menu under (Help > Debug Information)
    • Before sharing this, please take a moment to redact any information that's confidential (file paths, Git user credentials, remotes etc)

Kind regards, - Dylan Johnston

dpjohnst avatar Jun 14 '22 06:06 dpjohnst

Sorry for resurrecting this thread, but I'm facing the same issue.

  • which git-lfs

    opt/homebrew/bin/git-lfs
    
  • launchctl getenv PATH

    opt/homebrew/bin:/opt/homebrew/sbin:/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.:/usr/bin:/bin:/usr/sbin:/sbin
    
  • echo $PATH

    opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/usr/bin
    
  • Debug Information (when launched with smerge)

    === App Version Information ===
    Build: 2077
    
    === Git Version Information ===
    Using Git: git (system)
    git version 2.37.0 (Apple Git-136)
    PATH: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin (from shell)
    environment variables loaded using: /opt/homebrew/bin/zsh -l
    
    === Git Config Information ===
    branch.main.merge=refs/heads/main
    branch.main.remote=origin
    core.bare=false
    core.filemode=true
    core.ignorecase=true
    core.logallrefupdates=true
    core.precomposeunicode=true
    core.repositoryformatversion=0
    credential.helper=osxkeychain
    filter.lfs.clean=git-lfs clean -- %f
    filter.lfs.process=git-lfs filter-process
    filter.lfs.required=true
    filter.lfs.smudge=git-lfs smudge -- %f
    init.defaultbranch=main
    lfs.repositoryformatversion=0
    remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
    [email protected]
    user.name=Philip Trauner
    
    === Our Config Information ===
    Git Config Path Information
    Using config path: /etc/gitconfig
    Using config path: /Users/philip/.config/git/config
    Using config path: /Users/philip/.gitconfig
    
    Our config output is different to the Git config output
    branch.main.merge=refs/heads/main
    branch.main.remote=origin
    core.bare=false
    core.filemode=true
    core.ignorecase=true
    core.logallrefupdates=true
    core.precomposeunicode=true
    core.repositoryformatversion=0
    filter.lfs.clean=git-lfs clean -- %f
    filter.lfs.process=git-lfs filter-process
    filter.lfs.required=true
    filter.lfs.smudge=git-lfs smudge -- %f
    lfs.repositoryformatversion=0
    remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
    [email protected]
    user.name=Philip Trauner
    

PhilipTrauner avatar Aug 26 '22 12:08 PhilipTrauner

@PhilipTrauner, it does not look like the PATH is setup correctly for non-interactive login shells with zsh:

  === Git Version Information ===
  PATH: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin (from shell)
  environment variables loaded using: /opt/homebrew/bin/zsh -l

srbs avatar Aug 27 '22 07:08 srbs

I have stumbled upon the very same error reported in #147 on a Mac OS Ventura.

The cause was a conflict between the version of Git included in Xcode Command Line Tools and the Git LFS version installed via HomeBrew.

Basically, the Git binary executable (git) expects the binary executable of the Git LFS extension to be located inside the directory of its execution path.

Even though the Git binary executable installed by Xcode Command Line Tools is physically located in /usr/bin/git

~ which git
/usr/bin/git

its execution path is another directory

~ git --exec-path
/Applications/Xcode.app/Contents/Developer/usr/libexec/git-core

Therefore git is not able to find git-lfs binary inside /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core, as the latter is located in /opt/opt/homebrew/bin/git-lfs

~ which git-lfs
/opt/homebrew/bin/git-lfs

One workaround could have been the following:

sudo ln -s "$(which git-lfs)" "$(git --exec-path)/git-lfs"

Unfortunately, in recent versions of Mac OS that command does not work:

~ sudo ln -s "$(which git-lfs)" "$(git --exec-path)/git-lfs"
ln: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git-lfs: Operation not permitted

That error is due to the System Integrity Protection, aka "SIP", a feature enabled in recent versions of Mac OS. It basically makes parts of the file system read-only to everybody, including root: even prepending sudo, as shown above, is ineffective.

Said that, the only solution that worked for me was installing also Git via brew

~ brew install git

ensuring that the HomeBrew binaries have precedence over system ones:

~ echo $PATH
opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/Library/Apple/usr/bin

wandering-tales avatar Jul 05 '23 09:07 wandering-tales

Same problem here. Git lfs installed and configured for the entire repo, yet can't commit large files when switching to mac. Works fine on my Win PC.

ioannis-koukourakis avatar Apr 05 '24 01:04 ioannis-koukourakis