Nautilus无法识别电子可执行文件 [英] Electron executable not recognized by Nautilus

查看:200
本文介绍了Nautilus无法识别电子可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用以下命令构建 Electron App 的可执行文件:

I'm not able to build an executable file of an Electron App with the following command:

electron-packager . electron-tutorial-app --overwrite --asar=true --platform=linux --arch=x64 --prune=true --out=release-builds

作为共享库文件(应用程序/ x-sharedlib)的生成文件未在 Ubuntu 18 。而是在Nautilus中打开文件时收到以下错误消息:

The build file, which is a shared library file (application/x-sharedlib), is not executing on Ubuntu 18. Instead, I'm getting the following error message when opening the file in Nautilus:


无法显示 electron-tutorial-app

Could not display "electron-tutorial-app"

没有为共享库文件安装应用程序。您
是否要搜索打开该文件的应用程序?

There is no application installed for "shared library" files. Do you want to search for an application to open this file?

[否] [是]

有没有办法做到这一点?

Is there any way around to do this?

推荐答案

TL; DR:产生的文件实际上是新格式的可执行文件。他们没有错。 Nautilus /文件管理器错误地将其识别为可执行文件。有解决方案,例如创建* .desktop文件以启动应用程序。

TL;DR: the produced files are actually executables of a new format. There's nothing wrong with them. Nautilus/file managers mistakenly don't recognize them as executables. There are solutions, such as creating a *.desktop file to launch the application.

这种现象发生是因为Electron生成Linux二进制文件的方式发生了变化。提交 9294facf 将二进制格式从ELF更改为 PIE 。所做的更改很小,只影响单个文件(BUILD.gn)。更改已从4.0.0版本开始出现在Electron中。

This phenomenon occurs as a side-effect of a change in how Electron builds Linux binaries. The commit 9294facf changed the binary format from ELF to PIE. The change is quite small and only affects a single file (BUILD.gn). The change has landed in Electron starting with version 4.0.0.

文件管理器利用 file 命令来决定什么处理文件(例如,打开图像查看器,文本编辑器或执行文件)。 file 无法区分共享库和PIE可执行文件,因此对PIE文件进行了错误分类(请参阅相应的错误报告)。

File managers utilize the file command to decide what to do with a file (e.g. open an image viewer, a text editor or execute the file). file cannot distinguish between shared libraries and PIE executables and therefore misclassifies PIE files (see the corresponding bug report).

由于该问题仅存在于图形文件管理器中,因此您可以从终端或脚本中运行可执行文件。对于非技术性最终用户而言,这有些涉及,而不是OP想要的。

Since the problem only exists for graphical file managers, you can simply run the executable from the terminal or from a script. This is somewhat involved for non-technical end users and not what the OP wants.

等待文件将PIE识别为可执行文件。反过来,这可能会导致文件管理器(例如Nautilus)正确启动PIE。目前尚不清楚是否或何时会发生这种情况。如果发生这种情况,它将可能仅包含在将来的发行版中。

Wait for file to recognize PIE as executable files. In turn, this will likely lead to file managers such as Nautilus to launch the PIEs correctly. It's not clear if or when this will happen. If it happens, it will likely only be included in future distro releases.

创建桌面文件以启动应用程序。无论如何,这都是启动桌面应用程序的常用方式。

Create a desktop file to launch the application. This is a common way desktop applications are launched anyway.

创建一个名为 myapp.desktop 的文件,其内容如下。

Create a file called myapp.desktop with the following contents.

[Desktop Entry]
Name=My Application
Exec=/path/to/binary
Terminal=false
Type=Application
StartupNotify=true
Encoding=UTF-8

然后,通过发出 chmod + x myapp.desktop 标记桌面文件可执行文件。双击文件应可按预期启动应用程序。

Then, mark the desktop file executable by issuing chmod +x myapp.desktop. Double clicking the file should launch the application as expected.

其他信息

electron-packager项目中的相应讨论: https://github.com/electron-userland/electron-packager/issues/901 。 (要点:此问题不是由电子包装程序引起的,请向上游看)。

The corresponding discussion in the electron-packager project: https://github.com/electron-userland/electron-packager/issues/901. (Gist: This issue was not caused by electron-packager, look upstream)

电子项目中的相应问题是 https://github.com/electron/electron/issues/15406 。 (要点:他们想在Linux上启用PIE。不是我们的错误,请向上游看)

The corresponding issue in the electron project is https://github.com/electron/electron/issues/15406. (Gist: they wanted to enable PIE on Linux. Not our bug, look upstream)

这篇关于Nautilus无法识别电子可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆