Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-52857

Cannot find git-lfs when it is not installed in /usr/bin/

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • git-plugin
    • None
    • OSX

      We have an issue on our OSX nodes, where we cannot checkout a repo with git-lfs.

      We suppose that it is related to that `checkout scm` listens `/usr/bin/` and it is not possible to install anything there because of Apple's system integrity. Even passing a PATH=$PATH:/usr/local/bin doesn't take any effect. 

      Tested this with a ssh nods and `git checkout` works (as we have user credentials and all the simlinks), but as all of our nodes use JNLP we would like to have a possibility to define path to git-lfs like we can do for git.

      Stack trace:

      hudson.plugins.git.GitException: Command "/usr/local/bin/git checkout -f 304f1c283e1fa22e47ea9d7be1e2582a93021819" returned status code 128:
       stdout: 
       stderr: git-lfs filter-process: git-lfs: command not found
       fatal: The remote end hung up unexpectedly
      at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2002)
       at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$800(CliGitAPIImpl.java:72)
       at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$9.execute(CliGitAPIImpl.java:2301)
       Also: hudson.remoting.Channel$CallSiteStackTrace: Remote call to JNLP4-connect connection from 172.31.128.169/172.31.128.169:49241
       at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1741)
       at hudson.remoting.UserResponse.retrieve(UserRequest.java:389)
       at hudson.remoting.Channel.call(Channel.java:955)
       at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.execute(RemoteGitImpl.java:146)
       at sun.reflect.GeneratedMethodAccessor638.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:498)
       at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.invoke(RemoteGitImpl.java:132)
       at com.sun.proxy.$Proxy117.execute(Unknown Source)
       at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1236)
       at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:113)
       at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:85)
       at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:75)
       at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
       at hudson.security.ACL.impersonate(ACL.java:290)
       at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
       at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
       at java.lang.Thread.run(Thread.java:748)
       Caused: hudson.plugins.git.GitException: Could not checkout 304f1c283e1fa22e47ea9d7be1e2582a93021819
       at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$9.execute(CliGitAPIImpl.java:2325)
       at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:153)
       at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:146)
       at hudson.remoting.UserRequest.perform(UserRequest.java:210)
       at hudson.remoting.UserRequest.perform(UserRequest.java:53)
       at hudson.remoting.Request$2.run(Request.java:358)
       at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
       at java.util.concurrent.FutureTask.run(FutureTask.java:264)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
       at hudson.remoting.Engine$1$1.run(Engine.java:94)
       at java.lang.Thread.run(Thread.java:844)
       Finished: FAILURE
      

       

          [JENKINS-52857] Cannot find git-lfs when it is not installed in /usr/bin/

          Lars Bilke added a comment - - edited

          Thanks Jeff, this works for me too! I had set up this symlink (I use Homebrew):

          ln -s /usr/local/bin/git-lfs /usr/local/Cellar/git/2.21.0/libexec/git-core/git-lf

          And for Macports:

          sudo ln -s `which git-lfs` /opt/local/libexec/git-core/git-lfs
          

          Lars Bilke added a comment - - edited Thanks Jeff, this works for me too! I had set up this symlink (I use Homebrew): ln -s /usr/local/bin/git-lfs /usr/local/Cellar/git/2.21.0/libexec/git-core/git-lf And for Macports: sudo ln -s `which git-lfs` /opt/local/libexec/git-core/git-lfs

          Devin Lane added a comment - - edited

          I just worked through this issue today and have found a reasonable solution. First, the problem lies in the way that Jenkins makes a connection to the slave; apparently, the "checkout" command uses an environment obtained from a non-interactive login, and BEFORE environment from Jenkins node config takes place. The rest of the build uses a "normal" environment so you may find that git lfs commands work there.

          One method of fixing this is to alter /etc/ssh/sshd_config (for macOS), set "PermitUserEnvironment" to YES, then restart sshd. Next, edit /Users/Jenkins/.ssh/environment and set PATH="$PATH:/usr/local/bin" etc as required. Finally, have Jenkins reconnect to the slave to pick up the new environment.

          More details at https://support.cloudbees.com/hc/en-us/articles/229724088-How-to-set-up-a-Jenkins-agent-to-have-the-same-path-as-the-user-when-connected-via-Remote-Desktop-

          Devin Lane added a comment - - edited I just worked through this issue today and have found a reasonable solution. First, the problem lies in the way that Jenkins makes a connection to the slave; apparently, the "checkout" command uses an environment obtained from a  non-interactive login, and BEFORE environment from Jenkins node config takes place. The rest of the build uses a "normal" environment so you may find that git lfs commands work there. One method of fixing this is to alter /etc/ssh/sshd_config (for macOS), set "PermitUserEnvironment" to YES, then restart sshd. Next, edit /Users/Jenkins/.ssh/environment and set PATH="$PATH:/usr/local/bin" etc as required. Finally, have Jenkins reconnect to the slave to pick up the new environment. More details at  https://support.cloudbees.com/hc/en-us/articles/229724088-How-to-set-up-a-Jenkins-agent-to-have-the-same-path-as-the-user-when-connected-via-Remote-Desktop-

          Rory Dungan added a comment -

          Had the same problem on Mac. Setting environment variables in the node properties didn't seem to help since it looks like they are applied to "Execute shell" job stages but not the checkout stage.

          Another workaround I found is to create a shell script that sets the PATH variable and then runs Git:

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

          Then in the Jenkins node properties screen, set the Git executable to that script:

          Feels like a bit of a hack but hopefully someone else finds it useful

          Rory Dungan added a comment - Had the same problem on Mac. Setting environment variables in the node properties didn't seem to help since it looks like they are applied to "Execute shell" job stages but not the checkout stage. Another workaround I found is to create a shell script that sets the PATH variable and then runs Git: #!/bin/sh export PATH=/usr/local/bin:$PATH git "$@" Then in the Jenkins node properties screen, set the Git executable to that script: Feels like a bit of a hack but hopefully someone else finds it useful

          Mark Waite added a comment - - edited

          The same condition exists for OpenBSD environment variables.

          The sshd_config on OpenBSD (and macOS) does not allow Jenkins to set environment variables unless the PermitUserEnvironment is set to YES as recommended by devinlane

          I encountered the problem because I could not find my PATH adjustments to locate Maven and Ant in the non-default locations where I store them.

          Mark Waite added a comment - - edited The same condition exists for OpenBSD environment variables. The sshd_config on OpenBSD (and macOS) does not allow Jenkins to set environment variables unless the PermitUserEnvironment is set to YES as recommended by devinlane I encountered the problem because I could not find my PATH adjustments to locate Maven and Ant in the non-default locations where I store them.

          Xin Meng added a comment -

          still have the issue. i try lots of methods, even copying the git lfs to the same path with git, but still fail to execute. no idea how to resolve it now. 

          I think this problem is very important for mac user.

          Xin Meng added a comment - still have the issue. i try lots of methods, even copying the git lfs to the same path with git, but still fail to execute. no idea how to resolve it now.  I think this problem is very important for mac user.

          Mark Waite added a comment -

          mengxin did you try the workaround proposed by Devin Lane?  It worked for me on my OpenBSD machine.

          Mark Waite added a comment - mengxin did you try the workaround proposed by Devin Lane?  It worked for me on my OpenBSD machine.

          Xin Meng added a comment -

          markewaite  Thanks for your reply, but in my case, I do not have a slave instance. all Jenkins running on my single mac computer. 

          I tried this before: https://smashswift.com/jenkins-does-not-recognize-git-lfs-on-mac/

          it works on my previous computer, but on the new one does not work. 

           

          Xin Meng added a comment - markewaite   Thanks for your reply, but in my case, I do not have a slave instance. all Jenkins running on my single mac computer.  I tried this before: https://smashswift.com/jenkins-does-not-recognize-git-lfs-on-mac/ it works on my previous computer, but on the new one does not work.   

          Xin Meng added a comment -

          currently i am testing another workwround:

           

          cp /usr/local/bin/git-lfs /usr/local/Cellar/git/2.36.1/libexec/git-core/

           

          seem like work, but waiting for final checkout result

          Xin Meng added a comment - currently i am testing another workwround:   cp /usr/local/bin/git-lfs /usr/local/Cellar/git/2.36.1/libexec/git-core/   seem like work, but waiting for final checkout result

          Xin Meng added a comment -

          finally

           

          https://smashswift.com/jenkins-does-not-recognize-git-lfs-on-mac/

          cp /usr/local/bin/git-lfs /usr/local/Cellar/git/2.36.1/libexec/git-core/

           

          works

          Xin Meng added a comment - finally   https://smashswift.com/jenkins-does-not-recognize-git-lfs-on-mac/ +  cp /usr/local/bin/git-lfs /usr/local/Cellar/git/2.36.1/libexec/git-core/   works

          S added a comment -

          sudo ln -s `which git-lfs` `git --exec-path`/git-lfs

          S added a comment - sudo ln -s `which git-lfs` `git --exec-path`/git-lfs

            Unassigned Unassigned
            joesss Serghei Moret
            Votes:
            5 Vote for this issue
            Watchers:
            14 Start watching this issue

              Created:
              Updated: