# ERROR: Error fetching remote repo 'origin' Failed to setup credentials

**URL:** <https://community.jenkins.io/t/error-error-fetching-remote-repo-origin-failed-to-setup-credentials/19165>\
**Category:** Ask a question\
**Created:** [September 5, 2024, 8:00pm UTC](https://community.jenkins.io/t/error-error-fetching-remote-repo-origin-failed-to-setup-credentials/19165 "2024-09-05T20:00:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheoWan1](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/theowan1/32/10015_2.png) [@TheoWan1](https://community.jenkins.io/u/TheoWan1)\
**Post date:** [September 5, 2024, 8:00pm UTC](https://community.jenkins.io/t/error-error-fetching-remote-repo-origin-failed-to-setup-credentials/19165/1 "2024-09-05T20:00:24Z")

</div>

I am using auth token from github to access my github repo, i am able to do it locally in my linux machine using the same auth token. So the token is not the issue here. However, jenkins just Failed to setup credentials, and I am unable to figure out why. Anything will help.

Thanks

> **Summary**
>
> **14:31:51** \> git --version # timeout=10 **14:31:51** \> git --version # ‘git version 2.25.1’ **14:31:51** using GIT\_ASKPASS to set credentials TheoPatToken **14:31:51** ERROR: Error fetching remote repo ‘origin’ **14:31:51** hudson.plugins.git.GitException: Failed to fetch from [repo · GitHub](https://github.com/repo) **14:31:51** at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:999) **14:31:51** at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1241) **14:31:51** at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1305) **14:31:51** at hudson.scm.SCM.checkout(SCM.java:540) **14:31:51** at hudson.model.AbstractProject.checkout(AbstractProject.java:1248) **14:31:51** at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:649) **14:31:51** at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:85) **14:31:51** at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:521) **14:31:51** at hudson.model.Run.execute(Run.java:1895) **14:31:51** at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44) **14:31:51** at hudson.model.ResourceController.execute(ResourceController.java:101) **14:31:51** at hudson.model.Executor.run(Executor.java:442) **14:31:51** Caused by: hudson.plugins.git.GitException: Failed to setup credentials **14:31:51** at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2187) **14:31:51** at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:635) **14:31:51** at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:170) **14:31:51** at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:161) **14:31:51** at hudson.remoting.UserRequest.perform(UserRequest.java:211) **14:31:51** at hudson.remoting.UserRequest.perform(UserRequest.java:54) **14:31:51** at hudson.remoting.Request$2.run(Request.java:377) **14:31:51** at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:78) **14:31:51** at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) **14:31:51** at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) **14:31:51** at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) **14:31:51** at java.base/java.lang.Thread.run(Thread.java:840) **14:31:51** Suppressed: hudson.remoting.Channel$CallSiteStackTrace: Remote call to Theo\_node **14:31:51** at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1787) **14:31:51** at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356) **14:31:51** at hudson.remoting.Channel.call(Channel.java:1003) **14:31:51** at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.execute(RemoteGitImpl.java:153) **14:31:51** at jdk.internal.reflect.GeneratedMethodAccessor875.invoke(Unknown Source) **14:31:51** at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) **14:31:51** at java.base/java.lang.reflect.Method.invoke(Method.java:568) **14:31:51** at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.invoke(RemoteGitImpl.java:138) **14:31:51** at jdk.proxy114/jdk.proxy114.$Proxy204.execute(Unknown Source) **14:31:51** at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:997) **14:31:51** at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1241) **14:31:51** at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1305) **14:31:51** at hudson.scm.SCM.checkout(SCM.java:540) **14:31:51** at hudson.model.AbstractProject.checkout(AbstractProject.java:1248) **14:31:51** at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:649) **14:31:51** at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:85) **14:31:51** at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:521) **14:31:51** at hudson.model.Run.execute(Run.java:1895) **14:31:51** at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44) **14:31:51** at hudson.model.ResourceController.execute(ResourceController.java:101) **14:31:51** at hudson.model.Executor.run(Executor.java:442) **14:31:51** Caused by: java.io.IOException: Cannot run program “cp”: error=2, No such file or directory **14:31:51** at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1143) **14:31:51** at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073) **14:31:51** at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.createNonBusyExecutable(CliGitAPIImpl.java:2743) **14:31:51** at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.createUnixStandardAskpass(CliGitAPIImpl.java:2520) **14:31:51** at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2145) **14:31:51** … 11 more **14:31:51** Caused by: java.io.IOException: error=2, No such file or directory **14:31:51** at java.base/java.lang.ProcessImpl.forkAndExec(Native Method) **14:31:51** at java.base/java.lang.ProcessImpl.(ProcessImpl.java:314) **14:31:51** at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:244) **14:31:51** at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1110) **14:31:51** … 15 more **14:31:51** ERROR: Error fetching remote repo ‘origin’

---

<div class="post-metadata">

**Author:** ![poddingue](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/poddingue/32/985_2.png) [@poddingue](https://community.jenkins.io/u/poddingue)\
**Post date:** [September 10, 2024, 9:45am UTC](https://community.jenkins.io/t/error-error-fetching-remote-repo-origin-failed-to-setup-credentials/19165/2 "2024-09-10T09:45:24Z")

</div>

Hello @TheoWan1, and welcome to this community. 👋

The error message `Cannot run program "cp": error=2, No such file or directory` indicates that the `cp` command is not found on the Jenkins node where the job is running. 🤷

This is likely causing the failure to set up credentials.

---

<div class="post-metadata">

**Author:** ![TheoWan1](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/theowan1/32/10015_2.png) [@TheoWan1](https://community.jenkins.io/u/TheoWan1)\
**Post date:** [October 10, 2024, 6:13pm UTC](https://community.jenkins.io/t/error-error-fetching-remote-repo-origin-failed-to-setup-credentials/19165/3 "2024-10-10T18:13:26Z")

</div>

@poddingue thanks for replying. I have looked into that, but the cp works fine when I do it manually as well. Here is another clip of error that showed the PatToken is not correct causing the repo is not able to clone. So I think the problem is before `Cannot run program "cp": error=2, No such file or directory`

> **Summary**
>
> using GIT\_ASKPASS to set credentials Temporary Read-Only GitHub Account **12:56:45** ERROR: Error cloning remote repo ‘origin’ **12:56:45** hudson.plugins.git.GitException: Failed to setup credentials **12:56:45** at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2187) **12:56:45** at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:635) **12:56:45** at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:871) **12:56:45** at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:170) **12:56:45** at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$GitCommandMasterToSlaveCallable.call(RemoteGitImpl.java:161) **12:56:45** at hudson.remoting.UserRequest.perform(UserRequest.java:211) **12:56:45** at hudson.remoting.UserRequest.perform(UserRequest.java:54) **12:56:45** at hudson.remoting.Request$2.run(Request.java:377) **12:56:45** at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:78) **12:56:45** at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) **12:56:45** at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) **12:56:45** at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)

Also, from the node logs, i can see there are some errors show below. However, jenkins is able to create a folder in my node, so I assume this error is not relevant

> **Summary**
>
> This is a Unix agent  
> ERROR: Unexpected error in launching an agent. This is probably a bug in Jenkins  
> Also: hudson.remoting.Channel$CallSiteStackTrace: Remote call to Theo\_node  
> at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1787)  
> at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356)  
> at hudson.remoting.Channel.call(Channel.java:1003)  
> at hudson.FilePath.act(FilePath.java:1283)  
> at org.jenkinsci.plugins.envinject.EnvInjectComputerListener.onOnline(EnvInjectComputerListener.java:144)  
> at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:751)  
> at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:441)  
> at hudson.plugins.sshslaves.SSHLauncher.startAgent(SSHLauncher.java:645)  
> at hudson.plugins.sshslaves.SSHLauncher.lambda$launch$0(SSHLauncher.java:465)  
> at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)  
> at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)  
> at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)  
> at java.base/java.lang.Thread.run(Thread.java:840)  
> java.lang.reflect.InaccessibleObjectException: Unable to make private native java.lang.reflect.Field java.lang.Class.getDeclaredFields0(boolean) accessible: module java.base does not “opens java.lang” to unnamed module @7f78fa3e  
> at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)  
> at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)  
> at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:200)  
> at java.base/java.lang.reflect.Method.setAccessible(Method.java:194)  
> at org.jenkinsci.plugins.envinject.service.EnvInjectMasterEnvVarsSetter.getModifiers(EnvInjectMasterEnvVarsSetter.java:29)  
> at org.jenkinsci.plugins.envinject.service.EnvInjectMasterEnvVarsSetter.call(EnvInjectMasterEnvVarsSetter.java:55)  
> at org.jenkinsci.plugins.envinject.service.EnvInjectMasterEnvVarsSetter.call(EnvInjectMasterEnvVarsSetter.java:19)  
> at hudson.remoting.UserRequest.perform(UserRequest.java:211)  
> at hudson.remoting.UserRequest.perform(UserRequest.java:54)  
> at hudson.remoting.Request$2.run(Request.java:377)  
> at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:78)  
> at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)  
> at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)  
> at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)  
> at java.base/java.lang.Thread.run(Thread.java:840)

---

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [October 11, 2024, 1:04am UTC](https://community.jenkins.io/t/error-error-fetching-remote-repo-origin-failed-to-setup-credentials/19165/4 "2024-10-11T01:04:05Z")

</div>

> [@TheoWan1](#):
>
> So I think the problem is before `Cannot run program "cp": error=2, No such file or directory`

The [message “Failed to setup credentials”](https://github.com/jenkinsci/git-client-plugin/blob/7af0df8472ad8d7a7b687a2be2eefd493e6e32db/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java#L2186) is reported when the Jenkins git client plugin detects an unexpected failure while launching command line git with credentials.

As setup for credentials in the git client plugin, the `cp` command creates a separate copy of the credential so that the Java process does not retain an open file descriptor on the credential file. The message `Cannot run program "cp": error=2, No such file or directory` means that the Java process running on the agent was unable to find the `cp` program. That message usually indicates that something has harmed the `PATH` environment variable on the agent running the command. You’ll need to fix that so that the `cp` command can be found.

If you are unable to fix the `PATH` configuration on the agent so that the `cp` command can be found, then you could try switching your configuration from using command line to instead use JGit. JGit is missing some features that are available in command line git and JGit generally uses more memory than command line git, but it is an option. Detailed instructions for that change are in the [git client plugin documentation](https://plugins.jenkins.io/git-client/#plugin-content-enabling-jgit).

---

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [October 11, 2024, 1:07am UTC](https://community.jenkins.io/t/error-error-fetching-remote-repo-origin-failed-to-setup-credentials/19165/5 "2024-10-11T01:07:36Z")

</div>

> [@TheoWan1](#):
>
> Unable to make private native java.lang.reflect.Field java.lang.Class.getDeclaredFields0(boolean) accessible: module java.base does not “opens java.lang” to unnamed module

That message is due to a flaw in the EnvInject plugin. Steps to resolve it are available in [this community post](https://community.jenkins.io/t/while-upgrading-jenkins-to-2-426-2-i-am-getting-below-when-connecting-a-node-to-the-jenkins-server/12272/4).
