Sanjibukai

Sanjibukai

Configuring the current working directory for IEx or Mix?

Hi everybody,

I wanted to know if it’s possible to configure the cwd (current working directory) path of the mix.exs file (which is the root path of the application) for iex.
Let me precise that I don’t want to change the defaults (i.e. move the mix.exs file elsewehre).
But I’m in a situation where I’m invoking mix commands from a directory that it’s not the project root.

For the details, I’m using VS Code tasks shortcuts to run mix commands where the cwd is the workspace directory of VS Code. So the mix commands fail because of not being in the same directory of the mix.exs file (error: Could not find a Mix.Project)

So, in other words I want to be able to run mix commands from another directory than the project root and be able to tell mix or iex (in case of iex -S mix) where to look for the mix.exs file.

I learned that IEx is looking for a dot file .iex.exs (in the cwd or in home) which it runs before starting the IEx session.

So I wonder if there is something equivalent for mix commands (where I can into the project root path) ?
Or if there is a way to define some kind of options in .iex.exs to define the path where mix should look for and then running iex -S mix?

I currently have found a workaround by either by cding before running the mix command (like cd project_dir && mix test) or by defining in VS Code the cwd of the task to run.
But I wanted to know if it’s possible to configure that inside the elixir project.

Thank you.

Most Liked

NobbZ

NobbZ

The working directory is inherited from the parent process.

Though as far as I remember VScode tasks can set the working directory of the task in options.cwd of the task.

Where Next?

Popular in Questions Top

lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New

Other popular topics Top

New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36128 110
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement