如何修复 Ubuntu 18.04 上的 repo forall 命令?

如何修复 Ubuntu 18.04 上的 repo forall 命令?

我正在尝试使用在 Ubuntu 18.04 上通过 snap 安装的 repo 命令。大多数命令运行正常,但当我尝试运行时repo forall出现以下错误:

repo forall -c 'pwd'
Traceback (most recent call last):
  File "/home/user/aosp/.repo/repo/main.py", line 531, in <module>
    _Main(sys.argv[1:])
  File "/home/user/aosp/.repo/repo/main.py", line 507, in _Main
    result = repo._Run(argv) or 0
  File "/home/user/aosp/.repo/repo/main.py", line 180, in _Run
    result = cmd.Execute(copts, cargs)
  File "/home/user/aosp/.repo/repo/subcmds/forall.py", line 230, in Execute
    pool = multiprocessing.Pool(opt.jobs, InitWorker)
  File "/snap/git-repo/18/usr/lib/python2.7/multiprocessing/__init__.py", line 232, in Pool
    return Pool(processes, initializer, initargs, maxtasksperchild)
  File "/snap/git-repo/18/usr/lib/python2.7/multiprocessing/pool.py", line 138, in __init__
    self._setup_queues()
  File "/snap/git-repo/18/usr/lib/python2.7/multiprocessing/pool.py", line 234, in _setup_queues
    self._inqueue = SimpleQueue()
  File "/snap/git-repo/18/usr/lib/python2.7/multiprocessing/queues.py", line 354, in __init__
    self._rlock = Lock()
  File "/snap/git-repo/18/usr/lib/python2.7/multiprocessing/synchronize.py", line 147, in __init__
    SemLock.__init__(self, SEMAPHORE, 1, 1)
  File "/snap/git-repo/18/usr/lib/python2.7/multiprocessing/synchronize.py", line 75, in __init__
    sl = self._semlock = _multiprocessing.SemLock(kind, value, maxvalue)
OSError: [Errno 13] Permission denied

我研究了这个问题:

https://stackoverflow.com/questions/2009278/python-multiprocessing-permission-denied

但我的/dev/shm目录似乎没问题:

ls -lad /dev/shm
drwxrwxrwt 2 root root 40 May 26 16:40 /dev/shm

以下命令可以正常工作:

$ cd /dev/shm
$ touch test
$ ls -la test
-rw-rw-r-- 1 myuser myuser 0 May 26 21:00 test

还有其他想法吗?

这是我的 repo 版本详细信息:

repo version v1.12.37
       (from https://gerrit.googlesource.com/git-repo)
repo launcher version 1.23
       (from /snap/git-repo/18/bin/repo)
git version 2.12.0
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609]

也许问题就出在这行代码上?

https://github.com/python/cpython/blob/804fcf66559992db9d23695e501c502ab20b7712/Modules/_multiprocessing/semaphore.c#L195

当我编写类似的示例程序时,它运行良好:

int main(void)
{
    const char *name = "/permission_test_semaphore";

    sem_t* sem = sem_open(name, O_CREAT | O_EXCL, 0600, 0);
    if (SEM_FAILED == sem) {
            printf("Create semaphore failed %s, errno = %d\n", name, errno);
    } else {
            printf("Created semaphore succeeded\n");
    }

    return 0;
}

因此仍在寻找...

答案1

解决方案是不要使用snapinstall repo 命令。apt而是使用。不知道为什么。

答案2

您可以选择打开 anaconda navigator 并从中安装所有内容。

  your@user$ conda activate
  (base)your@user$ conda-navigator

之后,您可以创建一个新的环境,然后从 anaconda navigator 安装软件包。

相关内容