1

When i run

sudo repo init -u https://github.com/LineageOS/android.git -b lineage-18.1

I am getting error -

 File "/home/rahul/android/lineage/.repo/repo/main.py", line 79
    file=sys.stderr)
        ^ SyntaxError: invalid syntax

if i run above command without sudo, i am getting following error -

/snap/git-repo/18/usr/bin/python: can't open file '/home/rahul/android/lineage/.repo/repo/main.py': [Errno 13] Permission denied

I am having python3 on my system.

Any idea how to fix?

3
  • 1
    Why sudo the first time ? The second error is normal, your user cannot update root files. You need to delete or change ownership of the root files to your user. Commented Mar 7, 2022 at 17:12
  • 1
    sudo doesn't cause syntax errors. There must be more to this. What is the code actually getting executed? What is repo? How does it use Git? Have you tried running in verbose mode (see documentation) to find out more? That said, it's often wrong to use sudo. In other words: This might be a bug in repo, it could be faulty use on your side. I don't see a programming question though, so I'd be tempted to close this as off-topic. Commented Mar 7, 2022 at 17:24
  • 1
    repo itself uses Python; your setup is probably causing repo itself to use the wrong version of Python (as run by sudo). Commented Mar 9, 2022 at 1:16

2 Answers 2

2

Looking at my own system (Debian 10), the system-installed repo launcher (apt install repo) is designed for and requires python 2. But when you init a repo, it downloads a newer version of itself from Google, and that version requires python 3, but it gets run by the python 2 environment and fails.

As a workaround, I've been downloading a newer version of repo from Google:

curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo

And then launch it with:

python3 ~/bin/repo init ...

See also: https://android.googlesource.com/tools/repo

I would prefer a more streamlined solution, but until I upgrade my Linux distribution to a release that includes a Python3-based version of repo, I don't know of a better solution.

Sign up to request clarification or add additional context in comments.

Comments

1

Could you please check the version of repo by using the repo --version command on your terminal and try reinstalling the repo package? Maybe the issue with the version.

repo version v2.21
       (from https://gerrit.googlesource.com/git-repo)
       (tracking refs/heads/stable)
       (Wed, 26 Jan 2022 16:46:03 +0000)
repo launcher version 2.21
       (from /usr/local/bin/repo)
       (currently at 2.21)
repo User-Agent git-repo/2.21 (Darwin) git/2.31.1 Python/3.10.2
git 2.31.1
git User-Agent git/2.31.1 (Darwin) git-repo/2.21
Python 3.10.2 (main, Feb  2 2022, 07:36:01) [Clang 12.0.0 (clang-1200.0.32.29)]
OS Darwin 20.6.0 (Darwin Kernel Version 20.6.0: Wed Jan 12 22:22:42 PST 2022; root:xnu-7195.141.19~2/RELEASE_X86_64)
CPU x86_64 (i386)

If on mac: try brew reinstall repo as it should work.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.