Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Couldn't posix_spawn: error 2

Edited

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

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

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

Worked for me!

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

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

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

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

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

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

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?)

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

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

Yes, I have M1 and macOS 12.3

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

Your turn. )

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.

Same problem.

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

same problem. what is the solution? thanks

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events