我正在按照自述文件中的指示将mint
与mint
一起安装。但是,当我尝试执行示例代码时,出现错误:
hex
由于我是Exixir的初学者,所以我确定我已经错过了一些简单的事情。这是我的安装方式:
在docker中运行:
iex(1)> {:ok, conn} = Mint.HTTP.connect(:http, "httpbin.org", 80)
** (UndefinedFunctionError) function Mint.HTTP.connect/3 is undefined (module Mint.HTTP is not available)
Mint.HTTP.connect(:http, "httpbin.org", 80)
创建新项目:
docker run -it --rm elixir /bin/sh
编辑# mix new kv
* creating README.md
* creating .formatter.exs
* creating .gitignore
* creating mix.exs
* creating lib
* creating lib/kv.ex
* creating test
* creating test/test_helper.exs
* creating test/kv_test.exs
Your Mix project was created successfully.
You can use "mix" to compile it, test it, and more:
cd kv
mix test
Run "mix help" for more commands.
,因此kv/mix.exs
块现在看起来像:
deps
更改目录并运行安装,选择 defp deps do
[
# {:dep_from_hexpm, "~> 0.3.0"},
# {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}
{:castore, "~> 0.1.0"},
{:mint, "~> 0.4.0"}
]
end
以安装Y
:
hex
这似乎有效。我也可以运行测试:
9afa01708fef# cd kv
9afa01708fef# mix deps.get
Could not find Hex, which is needed to build dependency :castore
Shall I install Hex? (if running non-interactively, use "mix local.hex --force") [Yn] Y
* creating /root/.mix/archives/hex-0.20.1
Resolving Hex dependencies...
Dependency resolution completed:
New:
castore 0.1.3
mint 0.4.0
* Getting castore (Hex package)
* Getting mint (Hex package)
然后运行外壳程序:
9afa01708fef# mix test
==> castore
Compiling 1 file (.ex)
Generated castore app
==> mint
Compiling 1 file (.erl)
Compiling 22 files (.ex)
Generated mint app
==> kv
Compiling 1 file (.ex)
Generated kv app
..
Finished in 0.02 seconds
1 doctest, 1 test, 0 failures
Randomized with seed 793687
在那一点上我运行9afa01708fef# iex
Erlang/OTP 22 [erts-10.5] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [hipe]
Interactive Elixir (1.9.1) - press Ctrl+C to exit (type h() ENTER for help)
(如该问题顶部的方框中的。)>
我在这里错过了什么?
我正在按照自述文件中的指示安装带有十六进制的薄荷。但是,当我尝试执行示例代码时,出现错误:iex(1)> {:ok,conn} = Mint.HTTP.connect(:http,“ httpbin.org”,80)** ...
对不起,我。解决方案是使用以下命令启动外壳: