在 Ubuntu 上安装 gmake;牛仔服务器未启动

Installing gmake on Ubuntu; Cowboy server not starting

我的 erlang cowboy 服务器需要 gmake 到 运行。我可以在 OSX 机器和 运行 服务器上使用 gmake run。 运行 make run 也工作正常但警告我应该安装 gmake.

当我在 ubuntu 主机上安装存储库 https://github.com/QuantumProductions/tunnel.git 时,我尝试 make run 并遇到错误。 gmake 没有可用的软件包。如何安装 gmake

root@marble-pyramid-1:~/tunnel# apt-get install gmake
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package gmake
root@marble-pyramid-1:~/tunnel# ls
erlang.mk  Makefile  oldh  rel  relx.config  src  static  tunnel.d
root@marble-pyramid-1:~/tunnel# make run
erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
 DEP    cowboy
 DEP    jiffy
mv: cannot stat ‘/root/tunnel/deps/jiffy/ebin/jiffy.app’: No such file or directory
make[1]: Entering directory `/root/tunnel/.erlang.mk/rebar'
./bootstrap
No beam files found.
escript: exception error: undefined function make:files/2
  in function  erl_eval:do_apply/6 (erl_eval.erl, line 569)
  in call from erl_eval:expr/5 (erl_eval.erl, line 243)
  in call from escript:eval_exprs/5 (escript.erl, line 856)
  in call from erl_eval:local_func/5 (erl_eval.erl, line 467)
  in call from escript:interpret/4 (escript.erl, line 774)
  in call from escript:start/1 (escript.erl, line 277)
  in call from init:start_it/1
make[1]: *** [all] Error 127
make[1]: Leaving directory `/root/tunnel/.erlang.mk/rebar'
/root/tunnel
{"init terminating in do_boot",{undef,[{rmemo,start,[],[]},{erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,569}]},{erl_eval,exprs,5,[{file,"erl_eval.erl"},{line,118}]},{init,start_it,1,[]},{init,start_em,1,[]}]}}

Crash dump was written to: erl_crash.dump
init terminating in do_boot ()
make[1]: Entering directory `/root/tunnel/deps/cowboy'
../../erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
 DEP    cowlib
 DEP    ranch
make[2]: Entering directory `/root/tunnel/deps/cowlib'
../../erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
 DEPEND cowlib.d
../../erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
 ERLC   cow_base64url.erl cow_cookie.erl cow_date.erl cow_hpack.erl cow_http.erl cow_http2.erl cow_http_hd.erl cow_http_te.erl cow_mimetypes.erl cow_multipart.erl cow_qs.erl cow_spdy.erl cow_sse.erl cow_uri.erl cow_ws.erl
src/cow_base64url.erl:31: syntax error before: '{'
src/cow_base64url.erl:40: syntax error before: '{'
src/cow_base64url.erl:52: syntax error before: '{'
src/cow_base64url.erl:59: syntax error before: '{'
src/cow_base64url.erl:21: function decode/1 undefined
src/cow_base64url.erl:22: function decode/2 undefined
src/cow_base64url.erl:23: function encode/1 undefined
src/cow_base64url.erl:55: function encode/3 undefined
make[3]: *** [ebin/cowlib.app] Error 1
make[2]: *** [app] Error 2
make[2]: Leaving directory `/root/tunnel/deps/cowlib'
make[1]: *** [deps] Error 2
make[1]: Leaving directory `/root/tunnel/deps/cowboy'
make: *** [deps] Error 2

编辑:安装 erlang-base-hipe:

root@marble-pyramid-1:~/tunnel# apt-get install erlang-base-hipe
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  gyp javascript-common libc-ares-dev libc-ares2 libjs-node-uuid libssl-dev
  libssl-doc libv8-3.14-dev linux-headers-3.13.0-68
  linux-headers-3.13.0-68-generic linux-image-3.13.0-68-generic
  linux-image-extra-3.13.0-68-generic node-abbrev node-ansi node-archy
  node-async node-block-stream node-combined-stream node-cookie-jar
  node-delayed-stream node-forever-agent node-form-data node-fstream
  node-fstream-ignore node-github-url-from-git node-glob node-graceful-fs
  node-gyp node-inherits node-ini node-json-stringify-safe node-lockfile
  node-lru-cache node-mime node-minimatch node-mkdirp node-mute-stream
  node-node-uuid node-nopt node-normalize-package-data node-npmlog node-once
  node-osenv node-qs node-read node-read-package-json node-request node-retry
  node-rimraf node-semver node-sha node-sigmund node-slide node-tar
  node-tunnel-agent node-which zlib1g-dev
Use 'apt-get autoremove' to remove them.
Suggested packages:
  erlang-edoc erlang-gs erlang erlang-manpages erlang-doc
The following packages will be REMOVED:
  erlang-base
The following NEW packages will be installed:
  erlang-base-hipe
0 upgraded, 1 newly installed, 1 to remove and 196 not upgraded.
Need to get 8,030 kB of archives.
After this operation, 2,610 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.digitalocean.com/ubuntu/ trusty-updates/universe erlang-base-hipe amd64 1:16.b.3-dfsg-1ubuntu2.1 [8,030 kB]
Fetched 8,030 kB in 0s (16.9 MB/s)
dpkg: erlang-base: dependency problems, but removing anyway as you requested:
 erlang-crypto depends on erlang-base (= 1:16.b.3-dfsg-1ubuntu2.1) | erlang-base-hipe (= 1:16.b.3-dfsg-1ubuntu2.1); however:
  Package erlang-base is to be removed.
  Package erlang-base-hipe is not installed.
 erlang-asn1 depends on erlang-base (= 1:16.b.3-dfsg-1ubuntu2.1) | erlang-base-hipe (= 1:16.b.3-dfsg-1ubuntu2.1); however:
  Package erlang-base is to be removed.
  Package erlang-base-hipe is not installed.
 erlang-syntax-tools depends on erlang-base (= 1:16.b.3-dfsg-1ubuntu2.1) | erlang-base-hipe (= 1:16.b.3-dfsg-1ubuntu2.1); however:
  Package erlang-base is to be removed.
  Package erlang-base-hipe is not installed.
 erlang-runtime-tools depends on erlang-base (= 1:16.b.3-dfsg-1ubuntu2.1) | erlang-base-hipe (= 1:16.b.3-dfsg-1ubuntu2.1); however:
  Package erlang-base is to be removed.
  Package erlang-base-hipe is not installed.
 erlang-webtool depends on erlang-base (= 1:16.b.3-dfsg-1ubuntu2.1) | erlang-base-hipe (= 1:16.b.3-d
(Reading database ... 110838 files and directories currently installed.)
Removing erlang-base (1:16.b.3-dfsg-1ubuntu2.1) ...
Searching for services which depend on erlang and should be stopped...none found.
Killing epmd...it is not running.
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Selecting previously unselected package erlang-base-hipe.
(Reading database ... 110469 files and directories currently installed.)
Preparing to unpack .../erlang-base-hipe_1%3a16.b.3-dfsg-1ubuntu2.1_amd64.deb ...
Unpacking erlang-base-hipe (1:16.b.3-dfsg-1ubuntu2.1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up erlang-base-hipe (1:16.b.3-dfsg-1ubuntu2.1) ...
Searching for services which depend on erlang and should be started...none found.
root@marble-pyramid-1:~/tunnel# make run
erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
make[1]: Entering directory `/root/tunnel/deps/cowboy'
../../erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
make[2]: Entering directory `/root/tunnel/deps/cowlib'
../../erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
../../erlang.mk:24: Please upgrade to GNU Make 4 or later: https://erlang.mk/guide/installation.html
 ERLC   cow_base64url.erl cow_cookie.erl cow_date.erl cow_hpack.erl cow_http.erl cow_http2.erl cow_http_hd.erl cow_http_te.erl cow_mimetypes.erl cow_multipart.erl cow_qs.erl cow_spdy.erl cow_sse.erl cow_uri.erl cow_ws.erl
src/cow_base64url.erl:31: syntax error before: '{'
src/cow_base64url.erl:40: syntax error before: '{'
src/cow_base64url.erl:52: syntax error before: '{'
src/cow_base64url.erl:59: syntax error before: '{'
src/cow_base64url.erl:21: function decode/1 undefined
src/cow_base64url.erl:22: function decode/2 undefined
src/cow_base64url.erl:23: function encode/1 undefined
src/cow_base64url.erl:55: function encode/3 undefined
make[3]: *** [ebin/cowlib.app] Error 1
make[2]: *** [app] Error 2
make[2]: Leaving directory `/root/tunnel/deps/cowlib'
make[1]: *** [deps] Error 2
make[1]: Leaving directory `/root/tunnel/deps/cowboy'
make: *** [deps] Error 2
root@marble-pyramid-1:~/tunnel#

make 在 Ubuntu 上是 gmake。你实际上不需要它被称为 gmake.

如果您的主机是 Ubuntu 14.04 LTS,那么您的 gmake 版本几乎可以肯定是 3.81,这似乎很有可能。要获得 gmake 4,您将不得不自己构建它或切换您的主机发行版。

简单的解决方案

在 Ubuntu 16.04 而不是 14.04

上托管您的服务

稍微复杂(但仍然简单)的解决方案

这里我们将构建 gmake 4.2.1 并将其安装到您主机上的其他位置。

尝试以下两个命令并比较主机上的输出:

ceverett@changa:~$ make --version
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
これはフリーソフトウェアです. 利用許諾についてはソースを
ご覧ください.
商業性や特定の目的への適合性の如何に関わらず, 無保証です.

This program built for x86_64-pc-linux-gnu
ceverett@changa:~$ uname -srv
Linux 3.13.0-129-generic #178-Ubuntu SMP Fri Aug 11 12:48:20 UTC 2017

这是我的 Ubuntu 14.04 系统之一,目前是最新的。我有 gmake 3.81,我是 运行 内核 3.13。 (显然那里的日语位是由于地区。)

刚刚为 gmake 4.21 提取源代码,构建它并将其安装到 /opt/gmake 似乎工作得很好:

sudo mkdir /opt/gmake
sudo chown "$USER:$USER" /opt/gmake
mkdir foo
cd foo
wget http://ftp.gnu.org/gnu/make/make-4.2.1.tar.bz2
tar -jxf make-4.2.1.tar.bz2
cd make-4.2.1
./configure --prefix=/opt/gmake
make
make install

假设你已经安装了 gcc,这应该没有任何问题,你将在 /opt/gmake/bin/make 中安装 gmake 4.21。

挂钩 erlang.mk 和你的 gmake 特殊安装位置将需要一些 pathyness 修正,但如果你的路径中已经有 $HOME/bin/ 那么以下应该有效:

ceverett@changa:~/foo$ sudo ln -s /opt/gmake/bin/make $HOME/bin/make
ceverett@changa:~/foo$ bash
ceverett@changa:~/foo$ make --version
GNU Make 4.2.1
このプログラムは x86_64-pc-linux-gnu 用にビルドされました
Copyright (C) 1988-2016 Free Software Foundation, Inc.
ライセンス GPLv3+: GNU GPL バージョン 3 以降 <http://gnu.org/licenses/gpl.html>
これはフリーソフトウェアです: 自由に変更および配布できます.
法律の許す限り、 無保証 です.

我没有任何项目使用 erlang.mk 并且还需要构建其他语言的代码,但是从 运行 make devel 在一个测试项目中这似乎有工作得很好。

如果您首先查看输出,您会发现真正的错误是:

src/cow_base64url.erl:31: syntax error before: '{'

如果您查看 src/cow_base64url.erl 中的 31 行(在 deps/cowlib/src 中),您会发现

decode(Enc, #{}).

#{} 创建一个新的空映射,这是 Erlang 中的 "new" 特性(最初在 R17 引入,现在我们在 R20 上)。所以这让我觉得你正在尝试用旧版本的 Erlang 编译你的代码。

请验证您的 Erlang 版本,只需在 shell:

中输入 运行 erl
-> % erl -v
Erlang/OTP 20 [erts-9.0.1] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:10] [hipe] [kernel-poll:false]

而且,如果实际上这一切都是由旧的 Erlang 发行版引起的,那么您可以尝试从 official site or use kerl 下载预构建的二进制文件以轻松构建您自己的二进制文件。