Snap 包命令不起作用

Snap 包命令不起作用

我创建了一个名为 ubuntunews 的 snap 包,它源自我的 github repo。它编译时没有任何错误,安装时也没有任何错误。但是,当我输入命令ubuntunews来运行它时,它给出了一个错误bash: /usr/local/bin/ubuntunews: No such file or directory ,这很奇怪,因为 snap 路径是 /snap/bin/ubuntunews。我认为这是因为我前段时间将 ubuntunews 作为常规包安装,但我现在已经卸载它并从 /usr/local/bin 中删除了 ubuntunews 脚本,但 snap 命令仍然不起作用并继续显示相同的错误。我该如何解决这个问题,这是我第一次构建 snap 包。

name: ubuntunews 
version: '1.0' 
summary: Get latest news from omgubuntu website 
description: | 
  Webcraped omgubuntu website to get the latest news about your favourite 
  linux distro and it's flavours. 

grade: devel 
confinement: devmode 

apps: 
  ubuntunews: 
    command: bin/ubuntunews 
    plugs: [network] 

parts: 
  ubuntu-news: 
    source: https://github.com/Abugbilla/ubuntunews 
    source-type: git 
    plugin: python 
    python-version: python3 
    python-packages: [bs4]

答案1

@popey 我这样做了,但仍然收到错误。但后来我发现问题出在 ubuntnews 的两个冲突路径上,即 /usr/local/bin/ubuntunews 和 /snap/bin/ubuntunews。为了清除它,我运行source ~./bashrc 以便只能获取 /snap/bin/ubuntunews,这是我真正想要的路径。但现在我收到了一个新的错误 /snap/ubuntunews/x1/usr/bin/python3: /lib/x86_64-linux-gnu/libc.so.6: version 'GLIBC_2.25' not found (required by /snap/ubuntunews/x1/usr/bin/python3)

答案2

它对我来说可以工作并构建,但您缺少一些依赖项。也许您缺少python-gi

alan@hal:~/tmp/ubuntunews⟫ snap install ubuntunews_1.0_amd64.snap --dangerous --devmode
ubuntunews 1.0 installed
alan@hal:~/tmp/ubuntunews⟫ snap run ubuntunews
Traceback (most recent call last):
  File "/snap/ubuntunews/x1/bin/ubuntunews", line 11, in <module>
    load_entry_point('ubuntunews==1.0', 'console_scripts', 'ubuntunews')()
  File "/snap/ubuntunews/x1/lib/python3.5/site-packages/pkg_resources/__init__.py", line 572, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/snap/ubuntunews/x1/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2755, in load_entry_point
    return ep.load()
  File "/snap/ubuntunews/x1/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2408, in load
    return self.resolve()
  File "/snap/ubuntunews/x1/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2414, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/snap/ubuntunews/x1/lib/python3.5/site-packages/ubuntunews/__init__.py", line 2, in <module>
    from . import brain
  File "/snap/ubuntunews/x1/lib/python3.5/site-packages/ubuntunews/brain.py", line 12, in <module>
    import gi
ImportError: No module named 'gi'

所以我想你至少需要:-

stage-packages:
  - python3-gi

相关内容