
orville
From Ruby to Elixir: Stuck at the start (page 20)
I managed to install asdf, then erlang and elixir via asdf.
I was able to create and test the example Mix project (page 19) successfully.
I’m confused where to put the very first example: one.ex with two functions (hello/0 and welcome/1). The filenames given start with elixir_examples/lib so I assumed that ‘lib’ is the same lib directory created on page 19, and thus created the one.ex file in a new examples/modules directory. However, running iex as shown on page 21 generates a “function Examples.Modules.One.hello/0 is undefined (module Examples.Modules.One is not available)” error message. I am invoking $ iex -S mix from the same directory that contains lib and mix.exs.
I’ve played around for a couple hours and am stumped. Thanks in advance for a hint!
Most Liked

orville
The primary cause was a typo in the “defmodule” in one.ex.
However, I still find the path to the example files confusing: just prior to setting up the examples, the book has us run “mix new examples” (p19) which creates a new folder, “examples,” which contains a “lib” folder where we are to place our source code. The first example on the following page, however, places the “one.ex” in a path that has those folder names in reverse: “elixir_examples/lib/examples/modules/one.ex” so it’s confusing, especially since the top-level directory is different than the “examples” directory just created, and then we have to add two empty directories inside lib (including a confusing second instance of “examples”.
I think I understand it now, but I found it a bit confusing. Enjoying working through the rest of the otherwise excellent book, though!
Popular Prag Prog topics










Other popular topics










Latest in PragProg
Latest (all)
Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /js
- /rails
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /ash
- /centos
- /php
- /deepseek
- /zig
- /scala
- /html
- /debian
- /nixos
- /lisp
- /agda
- /sublime-text
- /react-native
- /textmate
- /kubuntu
- /arch-linux
- /revery
- /ubuntu
- /manjaro
- /spring
- /django
- /diversity
- /lua
- /nodejs
- /julia
- /c
- /slackware
- /neovim