ZabGo
Issue when running tests: (Mix.Error) The database for Copi.Repo couldn't be created: killed
Hello,
I’m new to Elixir development. I’ve started to contribute to a website written with the Phoenix framework.
When I run the command mix test, most of the tests are failing. I suspect it’s because my test environment is not set up properly. Indeed, when I run an individual test I’ve got the following error message:
Mix task exited with reason
an exception was raised:
** (Mix.Error) The database for Copi.Repo couldn't be created: killed
(mix 1.16.0) lib/mix.ex:580: Mix.raise/2
(elixir 1.16.0) lib/enum.ex:987: Enum."-each/2-lists^foreach/1-0-"/2
(mix 1.16.0) lib/mix/task.ex:478: anonymous fn/3 in Mix.Task.run_task/5
(mix 1.16.0) lib/mix/task.ex:544: Mix.Task.run_alias/6
(debug_adapter 0.20.0) lib/debug_adapter/server.ex:1969: ElixirLS.DebugAdapter.Server.launch_task/1
returning code 1
11:15:00.361 [error] Process #PID<0.491.0> raised an exception
** (Mix.Error) The database for Copi.Repo couldn't be created: killed
(mix 1.16.0) lib/mix.ex:580: Mix.raise/2
(elixir 1.16.0) lib/enum.ex:987: Enum."-each/2-lists^foreach/1-0-"/2
(mix 1.16.0) lib/mix/task.ex:478: anonymous fn/3 in Mix.Task.run_task/5
(mix 1.16.0) lib/mix/task.ex:544: Mix.Task.run_alias/6
(debug_adapter 0.20.0) lib/debug_adapter/server.ex:1969: ElixirLS.DebugAdapter.Server.launch_task/1
The dev environment is working fine. I can launch the website and add data to the database.
Do I miss something to set up the test environment?
Thank you for you help. ![]()
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated!
To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead.
Sta...
New
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app?
Looking for hints regarding:
Addi...
New
Hi all, I wanted to ask how the community is dealing with post-release steps.
Today we have Ecto migrations, which make sure that the db...
New
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #performance










First 6 of 6 Posts
emadb
Seems like that the tests cannot reach the database. Is it running? The connection url for test env is correct?
If it works in dev mode you can try run the application in test env:
Doing so could help in finding the problem.
dimitarvp
Can you show us the aliases section of your
mix.exsfile? Also sometimes this happens when people have fallible code in their application initialization.Look for
<YOUR_APP>.Applicationmodule and its init function.ZabGo
Hello both,
Thank you very much for taking the time to answer my question. I actually managed to “solve the problem”. At least I can run the tests individually. The reason for that is that I extracted the user and password of the database to another file as below:
When I changed back to a hardcoded value as below I works fine
arcanemachine
One solution I’ve experienced is to make sure you’re exporting your environment variables.
For example, this might not work:
But this might:
ZabGo
Thanks @arcanemachine for you reply.
mix test is working fine as I source the file where I keep my environment variable before runningmix test. The issue is when I run one test on its own from VSCode using the VSCode debugger. I actually wonder if it’s creating a subshell to run this test?arcanemachine
Yeah, sounds like a VS Code problem. Could also depend on how you’re setting the environment variables too.
I can’t help with the VS Code stuff… but to prevent suprises like this in the future, you could use System.fetch_env!/1 so that the system raises an exception if you haven’t actually set the environment variable. It’s nice when you know 100% that the env var will be set somewhere.