How to create a run configuration for an elixir phoenix project in Intellij IDEA?

Hello again!

Unfortunately I’m stuck again. I want to create a run configuration for my Elixir Phoenix project, but I cannot get it to work.

My Phoenix project lives in a sub folder called backend.

Does anyone have a hint, how I can get it to work?

1 Like

The easiest thing is to use the shell and just run mix phx.server

1 Like

Seems kind of like an Intellij Elixir-plugin bug to me? Seems like it should work?

Unfortunately I’m stuck again. I want to create a run configuration for my Elixir Phoenix project, but I cannot get it to work.

My Phoenix project lives in a sub folder called backend.

Does anyone have a hint, how I can get it to work?

What is that “elixir mix phx.server” on the left side panel? Is that
the command you’re trying to run? (based on the error below)

I think just mix phx.server is what you want, assuming mix is on
your path…

That elixir mix phx.server is that what this plugin produces.

Of course mix phx.server is working :slight_smile: Just thought I want to get this shiny IDE with the plugin to work. :frowning:

1 Like

is @KronicDeth around? As the author of the IntelliJ plugin, he might have the best answers.

  1. Run > Edit Run Configurations
  2. Click +
  3. Select “Elixir Mix”
  4. In Name replace “Unamed” with phx.server
  5. In Program arguments: put phx.server
  6. If you leave “Working directory” blank, it will default to the Project root, since you say your phoenix project is in a subfolder called “backend”, you probably want to use the ... to select the backend directory
  7. Click OK to apply and close the Run/Debug Configurations dialog
  8. Go to Run > Run… to run the one you defined.

You can also use the Run Configuration select box if you have View > Toolbar checked.

3 Likes

Thank you very much for the explanation.

Unfortunately it doesn’t work like this.

When I do it in the shell it works.

You probably don’t have your SDK setup. Usually, when users don’t have the SDK setup, it’s because they didn’t setup the project.

You should be using import from external model instructions. If you just opened the directory of your project, the information from mix.exs and the SDK won’t be setup.

If you’re not using IntelliJ, but one of the Small IDEs (the language-specific ones like Rubymine, PHPStorm, etc), they don’t have access to the External Model Import system, so opening the directory will work, but you need to manually setup the Elixir SDK

1 Like

Thank you for your message. I really appreciate your help!

I found the problem:

The module SDK was set to Erlang for Elixir 20 (20).

Awesome! Thank you again!

@KronicDeth I hope you don’t mind, if I ask one more question. Do you know about a solution to have a relative path in the working directory field? So I can share this run configuration with everyone who is using the repo?

@openscript the relative pathing will just happen automatically if you click “Share” checkbox next to the “Name:” field in the Run Configuration and then commit the .idea/runConfigurations recursively. Even though the UI shows the absolute path, in the actually XML that persisted to disk, only the relative path is saved.

<component name="ProjectRunConfigurationManager">
  <configuration default="false" name="Mix ExUnit test" type="MixExUnitRunConfigurationType" factoryName="Elixir Mix ExUnit" show_console_on_std_err="false" show_console_on_std_out="false">
    <option name="passParentEnvs" value="false" />
    <option name="programParameters" value="test" />
    <option name="workingDirectory" value="$PROJECT_DIR$" />
    <module>
      <option name="moduleName" value="" />
    </module>
    <envs />
    <method />
  </configuration>
</component>

The serializing code that’s part of IntelliJ automatically substitutes the $PROJECT_DIR$ macro variable even though in the UI I have /Users/luke.imhoff/github/C-S-D/alembic. In your case, you should end up with the value being $PROJECT_DIR$/backend.

1 Like

Thank you so much!

Hello!

This is my first post. This topic is old but I think that is the perfect topic for my question:

How can I do the same but running a docker container? With PyCharm Pro is easy (change interpreter and setup a run configuration) but I don’t know how can I do that with a JetBrains IDE.

I already set Elixir SDK on project and modules settings. Right now I use Intellij Ultimate (2021.3.1 - trial) and PyCharm Pro (2021.3.1 - trial).

Thank you very much.

Regards.