{"id":28455415,"url":"https://github.com/simplifi/co_mix","last_synced_at":"2025-07-05T02:34:14.170Z","repository":{"id":58152303,"uuid":"505873935","full_name":"simplifi/co_mix","owner":"simplifi","description":"Common mix.exs code that all projects can benefit from","archived":false,"fork":false,"pushed_at":"2025-06-02T14:07:45.000Z","size":166,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":42,"default_branch":"main","last_synced_at":"2025-06-06T22:01:46.602Z","etag":null,"topics":["elixir","git","mix","versioning"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simplifi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-06-21T14:17:45.000Z","updated_at":"2022-08-29T16:52:08.000Z","dependencies_parsed_at":"2024-01-16T16:49:08.858Z","dependency_job_id":"7bc780fc-bbca-4f4a-be45-214e597a2810","html_url":"https://github.com/simplifi/co_mix","commit_stats":{"total_commits":48,"total_committers":3,"mean_commits":16.0,"dds":"0.16666666666666663","last_synced_commit":"fad855a3698ab6adae619d3dbd531e22e521d41e"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/simplifi/co_mix","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplifi%2Fco_mix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplifi%2Fco_mix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplifi%2Fco_mix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplifi%2Fco_mix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simplifi","download_url":"https://codeload.github.com/simplifi/co_mix/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplifi%2Fco_mix/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263671776,"owners_count":23494038,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir","git","mix","versioning"],"created_at":"2025-06-06T22:01:05.698Z","updated_at":"2025-07-05T02:34:14.164Z","avatar_url":"https://github.com/simplifi.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CoMix\nCommon mix.exs code that all projects can benefit from\n\n## Features\n- `CoMix.version/0`: Enables easy versioning in any git project through git tags\n  - One can run `git flow release start $VERSION; git flow release finish $VERSION` and be done\n  - If git errors instead of getting a tag, and the environment variable `CO_MIX_TAGLESS` is set, a version suffixed with `-tagless` is used\n\n## Installation\nAdd this to the top of your mix.exs file:\n```elixir\nunless Kernel.function_exported?(CoMix, :version, 0) do\n  {:ok, _} = Application.ensure_all_started(:hex)\n  Mix.install([{:co_mix, \"~\u003e 1.0\", runtime: false}])\nend\n```\nThen set `version = CoMix.version()` inside of the `def project`, instead of using a hardcoded version.\n\n### Troubleshooting\n#### Issue: Adding the `Mix.install` line to `mix.exs` causes `mix` commands like `mix deps.get` to error:\n```\n  (exit) exited in: GenServer.call(Hex.Registry.Server, {:open, []}, 60000)\n     (EXIT) no process: the process is not alive or there’s no process currently associated with the given name, possibly because its application isn’t started\n    (elixir 1.13.4) lib/gen_server.ex:1019: GenServer.call/3\n    (hex 1.0.1) lib/hex/remote_converger.ex:28: Hex.RemoteConverger.converge/2\n    (mix 1.13.4) lib/mix/dep/converger.ex:95: Mix.Dep.Converger.all/4\n    (mix 1.13.4) lib/mix/dep/converger.ex:51: Mix.Dep.Converger.converge/4\n    (mix 1.13.4) lib/mix/dep/fetcher.ex:16: Mix.Dep.Fetcher.all/3\n    (mix 1.13.4) lib/mix/tasks/deps.get.ex:31: Mix.Tasks.Deps.Get.run/1\n    (mix 1.13.4) lib/mix/task.ex:397: anonymous fn/3 in Mix.Task.run_task/3\n    (mix 1.13.4) lib/mix/cli.ex:84: Mix.CLI.run_task/2\n```\n\n##### Solution\nBe sure to include the call to `Application.ensure_all_started(:hex)` before calling `Mix.install/2`, to explicitly ensure hex is started.\n\n\n#### Issue: mix commands fail with Hex 2.0\nSince updating to Hex 2.0, Mix commands fail with an error similar to\n```\n** (Protocol.UndefinedError) protocol String.Chars not implemented for %Hex.Solver.Constraints.Range{min: %Version{major: 0, minor: 2, patch: 0}, max: %Version{major: 0, minor: 3, patch: 0, pre: [0]}, include_min: true, include_max: false} of type Hex.Solver.Constraints.Range (a struct). This protocol is implemented for the following type(s): Atom, BitString, Date, DateTime, Float, Integer, List, NaiveDateTime, Time, URI, Version, Version.Requirement\n    (elixir 1.14.1) lib/string/chars.ex:3: String.Chars.impl_for!/1\n    (elixir 1.14.1) lib/string/chars.ex:22: String.Chars.to_string/1\n    (hex 2.0.0) lib/hex/mix.ex:168: Hex.Mix.registry_dep_to_def/1\n    (elixir 1.14.1) lib/enum.ex:1658: Enum.\"-map/2-lists^map/1-0-\"/2\n    (hex 2.0.0) lib/hex/mix.ex:120: anonymous fn/1 in Hex.Mix.to_lock/1\n    (elixir 1.14.1) lib/enum.ex:1658: Enum.\"-map/2-lists^map/1-0-\"/2\n    (elixir 1.14.1) lib/enum.ex:1658: Enum.\"-map/2-lists^map/1-0-\"/2\n    (elixir 1.14.1) lib/map.ex:263: Map.new_from_enum/2\n```\n\n##### Solution\nThis is due to a known bug that was fixed in Elixir 1.14.2, update and try again.\n\n#### Issue: Commands like `mix local.hex --force` are failing (common for Travis):\n```\n** (MatchError) no match of right hand side value: {:error, {:hex, {'no such file or directory', 'hex.app'}}}\n    mix.exs:1: (file)\n    (mix 1.13.2) lib/mix/cli.ex:42: Mix.CLI.load_mix_exs/0\n    (mix 1.13.2) lib/mix/cli.ex:29: Mix.CLI.proceed/1\nThe command \"mix local.hex --force\" failed and exited with 1 during .\n```\n\n##### Solution\nThis is because `mix.exs` needs to ensure hex is started, so the machine needs to install hex first before mix can run with the updated mix.exs\n1. `cd` over to a directory without a `mix.exs`\n    - Short and to the point, `cd` will take you to the home dir, which is unlikely to have this file\n2. Run whichever mix commands were failing\n3. Run `cd -` to return to your previous directory, and proceed as usual\n\nIn `.travis.yml`, this usually looks something like\n```yaml\ninstall:\n  - cd\n  - mix do local.rebar --force, local.hex --force\n  - cd -\n```\n\n#### Issue: The release build is failing to upload from Travis:\n##### Solution\nFirst, make sure that everything is being run with `MIX_ENV` set the same (or defaulted)\n\nThere may be a script trying to pull the version by reading mix.exs\nA good solution to this that we've found is to look for and update these scripts:\n- If they already have hex installed, go ahead and use `mix app.version`\n  - If you don't have this command yet, it's easy to implement, see [here](https://mintcore.se/blog/2017/11/getting-elixir-app-version-from-command-line) ([Archived](https://web.archive.org/web/20200920053411/https://mintcore.se/blog/2017/11/getting-elixir-app-version-from-command-line))\n- In other cases, it may be cleaner to have the script call the binary, after it has been built, with a `version` argument\nSuch solutions can look like `VERSION=$(_build/prod/rel/my_app/bin/my_app version | cut -d ' ' -f2)`\n\n## Testing\nTesting is done by running `mix test`.\n\n## Releasing\nYou should be using [git flow](https://github.com/petervanderdoes/gitflow-avh/wiki/Installation) here.\n\nHowever, since this repo enables simplified versioning, we have chosen for the moment not to have it depend on itself.\n\nAs such, after running `git flow release start \u003cX.Y.Z\u003e`, you must create a commit bumping the version in mix.exs before running `git flow release finish \u003cX.Y.Z\u003e`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplifi%2Fco_mix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimplifi%2Fco_mix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplifi%2Fco_mix/lists"}