Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to promote to admin "module Ret.Repo is not available" #713

Open
Utopiah opened this issue Feb 25, 2024 · 3 comments
Open

Unable to promote to admin "module Ret.Repo is not available" #713

Utopiah opened this issue Feb 25, 2024 · 3 comments

Comments

@Utopiah
Copy link

Utopiah commented Feb 25, 2024

As recommended by https://github.com/mozilla/hubs-compose?tab=readme-ov-file#admin-panel-access I tried to run Ret.Account |> Ret.Repo.all() |> Enum.at(0) |> Ecto.Changeset.change(is_admin: true) |> Ret.Repo.update!() after logging in with a first user.

Unfortunately I'm getting

fabien@fabien-CORSAIR-ONE-i160:~/Prototypes/hubs-compose$ services/reticulum/bin/iex
Erlang/OTP 23 [erts-11.2.2.17] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1]

Interactive Elixir (1.14.3) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> Ret.Account |> Ret.Repo.all() |> Enum.at(0) |> Ecto.Changeset.change(is_admin: true) |> Ret.Repo.update!()
** (UndefinedFunctionError) function Ret.Repo.all/1 is undefined (module Ret.Repo is not available)
    Ret.Repo.all(Ret.Account)
iex(1)> 
@vincentfretin
Copy link

Maybe try iex -S mix where the reticulum mix.exs file is.

@Utopiah
Copy link
Author

Utopiah commented Feb 26, 2024

Ah, it worked, wonderful, thanks @vincentfretin!

Why though? I had a brief look at iex and mix but don't actually understand.

@vincentfretin
Copy link

This is more or less for the interpreter iex to know where the project files are located. That's the command you use in any phoenix project, I didn't really dig it why.

Here what gpt-4 answers:

In a Phoenix project, the command iex -S mix is used to start the Interactive Elixir (IEx) shell with your application and its dependencies loaded. This command is particularly useful for running your Phoenix application while also having an interactive session that can be used for debugging, running tasks, or directly interacting with your application's code and functions.

Here's a breakdown of the command:

iex: This is the Interactive Elixir shell, allowing you to run Elixir expressions in a REPL (Read-Eval-Print Loop). It's a great tool for testing small snippets of Elixir code, exploring functionalities, and debugging.

-S: This switch tells iex to run a script. In the context of this command, it's used to invoke the mix script, which is Elixir's build tool.

mix: Mix is a build tool that ships with Elixir and provides tasks for creating, compiling, testing your application, managing its dependencies, and much more. It's an essential part of the Elixir ecosystem and is used for project management.

When you run iex -S mix in the context of a Phoenix project, it compiles your project (if necessary), starts the application along with its dependencies, and then launches the IEx shell. This allows you to interact with your running Phoenix application from the IEx prompt. For example, you can query Ecto models, call functions defined in your modules, etc., all while the application is running. It's a powerful feature for development and debugging purposes.

This command is particularly useful because it lets you test changes in real-time, inspect state, and interact with the application's processes. It's a common practice during development to run this command in the terminal to have a live session for experimentation and debugging while developing a Phoenix application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants