iex

IEx Pry: Always allow?

旧巷老猫 提交于 2020-08-19 11:36:41
问题 When I run Elixir code with my debugger, Pry, then it always confronts me with Allow? [Yn] Can I pass a configuration option to always allow this? Thus, by default? Why is this question asked? What could be harmful? 回答1: No, you cannot provide an option to allow without manual confirmation. The confirmation is a reused component of IEx, any terminal takeover messages ( :take ) require user confirmation. This take over flow also happens in IEx.pry/0. As for why this is the case, I am not sure.

Elixir — Module was not compiled with docs

余生颓废 提交于 2020-01-01 12:05:32
问题 I just started learning elixir yesterday. I have a file User.exs. It looks like this: defmodule User do @moduledoc """ Defines the user struct and functions to handle users. """ # functions and stuff go here... end When I run iex , this is what happens when I try to see the docs: iex(1)> c "user.exs" [User] iex(2)> h User User was not compiled with docs Any ideas? 回答1: c("user.exs") compiles the file in memory and does not write the bytecode (.beam file) to disk while h/1 currently requires

Get a list of all elixir modules in IEx

一世执手 提交于 2019-12-24 00:43:57
问题 To get a list of all functions on a module in IEx I can run: Map.__info__(:functions) # or Enum.__info__(:functions) Using the {Module}.__info__(:functions) format. How can I get a list of all the standard lib modules? 回答1: From IEx you can type : + Tab to get a list of all available modules. 回答2: If you want to get all loaded Elixir modules, without erlang modules, run the following in a clean IEx shell: :code.all_loaded() |> Enum.filter(fn {mod, _} -> "#{mod}" =~ ~r{^[A-Z]} end) |> Enum.map

Pry while testing

梦想与她 提交于 2019-12-18 12:43:28
问题 I'm pretty new in Elixir, but have a lot fun with it! I came from Ruby world, so start looking analogy. And there is exist debugging tool pry . Using binding.pry I can interrupt any session. I found something similar in Elixir – IEx.pry . But it doesn't work when I'm testing something through ExUnit . Question – is it is possible to interrupt testing session and run iex with current environment? 回答1: You need to start your tests inside an iex session - you can do that by running iex -S mix

NotImplementedError: data_source='iex' is not implemented

余生长醉 提交于 2019-12-13 14:10:54
问题 I am trying to get some stock data through pandas_datareader in jupyter notebook. I was using google, but that does not work anymore, so I am using iex. import pandas_datareader.data as web import datetime start = datetime.datetime(2015,1,1) end = datetime.datetime(2017,1,1) facebook = web.DataReader('FB','iex',start,end) However, it comes back with the following error. NotImplementedError: data_source='iex' is not implemented Can anyone help me how to solve this issue please? 回答1: You need

Code.ensure_loaded? in .iex.exs

醉酒当歌 提交于 2019-12-11 05:53:08
问题 I have an elixir console configuration stored in .iex.exs : if Code.ensure_loaded?(MyApp.Repo) do alias MyApp.Repo end I want to have an ability to run both iex and iex -S mix . I'll have exception if I remove condition on iex . But this conditions doesn't work well! Even on iex -S mix I have (module Repo is not available) error if I'm trying to invoke Repo.get(...) . So, my questions are: Why Code.ensure_loaded? doesn't work here? How can I fix that? 回答1: This is a matter of scoping. Inside

Elixir — Module was not compiled with docs

为君一笑 提交于 2019-12-04 10:22:47
I just started learning elixir yesterday. I have a file User.exs. It looks like this: defmodule User do @moduledoc """ Defines the user struct and functions to handle users. """ # functions and stuff go here... end When I run iex , this is what happens when I try to see the docs: iex(1)> c "user.exs" [User] iex(2)> h User User was not compiled with docs Any ideas? c("user.exs") compiles the file in memory and does not write the bytecode (.beam file) to disk while h/1 currently requires (details below) the beam file to be present on disk to work. You can make c store the generated bytecode in

Make elixir app recompile and reload on source code change

ぐ巨炮叔叔 提交于 2019-12-03 09:32:58
How to automatically recompile and reload my iex + mix application every time I modify the source code? If there's no way for iex + mix combination to do that, what's the easiest alternative? I've checked phoenix's way to do reload, and it doesn't seems easy to implement for my small test project. I also know about José's .iex.exs : defmodule R do def reload! do Mix.Task.reenable "compile.elixir" Application.stop(Mix.Project.config[:app]) Mix.Task.run "compile.elixir" Application.start(Mix.Project.config[:app], :permanent) end end And I'm not extremely happy since it's not reloading

Another way to exiting IEX other than ctrl-C

余生长醉 提交于 2019-12-03 06:36:43
问题 I know we can exit the IEX console with control-C. I'm curious if there's a command to type into the console that would also do the same thing. 回答1: I can think of 3 ways to quit an IEx shell: The mentioned <ctrl-c> hit twice or once followed by q and then <enter> , <ctrl-g> and then q + <enter> , and finally System.halt , but there is a difference between System.halt and the others. Namely that System.halt " halts the Erlang runtime " and the others just " quit the shell ". When you have

Is there a Phoenix equivalent to Rails Console

邮差的信 提交于 2019-12-03 03:23:13
问题 I'm just learning Phoenix and Elixir and I'm coming from Ruby/Rails where I work in the REPL using pry to inspect my database and application state. I'm trying to figure out how to interact with my database and models in a Phoenix app. I'm aware of iex , but I don't know how to use it inspect my app's database from the repl. Do I need to connect to it with ecto each time from the repl? Is there a rails console equivalent. I've checked the Phoenix docs, Elixir Dose, and the Ecto repo, but can