如何在Travis中安装Elixir并禁用默认Mix项目检查命令
Problem Description
I've configured my .travis.yml with the following content:
language: node_js node_js: - 6.10 language: elixir elixir: - 1.2.2 otp_release: - 18.2.1
But when running on Travis CI, I get this error:
** (Mix) Could not find a Mix.Project, please ensure a mix.exs file is available
The command "mix deps.get" failed and exited with 1 during .
I don't have an Elixir project file; I just want to install Elixir (and use iex) on Travis. How can I disable Travis' Mix project check?
Answer
This issue comes from Travis CI having default build steps for Elixir projects—by default, it automatically runs mix deps.get and other Mix-related commands, which require a mix.exs file to exist. To get around this, you just need to override Travis' default script with a command that won't trigger Mix project checks.
Here's how to adjust your .travis.yml:
language: node_js node_js: - 6.10 language: elixir elixir: - 1.2.2 otp_release: - 18.2.1 # Override default script to skip Mix project validation script: # A simple message to confirm the environment is set up properly - echo "Elixir and OTP are ready to use" # If you need to run iex commands (note: Travis is non-interactive, so use `-e` for inline execution) - iex -e "IO.puts('Hello from IEx!'); System.halt()"
If you only need to install the Elixir environment without running any extra commands, you can even set the script to true—this is a no-op command that always succeeds:
script: true
With this change, Travis will still install the specified Elixir and OTP versions as you configured, but it won't attempt to look for a mix.exs file or execute any default Mix commands.
内容的提问来源于stack exchange,提问作者martin doe

