为什么我不能让IEx.pry在Windows上运行? [英] Why can't I get IEx.pry to work on Windows?

查看:68
本文介绍了为什么我不能让IEx.pry在Windows上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下代码示例来使IEx.pry工作:

I am trying to make IEx.pry work with the following code example:

require IEx;

defmodule Example do
  def double_sum(x, y) do
    IEx.pry
    hard_work(x, y)
  end

end

Example.double_sum(1, 2)

何时我运行它时出现以下错误:

When I run it I get the following error:

Cannot pry #PID<0.106.0> at lib/example.ex:5. Is an IEx shell running? If you are Windows, you may need to start IEx with the --werl flag.

作为回应,我用--werl启动了iex并打开了erlang shell。

In response I launched iex with --werl and it opened the erlang shell.

在erlang shell中,我试图更改目录,以便可以启动文件。我是这样输入的:

In the erlang shell I tried to change directories so that I can launch the file. I did this by typing:

cd(c:/Users/william/Desktop/example)

我收到以下错误:

(SyntaxError) iex:1: keyword argument must be followed by space after: c:


推荐答案

假定模块代码位于 c:/Users/william/Desktop/example.ex 中,则可以输入 iex 并从此处强制编译:

Assuming the module code is located in "c:/Users/william/Desktop/example.ex", one might enter the iex and force a compilation from there:

iex> c "c:/Users/william/Desktop/example.ex"

Request to pry #PID<0.89.0> at /tmp/a.ex:5

    defmodule Example do
      def double_sum(x, y) do
        IEx.pry
        x + y
      end

Allow? [Yn] y

Interactive Elixir (1.5.0-dev) - press Ctrl+C to exit (type h() ENTER for help)
pry(1)> 

一旦按下 y ,您

输入了 pry 提示。另一种选择是使用 mix 来管理源代码,甚至是简单的源代码。 mix new将创建新的程序包。要在 mix 中启用 IEx.pry 支持,应运行 mix iex -S 开头的任务:

Another option would be to use mix to manage source code, even such simple source code. mix new will create new package. To enable IEx.pry support in mix one should run mix tasks prepended with iex -S:

iex -S mix # for just iex in mix environment

或:

iex -S mix phoenix.server

启用<凤凰应用程序中的code> IEx.pry 支持。


  • IEx docs ;

  • < a href = http://elixir-lang.org/getting-started/mix-otp/introduction-to-mix.html rel = nofollow noreferrer> mix

  • IEx docs;
  • Intro to mix.

边注:分号后需要IEx 是多余的,并且有代码味。

Sidenote: semicolon after require IEx is redundant and is a code smell.

这篇关于为什么我不能让IEx.pry在Windows上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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