Git requires commandline dev tools - new xcode update - xcode

Xcode had a recent update leading to git commands not working. Message showed up saying commandline dev tools was needed
Edit Fixed:
First I was being prompted to reinstall commandLine tools over and over when trying to accept the terms
I FIXED this by opening xcode and confirming the new update information
NOTE:
I moved this here as another thread had a mix of other issues with the error it was in

First I was being prompted to reinstall commandLine tools over and over when trying to accept the terms
I FIXED this by opening xcode and confirming the new update information

Related

How to use git commands in Visual Studio 2019 Integrated Terminal [duplicate]

Visual Studio Code reports "It look like git is not installed on your system." when I try to switch to the git view. I know I have git installed and used by other Git clients. I guess if I reinstall Git following Visual Studio Code's instruction ("install it with Chocolatey or download it from git-scm.com"), it probably can fix the problem, but I don't want to mess up the existing Git clients on my system. Is there a reliable way to configure Visual Studio Code so it can find existing git installation?
Now you can configure Visual Studio Code (version 0.10.2, check for older versions) to use an existing Git installation.
Just add the path to the Git executable in your Visual Studio Code settings (menu File → Preferences → Settings) like this:
{
// Is Git enabled
"git.enabled": true,
// Path to the Git executable
"git.path": "C:\\path\\to\\git.exe"
// Other settings
}
Update 2020 (Mac)
I went through this $h!† again after updating to macOS v10.15 (Catalina), which requires an Xcode update.
And to clarify, while this post is about Visual Studio Code, this issue, is system wide. Your Git install is affected/hosed. You can try to run git in your terminal, Bash, Z shell (zsh), or whatever. It is now and it just won't.
It is the same fix. Just update Xcode. Start it up and agree to the license. That's it.
I hit this on Mac/OS X.
Symptoms:
You've been using Visual Studio Code for some time and have don’t have any issues with Git
You install Xcode (for whatever reason - OS update, etc.)
After installing Xcode, Visual Studio Code suddenly "can't find Git and asks you to either install or set the Path in settings"
Quick fix:
Run Xcode (for the first time, after installing) and agree to license. That's it.
How I stumbled upon this "fix":
After going through numerous tips about checking git, e.g., which git and git --version, the latter actually offered clues with this Terminal message:
Agreeing to the Xcode/iOS license requires admin privileges, please run “sudo xcodebuild -license” and then retry this command.
As to why Xcode would even wrap it's hands on git, WAT.
Visual Studio Code simply looks in your PATH for git. Many UI clients ship with a "Portable Git" for simplicity, and do not add git to the path.
If you add your existing git client to your PATH (so that it can find git.exe), Visual Studio Code should enable Git source control management.
This can happen after upgrading macOS. Try running Git from a terminal and see if the error message begins with:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) ...
If so, the fix is to run:
xcode-select --install
from the terminal. See this answer for more details.
I had this problem after upgrading to macOS v10.15 (Catalina).
The issue is resolved as follows:
1.
Find the Git location from the terminal:
which git
2.
Add the location of Git in settings file with your location:
settings.json
"git.path": "/usr/local/bin/git",
Depending on your platform, the user settings file (settings.json) is located here:
Windows %APPDATA%\Code\User\settings.json
macOS $HOME/Library/Application Support/Code/User/settings.json
Linux $HOME/.config/Code/User/settings.json
In Visual Studio Code, open 'User Settings': Ctrl + P and type >sett. Press Enter.
This will open the default settings on the left side and User Settings on the right side.
Just add the path to git.exe in user settings:
"git.path": "C:\\Users\\[WINDOWS_USER]\\AppData\\Local\\Programs\\Git\\bin\\git.exe"
Replace [WINDOWS_USER] with your user name.
Restart Visual Studio Code.
First check if Git* is installed or not in your system by typing the command in cmd /command prompt (in Windows):
where git
If you get an output like this,
λ where git
C:\cmder\vendor\git-for-windows\cmd\git.exe
Then Go to Settings → Preferences → Settings and put the bellow code** right part.
{
// If git enabled?
"git.enabled": true,
// Path to the Git executable
"git.path": "C:\\cmder\\vendor\\git-for-windows\\cmd\\git.exe"
}
If you don't have Git installed, install Git from https://git-scm.com/
** Just add a double slash (\\), just like the above code.
UPGRADE TO MacOS Ventura < 13.0
As of November 2022
Upgrading to MacOS Ventura does not seem to affect your coding environments too much.
After upgrading to macOS Ventura your Terminal and VScode will give off a few errors. Such as:
It look like git is not installed on your system ..
or
can't find Git and asks you to either install or set the Path in settings
some errors depend on your zsh setup or other customizations.
These common problems can be resolved by simply by reinstalling xcode command line tools and updating Homebrew - since your terminal might be affected reinstall from apples executable https://developer.apple.com/download/all/
developer.apple.com you will need to log in with your apple id.
Once installed, update Homebrew
brew upgrade
Mac M1 - M2 machines likely have some native and ARM applications so run:
arch -arm64 brew upgrade
Close all terminals and Vscode to restart!
reopen Vscode, errors should be gone.
If Vscode is still looking for Git path you will need to add it manually.
Find git location and copy from the terminal:
which git
and add the path to the git executable in your Visual Studio Code JSON settings file (File -> Preferences -> Settings) find and update the line - should look similar:
"git.path": "/usr/local/bin/git",
After an OS X update, I had to run xcode-select --install for GitLens to work.
Ran into the same problem after!
how I fixed it?
Step 1: Go to the Settings in vscode.
Step 2: Open settings.json.
Step 3: You need to find something like "git.path" in settings.json
Step 4: just add the directory path where git is installed in your system.
example : "git.path": "D:/Git/bin/git.exe"
Step 5: Restart your vscode.
Hope this helps.
Run
xcode-select --install it'll prompt you to install command line developer tools. Install the tools and installation restart your VScode.
You'll see git working once again in VScode
I ran into this problem after upgrading my macOS to Monterey.
It turned out that the xcode has been removed in the new update from my mac. Just tried the following suggested solution:
https://stackoverflow.com/a/52522566/11207358
VSCode 1.50 (Sept 2020) adds an interesting alternative with issue 85734:
Support multiple values for the git.path setting
I use VSCode in three different places; my home computer, my work computer, and as a portable version I carry on a drive when I need to use a machine that doesn't have it.
I use an extension to keep my settings synced up between editors, and the only issue I've encountered so far is that the git path doesn't match between any of them.
On my home machine I have it installed to C of course,
work likes to be funny and install it on A,
and for the one on my drive I have a relative path set so that no matter what letter my drive gets, that VSCode can always find git.
I already attempted to use an array myself just to see if it'd work:
"git.path": ["C:\\Program Files\\Git\\bin\\git.exe", "A:\\Git\\bin\\git.exe", "..\\..\\Git\\bin\\git.exe"],
But VSCode reads it as one entire value.
What I'd like is for it to recognize it as an array and then try each path in order until it finds Git or runs out of paths.
This is addressed with PR 85954 and commit c334da1.
with VSCode 1.60+
"git.enabled": true
git.path
I faced this problem on macOS v10.13.5 (High Sierra) after upgrading Xcode.
When I run the git command, I received the below message:
Agreeing to the Xcode/iOS license requires admin privileges, please run “sudo xcodebuild -license” and then retry this command.
After running the sudo xcodebuild -license command, the below message appears:
You have not agreed to the Xcode license agreements. You must agree to both license agreements below in order to use Xcode.
Hit the Enter key to view the license agreements at '/Applications/Xcode.app/Contents/Resources/English.lproj/License.rtf'
Typing the Enter key to open the license agreements and typing the space key to review details of it, until the below message appears:
By typing 'agree' you are agreeing to the terms of the software license agreements. Type 'print' to print them or anything else to cancel, [agree, print, cancel]
The final step is simply typing agree to sign with the license agreement.
After typing the git command, we can check that Visual Studio Code detected Git again.
I have recently started with Visual Studio Code. I have this issue and just writing the exact path of the Git executable solves
the issue. Here is the code:
"git.path": "C:\Program Files\Git\bin\git.exe",
If you have multiple environments. You could include Git Path in the Visual Studio Code Workspace Setting. For Windows, depending on your setting, you could hit Ctrl + P, search for "settings". Open settings.json (or menu File → Preferences → Settings). Navigate to Workspace Settings. Find "Path" and add paths to Git bin and cmd folders.
Environments can have their own paths. I discovered this when I echoed my PC %PATH% on cmd. Git bin and cmd path where available, but when I was working on my project, echoed %PATH% did not have git and cmd folder. Adding them, as shown above, solved the issue.
Extra Notes:
On cmd, you can echo "%PATH%" and see if git bin and cmd folders are included. If not, you could concatenate using SETX PATH on, for example,
SETX PATH "%PATH%;Path_to_Git_bin;Path_to_Gt_cmd;"
This will make git available on local, root but not in some environments which comes with their own paths (SETX /M PATH "%PATH%;Path_to_Git_bin;Path_to_Gt_cmd;" would have though).
In case you have a long Path that is chopped off due to Path length (getting "Error: Truncated at X characters." message), you can increase the path length in RegEdit.
In "Search Windows", search for "regedit". Right-click to open as Administrator.
Go to Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem
Right-click and modify. Change value data from 0 to 1
This will increase your path length. If it is already one, then I am not sure how to proceed from there :).
[9
The only way I could get to work in my Windows 8.1 is the following:
Add to system environment variables (not user variables):
c:\Users\USERNAME\AppData\Local\GitHub\PortableGit_YOURVERSION\bin\;c:\Users\USERNAME\AppData\Local\GitHub\PortableGit_YOURVERSION\libexec\git-core\;c:\Users\USERNAME\AppData\Local\GitHub\PortableGit_YOURVERSION\cmd\
This fixed the "it looks like git is not installed on your system" error on my Visual Studio Code.
Make sure git is enabled (File --> Preferences --> Git Enabled) as other have mentioned.
Make sure Gits installed and in the PATH (with the correct location, by default: C:\Program Files\Git\cmd) - PATH on system variables btw
Change default terminal, Powershell can be a bit funny, I recommend Git BASH but cmd is fine, this can be done by selecting the terminal dropdown and selecting 'set default shell' then creating a new terminal with the + button.
Restarting VS Code, sometimes Reboot if that fails.
Hope that helped, and last but not least, it's 'git' not 'Git'/'gat'. :)
In my case GIT was installed on my WIndows 10 OS and there was an entry in PATH variable. But VS CODE 1.52.1 still unable to detect it from terminal window but it was available in CMD console.
Problem was solved by switching terminal from PowerShell to CMD or Shell + VsCode restart.
I solved the same problem on MacOS with m1 pro processor by installing Git Lens Visual Code extension. The changed files were displayed after enabling the extension. Then I turned reloaded the VSCode and there was no changes, but once I run
git status
in terminal, it shows all the files, and all changes are tracked.
Faced this issue after updating macOS!
Installed git again using homebrew and it worked!
brew install git
FOR MAC
First, type
git
in the terminal and see what error you are getting.
Then:
If the error is related to Command Line tool!
Run:
xcode-select --install
And
Just go ahead and go through this answer, For Mac especially. Worked very easily for me.
https://apple.stackexchange.com/a/254381
Three years later, I ran into the same issue. Setting the path in user settings & PATH environment variable didn't help. I updated Visual Studio Code and that solved it.
First install Git onto your desktop, and then add the encircled extension in Visual Studio Code, as seen in the picture.
That helped me fix the same issue you have.
Open
C:\Users\nassim\AppData\Roaming\Code\User\settings.json
Comment any Git line there:
// ...
// "git-graph.integratedTerminalShell": "E:\\Apps\\Git\\bin\\bash.exe",
// "git.path": ""
//...
And add git.exe to the OS path.
Note for me: Fixing this Git error also fixed the npm error too. Since they are both defined in the path, if one fail, the remaining will fail as well.
Follow this :
1. File > Preferences > setting
2. In search type -> git path
3. Now scroll down a little > you will see "Git:path" section.
4. Click "Edit in settings.json".
5. Now just paste this path there "C:\\Program Files\\Git\\mingw64\\libexec\\git-core\\git.exe"
Restart VSCode and open new terminal in VSCode and try "git version"
In case still problem exists :
1. Inside terminal click on terminal options (1:Poweshell)
2. Select default shell
3. Select bash
open new terminal and change terminal option to 2:Bash
Again try "git version" - this should work :)
What worked for me was manually adding the path variable in my system.
I followed the instructions from Method 3 in this post:
https://appuals.com/fix-git-is-not-recognized-as-an-internal-or-external-command/
If git is missing after the OS update, in my case Big Sur, just literally: brew install git
I edited Path into System Environment and add "C:\Program Files\Git\bin" then restart Vscode. It's worked for me. I don't understand why I am using it normally then I have this problem. Maybe during the installation of something it causes that problem.
It worked for me just by installing git for windows, from this link https://git-scm.com/download/win
There was no need of setting environment variable or path.
Context:
I had installed VS Code, and github desktop, I cloned the repo using Github desktop.
When I opened repo, using VS Code, I saw this error.
I resolved by installing git for windows.

FileMerge quits immediately after launching from SourceTree

I regularly use Atlassian SourceTree (on Mac OS X) to launch FileMerge to resolve git merge conflicts. Out of the blue it has stopped working: when I right click and select Resolve Conflicts > Launch External Merge Tool, FileMerge launches, creates its intermediate files, then immediately exits. SourceTree interprets that as the merge process being complete.
What's the issue and how can I debug/fix it?
I note that a previous question 'SourceTree filemerge quits immediately and creates 4 files. How to fix it?' does not address this particular scenario (for one, it says FileMerge quits in the title, but in the body it says FileMerge displays /dev/null as one of the panels. Additionally, my merge conflict is not due to a removed file.)
To diagnose the problem, I ran opendiff from the Terminal. I received the following error:
xcode-select: error: tool 'opendiff' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
To solve:
Open Xcode > Preferences > Locations
Click on the drop-down box beside Command Line Tools and select your current Xcode version. (This was empty for me because I had recently installed Xcode on a new Mac.)
Run opendiff in Terminal again, and the above error should no longer appear.
Now FileMerge will open correctly from SourceTree when you click Launch External Merge Tool.
For me, SourceTree didn't even launch FileMerge. When clicking Launch External Merge Tool nothing happened.
Moreover, running opendiff in Terminal worked as expected:
$ opendiff
opendiff[64176:5561154] too few arguments
opendiff[64176:5561154] usage: opendiff file1 file2 [-ancestor ancestorFile] [-merge mergeFile]
What helped me was manually configuring SourceTree to use FileMerge via the opendiff command with the following arguments: $LOCAL $REMOTE -ancestor $BASE -merge $MERGED
This way, SourceTree opens FileMerge as expected.
This helped:
https://gist.github.com/kylefox/4512777
Tell system when Xcode utilities live:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
Set "opendiff" as the default mergetool globally:
git config --global merge.tool opendiff
If Xcode has recently updated itself, you may need to agree to the new license terms. If you have not agreed to the license terms, FileMerge (when launched from SourceTree) will quit immediately.
To check for this, open a shell and run as your usual user:
$ opendiff
If the license is the problem, it will tell you. To agree to the new license terms, you'll need to run open diff using sudo:
$ sudo opendiff
After agreeing to the license terms, you can now retry launching FileMerge from SourceTree using Resolve Conflicts > Launch External Merge Tool. FileMerge should launch and behave normally.
This also works to resolve the message "xcode-select: error: tool 'opendiff' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance":
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
I have encountered this problem and solved it with the answer here
So this time, when I had it again, I thought the same issue happened...
And after trying for almost an hour, I've realized that the Diffmerge (or any external diff tool) did not open because there was no file in the current branch to merge.
This can happen when you do Cherry Pick where the commits can be jumpy. Added this answer to remind people who are going to have the same issue.
Tick Allow Sourcetree to modify your global... solves the issue for me

Why can't I run git commands after updating to OSX 10.10?

I upgraded from OSX 10.9 to 10.10. When I try to
git status
I get
Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.
Why do I have to accept a new TOS to run git? Is there a workaround to accepting new Xcode TOS?
I know that I could simply open up Xcode and accept the new user agreement and carry on. I plan on using Xcode in the future and have no specific objections to using it. Wondering how a developer could, hypothetically, choose to continue running git should they disagree with Xcode's new TOS.
If you find that which git returns /Library/Developer/CommandLineTools/usr/bin then you are dependent on xcode functionality and its associated TOS.
If you install through another mechanism, brew or via GitHub command line tools, you would not receive this prompt. You may want to make sure your other version is earlier in your path:
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Git and Xcode: Why do I have to agree to Xcode's T&Cs to use Git?

Git temporarily stopped working after I updated Xcode on my Mac. The message:
"Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo."
and then started working once I'd agreed to Xcode's T&Cs and installed the update.
Why, or should I say how, are the two linked?
I installed Git using the install.
Your git binary is provided by XCode (which is an easy way to get many command line tools packaged and maintained by Apple), and Apple wants you to accept their license before using any XCode component
If you don't like this, you can install it manually using Homebrew or similar. If you want to compile it yourself you will need a compiler for that. An easy way is using the one provided by XCode (see a pattern here?).
I've found that for my needs as a cross-platform Java-using-git developer the binaries provided by XCode are fine. This especially since they are automatically updated by Apple over time.
sudo xcodebuild -license will show you the license text of Xcode.
You have to agree its terms and condition at the end or you can just run the command given below.
sudo xcodebuild -license accept
P.S.- You are giving access to xcode.
In your terminal, run your git command as sudo
sudo git status
This will give you the option to view/accept the license agreements. Press enter to view it and press space until you get to the bottom. You can then type "agree" to agree to the license agreements. This will get rid of that message and you can use git again.
tl;dr try opening xcode and installing the plugins it suggests.
Even after I installed xcode, accepted the terms, and followed the developer tools prompt, it would continue to prompt me to install developer tools as if I didn't just do it. I eventually found a thread on reddit that suggested opening xcode and going through the recommended plugin installtion that comes up and that worked for me.

XCode 4.3 Command Line Tools Package with Invalid Checksum

The package Apple provides to install the command line tools with Xcode 4.3 is corrupted, and I seem to need it because I'm developing some command line tools.
Has anybody found an alternative Command Line package for Xcode 4.3 from Apple that works or an workaround for the subject?
Xcode includes a new "Downloads" preference pane to install optional components such as command line tools, and previous iOS Simulators.
So, I found a way to do this correctly.
The problem is really in one of the European mirrors from Apple.
The workaround is to:
- Install Tor: https://www.torproject.org/
- Choose a Tor node in the USA
- Logging into your Apple Developer account and download the package
It now opens correctly without any checksum warning.
I solved my own problem of downloading/installing Xcode 4.3.1 "Command Line Tools" by getting them directly from the developer's webpage. The March version yielded a checksum error just like
the download from within Xcode 4.3.1, i.e. Xcode/Preferences/Downloads . But I did have success with the February version of CLT. I don't know why things were out-of-sync.
I had the same problem when trying to install the Command Line Tools from the Downloads tab in the XCode preferences (also downloading from Europe). I fixed it by clearing the dns cache on my system.
This is the Terminal command to clear the dns cache (OSX Lion):
dscacheutil -flushcache
Restart XCode after running this command, it may not fix the problem with the checksum until you do.
try:
defaults write com.apple.frameworks.diskimages skip-verify -bool true
Just add another mirror for the download site:
Use the following to determine a valid ip:
http://www.webmaster-toolkit.com/dns-query.shtml?address=adcdownload.apple.com
and add this to /etc/hosts:
adcdownload.apple.com
Example (ip might already have changed)
64.211.144.168 adcdownload.apple.com.
You can simply click skip while the disk image is verifying. I have installed from a dmg of CLT-4.3 with this problem and built an extensive amount of software with if successfully on my te

Resources