Skip to content

Installing archive from remote excludes dot files #13994

@almirsarajcic

Description

@almirsarajcic

Elixir and Erlang/OTP versions

Erlang/OTP 27 [erts-15.1.2] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [dtrace]

Elixir 1.17.3 (compiled with Erlang/OTP 27)

Operating system

macOS Sonoma 14.7 (23H124)

Current behavior

I'm working on a generator that relies on a lot of template files, some of which are dot files.

The installed archive is supposed to include all these files, but currently it doesn't.

I can bypass the issue locally by running mix archive.build --include-dot-files

$ mix archive.build --include-dot-files
Generated archive "optimum_gen_infra-0.1.1.ez" with MIX_ENV=dev
$ tar -ztvf optimum_gen_infra-0.1.1.ez
-rw-r--r--  0 0      0         457 Nov 14 22:09 optimum_gen_infra-0.1.1/priv/templates/test/app_name_web/controllers/health_controller_test.exs.eex
-rw-r--r--  0 0      0         299 Nov 14 22:09 optimum_gen_infra-0.1.1/priv/templates/rel/env.sh.eex.eex
-rw-r--r--  0 0      0         639 Nov 14 22:09 optimum_gen_infra-0.1.1/priv/templates/lib/app_name_web/controllers/health_controller.ex.eex
-rw-r--r--  0 0      0         687 Nov 14 22:09 optimum_gen_infra-0.1.1/priv/templates/fly.toml.eex
-rw-r--r--  0 0      0         672 Nov 14 22:09 optimum_gen_infra-0.1.1/priv/templates/fly.prod.toml.eex
-rw-r--r--  0 0      0         148 Nov 14 22:09 optimum_gen_infra-0.1.1/priv/templates/coveralls.json.eex
-rw-r--r--  0 0      0         841 Nov 14 22:09 optimum_gen_infra-0.1.1/priv/templates/README.md.eex
-rw-r--r--  0 0      0         110 Nov 14 22:09 optimum_gen_infra-0.1.1/priv/templates/Makefile.eex
-rw-r--r--  0 0      0         111 Nov 14 22:09 optimum_gen_infra-0.1.1/priv/templates/.tool-versions.eex
-rw-r--r--  0 0      0         193 Nov 14 22:09 optimum_gen_infra-0.1.1/priv/templates/.sobelow-conf.eex
-rw-r--r--  0 0      0         133 Nov 14 22:09 optimum_gen_infra-0.1.1/priv/templates/.prettierrc.js.eex
-rw-r--r--  0 0      0         303 Nov 14 22:09 optimum_gen_infra-0.1.1/priv/templates/.prettierignore.eex
-rw-r--r--  0 0      0          22 Nov 14 22:09 optimum_gen_infra-0.1.1/priv/templates/.mise.toml.eex
-rw-r--r--  0 0      0       11749 Nov 14 22:09 optimum_gen_infra-0.1.1/priv/templates/.github/github_workflows.ex.eex
-rw-r--r--  0 0      0           0 Nov 14 22:09 optimum_gen_infra-0.1.1/priv/templates/.env.sample.eex
-rw-r--r--  0 0      0         335 Nov 14 22:09 optimum_gen_infra-0.1.1/priv/templates/.env.prod.sample.eex
-rw-r--r--  0 0      0           3 Nov 14 22:09 optimum_gen_infra-0.1.1/priv/templates/.dialyzer_ignore.exs.eex
-rw-r--r--  0 0      0        9079 Nov 14 22:09 optimum_gen_infra-0.1.1/priv/templates/.credo.exs.eex
-rw-r--r--  0 0      0          20 Nov 14 22:09 optimum_gen_infra-0.1.1/priv/plts/dialyzer.plt.hash
-rw-r--r--  0 0      0     3881457 Nov 14 22:09 optimum_gen_infra-0.1.1/priv/plts/dialyzer.plt
-rw-r--r--  0 0      0         366 Nov 14 22:09 optimum_gen_infra-0.1.1/ebin/optimum_gen_infra.app
-rw-r--r--  0 0      0       38116 Nov 14 22:09 optimum_gen_infra-0.1.1/ebin/Elixir.Mix.Tasks.Optimum.Gen.Infra.beam
-rw-r--r--  0 0      0           7 Nov 14 22:09 optimum_gen_infra-0.1.1/.elixir

and then installing the archive using mix archive.install optimum_gen_infra-0.1.1.ez

$ mix archive.install optimum_gen_infra-0.1.1.ez
Found existing entry: /Users/almirsarajcic/.local/share/mise/installs/elixir/1.17.3-otp-27/.mix/archives/optimum_gen_infra-0.1.1
Are you sure you want to replace it with "optimum_gen_infra-0.1.1.ez"? [Yn] Y
* creating /Users/almirsarajcic/.local/share/mise/installs/elixir/1.17.3-otp-27/.mix/archives/optimum_gen_infra-0.1.1
$ ls -a /Users/almirsarajcic/.local/share/mise/installs/elixir/1.17.3-otp-27/.mix/archives/optimum_gen_infra-0.1.1/optimum_gen_infra-0.1.1/priv/templates
.                        .env.sample.eex          .sobelow-conf.eex        fly.prod.toml.eex
..                       .github                  .tool-versions.eex       fly.toml.eex
.credo.exs.eex           .mise.toml.eex           Makefile.eex             lib
.dialyzer_ignore.exs.eex .prettierignore.eex      README.md.eex            rel
.env.prod.sample.eex     .prettierrc.js.eex       coveralls.json.eex       test

But this obviously doesn't work with Hex because the archive.build step is a part of the archive.install command and I can't do much about it from the user perspective.

$ mix archive.install hex optimum_gen_infra --repo acme
Resolving Hex dependencies...
Resolution completed in 0.004s
New:
  optimum_gen_infra 0.1.1
* Getting optimum_gen_infra (Hex package)
Checksum mismatch between registry and the cached package for optimum_gen_infra 0.1.1

Registry checksum: 299a91a2c4dc8f9fe9d8df1491fef2f12270338f97c3b193ac322cb62a0b1f53
Package checksum:  501dffa412a456f5e7baa7cfe2efce31872a968defb2d570c0b85c3a3e6df5e0

This may happen when the previously cached package got re-published, but it may also indicate a security issue so verify the new package.

Re-fetching...
All dependencies are up to date
Compiling 1 file (.ex)
Generated optimum_gen_infra app
Generated archive "optimum_gen_infra-0.1.1.ez" with MIX_ENV=prod
Found existing entry: /Users/almirsarajcic/.local/share/mise/installs/elixir/1.17.3-otp-27/.mix/archives/optimum_gen_infra-0.1.1
Are you sure you want to replace it with "optimum_gen_infra-0.1.1.ez"? [Yn] Y
* creating /Users/almirsarajcic/.local/share/mise/installs/elixir/1.17.3-otp-27/.mix/archives/optimum_gen_infra-0.1.1
$ ls -a /Users/almirsarajcic/.local/share/mise/installs/elixir/1.17.3-otp-27/.mix/archives/optimum_gen_infra-0.1.1/optimum_gen_infra-0.1.1/priv/templates
.                  Makefile.eex       coveralls.json.eex fly.toml.eex       rel
..                 README.md.eex      fly.prod.toml.eex  lib                test

I suspect it's because no flags are passed to the archive.build command here:

@impl true
def build(_install_spec, _opts) do
src = Mix.Local.name_for(:archives, Mix.Project.config())
previous = find_previous_versions(src)
Enum.each(previous, fn path ->
Code.delete_path(Mix.Local.archive_ebin(path))
end)
Mix.Task.run("archive.build", [])
src
end

Expected behavior

Dot files should be included in the installed archive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions