Mix command not found on Heroku run

Deploying on Heroku a Elixir Phoenix project it is saying that mix command not found on command heroku run 'POOL_SIZE=2 mix test.task'

I pushed the code before running and followed the tutorial on elixir docs carefully.

To mention - mix phx.server and all other mix commands are workin just fine. Elixir version: 1.11.2

$ heroku run "POOL_SIZE=2 mix hello.task"
 ›   Warning: heroku update available from 7.52.0 to 7.53.1.
Running POOL_SIZE=2 mix hello.task on ⬢ bgsites... up, run.4395 (Free)
bash: mix: command not found

Can you paste the output of “heroku buildpacks”

2 Likes

Actually following Deploying on Heroku — Phoenix v1.5.9 there is only one heroku buildpack command:

$ heroku buildpacks:add https://github.com/gjaldon/heroku-buildpack-phoenix-static.git
 ›   Warning: heroku update available from 7.52.0 to 7.53.1.
 ›   Error: The buildpack 
 ›   https://github.com/gjaldon/heroku-buildpack-phoenix-static.git is already 
 ›   set on your app.

$ git push heroku main
Enumerating objects: 2346, done.
Counting objects: 100% (2346/2346), done.
Delta compression using up to 12 threads
Compressing objects: 100% (639/639), done.
Writing objects: 100% (2346/2346), 1.68 MiB | 477.00 KiB/s, done.
Total 2346 (delta 1633), reused 2309 (delta 1603), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: https://github.com/gjaldon/heroku-buildpack-phoenix-static.git
remote: -----> Phoenix app detected
remote: 
remote: -----> Loading configuration and environment
remote:        Loading config...
remote:        The config file phoenix_static_buildpack.config wasn't found
remote:        Using the default config provided from the Phoenix static buildpack
remote:        Detecting assets directory
remote:        WARNING: no package.json detected in root nor custom directory
remote:        * assuming phoenix 1.3.x and later, please check config file
remote:        Will use phoenix configuration:
remote:        * assets path assets
remote:        * mix tasks namespace phx
remote:        Will use the following versions:
remote:        * Node 6.9.2
remote:        Will export the following config vars:
remote: DATABASE_URL
remote: POOL_SIZE
remote: SECRET_KEY_BASE
remote:        * MIX_ENV=prod
remote: 
remote: -----> Installing binaries
remote: Resolving node version 6.9.2...
remote: Downloading and installing node 6.9.2...
remote:        Installing Node 6.9.2...
remote:        Using default npm version 3.10.9
remote: Downloading and installing yarn 0.27.5...
remote: Installed yarn 0.27.5
remote: 
remote: -----> Building dependencies
remote:        Installing node modules
remote: yarn install v0.27.5
remote: [1/4] Resolving packages...
remote: error "/tmp/build_9c2e4576/deps/phoenix" doesn't exist.
remote: info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
remote:  !     Push rejected, failed to compile Phoenix app.
remote: 
remote:  !     Push failed
remote:  !
remote:  ! ## Warning - The same version of this code has already been built: 9c969d85d1fdd442d194e89b429009060345e431
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version 9c969d85d1fdd442d194e89b429009060345e431
remote:  ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote:  !
remote:  ! If you are developing on a branch and deploying via git you must run:
remote:  !
remote:  !     git push heroku <branchname>:main
remote:  !
remote:  ! This article goes into details on the behavior:
remote:  !   https://devcenter.heroku.com/articles/duplicate-build-version
remote: 
remote: Verifying deploy...
remote: 
remote: !	Push rejected to bgsites.
remote: 
To https://git.heroku.com/bgsites.git
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/bgsites.git'

From this I see that
remote: error "/tmp/build_9c2e4576/deps/phoenix" doesn't exist.

maybe you should use this buildpack along with the current buildpack you’re using.

Taken from the docs: heroku create --buildpack hashnuke/elixir

2 Likes

If you didn’t create the app using the command @jhefreyzz mentioned you need to do the following:

heroku buildpacks:clear
heroku buildpacks:set hashnuke/elixir
heroku buildpacks:add https://github.com/gjaldon/heroku-buildpack-phoenix-static.git

That should sort it out for you

2 Likes

yeah, I did it, but the error still stands

can you run heroku buildpacks again and paste the output?

$ heroku buildpacks:clear
 ›   Warning: heroku update available from 7.52.0 to 7.53.1.
Buildpacks cleared. Next release on bgsites will detect buildpacks normally.
$ heroku buildpacks:set hashnuke/elixir
 ›   Warning: heroku update available from 7.52.0 to 7.53.1.
Buildpack set. Next release on bgsites will use hashnuke/elixir.
heroku buildpacks:add https://github.com/gjaldon/heroku-buildpack-phoenix-static.git
 ›   Warning: heroku update available from 7.52.0 to 7.53.1.
Buildpack added. Next release on bgsites will use:
  1. hashnuke/elixir
  2. https://github.com/gjaldon/heroku-buildpack-phoenix-static.git
Run git push heroku main to create a new release using these buildpacks.

Can you execute git push heroku main and paste the logs?

1 Like
$ git push heroku main
Enumerating objects: 2346, done.
Counting objects: 100% (2346/2346), done.
Delta compression using up to 12 threads
Compressing objects: 100% (639/639), done.
Writing objects: 100% (2346/2346), 1.68 MiB | 413.00 KiB/s, done.
Total 2346 (delta 1633), reused 2309 (delta 1603), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpacks:
remote:        1. hashnuke/elixir
remote:        2. https://github.com/gjaldon/heroku-buildpack-phoenix-static.git
remote: -----> Elixir app detected
remote: -----> Will export the following config vars:
remote: DATABASE_URL
remote: POOL_SIZE
remote: SECRET_KEY_BASE
remote:        * MIX_ENV=prod
remote: -----> Checking Erlang and Elixir versions
remote:        WARNING: elixir_buildpack.config wasn't found in the app
remote:        Using default config from Elixir buildpack
remote:        
remote:        IMPORTANT: The default elixir_version will be removed on 2021-06-01. Please explicitly set an elixir_version in your elixir_buildpack.config before then or your deploys will fail.
remote:        
remote:        Will use the following versions:
remote:        * Stack heroku-20
remote:        * Erlang 20.1
remote:        * Elixir v1.5.3 
remote: -----> Stack changed, will rebuild
remote: -----> Fetching Erlang 20.1 from https://repo.hex.pm/builds/otp/ubuntu-20.04/OTP-20.1.tar.gz
remote: -----> Installing Erlang 20.1 (changed)
remote: 
remote: -----> Fetching Elixir v1.5.3 for OTP 20 from https://repo.hex.pm/builds/elixir/v1.5.3-otp-20.zip
remote: -----> Installing Elixir v1.5.3 (changed)
remote: -----> Installing Hex
remote: * creating /app/.mix/archives/hex-0.21.2
remote: -----> Installing rebar
remote: * creating /app/.mix/rebar
remote: * creating /app/.mix/rebar3
remote: -----> Fetching app dependencies with mix
remote: Resolving Hex dependencies...
remote: Dependency resolution completed:
remote: Unchanged:
remote:   bcrypt_elixir 2.3.0
remote:   certifi 2.5.3
remote:   comeonin 5.3.2
remote:   connection 1.1.0
remote:   cowboy 2.8.0
remote:   cowboy_telemetry 0.3.1
remote:   cowlib 2.9.1
remote:   db_connection 2.3.1
remote:   decimal 2.0.0
remote:   ecto 3.5.7
remote:   ecto_sql 3.5.4
remote:   elixir_make 0.6.2
remote:   ex_aws 2.1.7
remote:   ex_aws_s3 2.1.0
remote:   gettext 0.18.2
remote:   hackney 1.17.0
remote:   idna 6.1.1
remote:   jason 1.2.2
remote:   kaffy 0.9.0
remote:   metrics 1.0.1
remote:   mime 1.5.0
remote:   mimerl 1.2.0
remote:   parse_trans 3.3.1
remote:   phoenix 1.5.7
remote:   phoenix_ecto 4.2.1
remote:   phoenix_html 2.14.3
remote:   phoenix_live_dashboard 0.4.0
remote:   phoenix_live_view 0.15.4
remote:   phoenix_pubsub 2.0.0
remote:   plug 1.11.0
remote:   plug_cowboy 2.4.1
remote:   plug_crypto 1.2.1
remote:   postgrex 0.15.8
remote:   ranch 1.7.1
remote:   ssl_verify_fun 1.1.6
remote:   sweet_xml 0.6.6
remote:   telemetry 0.4.2
remote:   telemetry_metrics 0.6.0
remote:   telemetry_poller 0.5.1
remote:   unicode_util_compat 0.7.0
remote:   waffle 1.1.4
remote:   waffle_ecto 0.0.10
remote: * Getting bcrypt_elixir (Hex package)
remote: * Getting kaffy (Hex package)
remote: * Getting phoenix (Hex package)
remote: * Getting phoenix_ecto (Hex package)
remote: * Getting ecto_sql (Hex package)
remote: * Getting postgrex (Hex package)
remote: * Getting phoenix_live_view (Hex package)
remote: * Getting phoenix_html (Hex package)
remote: * Getting phoenix_live_dashboard (Hex package)
remote: * Getting telemetry_metrics (Hex package)
remote: * Getting telemetry_poller (Hex package)
remote: * Getting gettext (Hex package)
remote: * Getting jason (Hex package)
remote: * Getting plug_cowboy (Hex package)
remote: * Getting waffle (Hex package)
remote: * Getting waffle_ecto (Hex package)
remote: * Getting ex_aws (Hex package)
remote: * Getting ex_aws_s3 (Hex package)
remote: * Getting hackney (Hex package)
remote: * Getting sweet_xml (Hex package)
remote: * Getting certifi (Hex package)
remote: * Getting idna (Hex package)
remote: * Getting metrics (Hex package)
remote: * Getting mimerl (Hex package)
remote: * Getting parse_trans (Hex package)
remote: * Getting ssl_verify_fun (Hex package)
remote: * Getting unicode_util_compat (Hex package)
remote: * Getting ecto (Hex package)
remote: * Getting decimal (Hex package)
remote: * Getting telemetry (Hex package)
remote: * Getting cowboy (Hex package)
remote: * Getting cowboy_telemetry (Hex package)
remote: * Getting plug (Hex package)
remote: * Getting mime (Hex package)
remote: * Getting plug_crypto (Hex package)
remote: * Getting cowlib (Hex package)
remote: * Getting ranch (Hex package)
remote: * Getting connection (Hex package)
remote: * Getting db_connection (Hex package)
remote: * Getting phoenix_pubsub (Hex package)
remote: * Getting comeonin (Hex package)
remote: * Getting elixir_make (Hex package)
remote: -----> Copying hex from /app/.mix/archives/hex-0.21.2
remote: -----> Compiling
remote: ** (Mix) You're trying to run :bgsite_official on Elixir v1.5.3 but it has declared in its mix.exs file it supports only Elixir ~> 1.7
remote:  !     Push rejected, failed to compile Elixir app.
remote: 
remote:  !     Push failed
remote:  !
remote:  ! ## Warning - The same version of this code has already been built: 9c969d85d1fdd442d194e89b429009060345e431
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version 9c969d85d1fdd442d194e89b429009060345e431
remote:  ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote:  !
remote:  ! If you are developing on a branch and deploying via git you must run:
remote:  !
remote:  !     git push heroku <branchname>:main
remote:  !
remote:  ! This article goes into details on the behavior:
remote:  !   https://devcenter.heroku.com/articles/duplicate-build-version
remote: 
remote: Verifying deploy...
remote: 
remote: !	Push rejected to bgsites.
remote: 
To https://git.heroku.com/bgsites.git
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/bgsites.git'

Do you have elixir_buildpack.config in your app directory specifying the erlang and elixir version. Create phoenix_static_buildpack.config for the other buildpack
Its like this:

# Elixir version
elixir_version=1.11.2

# Erlang version
erlang_version=23.2
1 Like

Well, Actually I don’t have it, will create and test again