Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Couldn't posix_spawn: error 2

Tom Bouquet
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 17, 2022

Keep getting this error when trying to clone my Github repos. Any help would be appreciated! I am running on MacOS (M1)

Couldn't posix_spawn: error 2

 

6 answers

1 accepted

5 votes
Answer accepted
Frankie
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 22, 2022

Since macOS 12.3 removed the built-in Python@2.x, Sourcetree cannot open Mercurial projects normally after system upgrade.

 

Guess the reason is that the built-in Mercurial of Sourcetree depends on the built-in Python2 of macOS, but Python2 was removed, so it throws an error.

 

The solution is as follows:

 

1. Open Sourcetree preferences and switch to the Mercurial tab. 

You can see the error message from Mercurial Version: Embedded Mercurial Couldn't posix_spawn: error 2.

 

2. Select Use System Mercurial,path like: /usr/local/Cellar/mercurial/6.1/lib/python3.10/site-packages/mercurial.

 

Choose according to the version of Mercurial you have installed. If you installed Mercurial using Homebrew, you can find its path through brew list mercurial.

 

That's it.

 

iShot2022-03-22 23.09.11.png

j c March 23, 2022

This doesn't seem to work. I get the same error using the Brew-installed version of Mercurial.

On my system it was installed at:

/opt/homebrew/Cellar/mercurial/6.1/lib/python3.10/site-packages/mercurial/

...but once I select that folder in SourceTree, it says the same error: "System Mercurial Couldn't posix_spawn: error 2"

Maybe it's still trying to use Python 2.7 still instead of Python 3.10?

 

Like # people like this
mapz
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 29, 2022

Worked for me!

veraZhang
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 27, 2022

thanks!

Fäbs Fäberson
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 25, 2022

If I choose the mercurial location from brew I get the 'not found' error and am not able to select it in Sourcetree.

Like adhimas_luqman likes this
j c August 2, 2022

The only way I was able to get it to work was to modify the "hg_local" file inside the SourceTree.app package and replace the first line to point to the path of Python 3.10 that I installed via Homebrew <https://brew.sh>. And then set it to use the Embedded Mercurial.

The steps:

1. Install Python 3.10 via Homebrew <https://brew.sh>, or skip this and just try with the Python you already installed.

2. Select your copy of SourceTree.app in the Finder and right-click (aka Control-click) on the icon and choose "Show Package Contents".

3. Navigate to Contents/Resources/mercurial_local/, then open "hg_local" in a text editor (BBEdit or TextEdit). You'll have to drag and drop it onto the editor icon, as the Mac will only want to open the file in Terminal by default.

4. Change the first line to the path of the Python you installed. (I found Python 3.10 works fine with the embedded Mercurial.)

For example, change line 1 from:

#!/usr/bin/python

to:

#!/opt/homebrew/opt/python@3.10/bin/python3.10

(Note, this is where Python 3.10 installed for me, but might be very different for you. Confirm first.)

...and save the file.

5. Launch SourceTree and make sure you are in Embedded Mercurial mode, in Preferences > Mercurial > "Embedded Mercurial Version 4.6.1".

6. Don't let SourceTree update until they have fixed this issue themselves, otherwise it will undo the above edit on step #4 (or redo the edit after each update.)

Like # people like this
Stephen Douglas Scotti
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 2, 2022

Same issue for me, although I just had to change hashbang /she-bang to:

#!/usr/bin/python3, restart SourceTree and wait for it to be 'fixed' in the distro package.  I installed hg with homebrew also.  M1 Mac Monterey.

Like adhimas_luqman likes this
sunil_pandith
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 17, 2022

IT WORKED FOR ME!!! I installed mercurial first using "brew install mercurial" then uninstalled the SourceTree and installed it back again!! Hope it helps !!!

j c November 17, 2022

Be aware that they officially released a new version 4.2 that works without modification, and at full speed for M1 Macs.

1 vote
Frank Vyncke
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 22, 2022

Same problem after upgrading to 12.3... I am still on Intel. Git works, Mercurial does not

Frank Vyncke
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 22, 2022

it's actually related to the fact that Apple seems to have upgraded the default python to version 3 (at last).

But that breaks any hg (also on the command line).

On command line I can fix it by installing mercurial 6.1, but I cannot select that version as the external mercurial... Sourcetree reports 'mercurial not found in selected folder?)

1 vote
Frankie
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 21, 2022

Me too, after upgrading macOS 12.3, opening the Mercurial project in sourcetree will report an error. But the Git project works fine.

1 vote
Jiajun March 21, 2022

Same here. Looks like a recent MacOS update causes the issue.

Yuri March 21, 2022

Yes, I have M1 and macOS 12.3

Jiajun March 21, 2022

Has anyone reported the issue to Atlassian? Otherwise it will take forever to get it fixed.

Yuri March 21, 2022

Your turn. )

0 votes
DC
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 20, 2022

Same problem, I still can't fix this problem after adding the existing local repo on macOS 12.4 Apple M1 and SourceTree 4.1.8 (244).

And I get the 'not found' error when I choose the mercurial location from brew. I guess SourceTree don't support Mercurial 6.1.3 by Python 3.8.9.

Looks like official noticed this problem: https://jira.atlassian.com/browse/SRCTREE-7867. Let's look forward to hearing from their good news.

0 votes
Yuri March 17, 2022

Same problem.

Tom Bouquet
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 17, 2022

Mine magically fixed itself after adding an existing local repo. If it wasn't that then idk what fixed it.

veraZhang
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 27, 2022

same problem. what is the solution? thanks

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events