hexpm / hex

Package manager for the Erlang ecosystem.
https://hex.pm
978 stars 187 forks source link

(FunctionClauseError) no function clause matching in Mix.Local.Installer.parse_args/2 #979

Closed barracuda156 closed 1 year ago

barracuda156 commented 1 year ago

How to fix destroot for hex? It builds but fails to install.

Executing:  cd "/opt/local/var/macports/build/_opt_PPCRosettaPorts_erlang_hexpm/hexpm/work/hex-2.0.4" && /opt/local/bin/mix install DESTDIR=/opt/local/var/macports/build/_opt_PPCRosettaPorts_erlang_hexpm/hexpm/work/destroot 
Compiling 1 file (.xrl)
Compiling 14 files (.erl)
Compiling 81 files (.ex)
warning: Mix.ensure_application!/1 is undefined or private
  lib/hex/stdlib.ex:17: Hex.Stdlib.ssh_hostkey_fingerprint/2

Generated hex app
Generated archive "hex.ez" with MIX_ENV=dev
** (FunctionClauseError) no function clause matching in Mix.Local.Installer.parse_args/2    

    The following arguments were given to Mix.Local.Installer.parse_args/2:

        # 1
        ["hex.ez", "DESTDIR=/opt/local/var/macports/build/_opt_PPCRosettaPorts_erlang_hexpm/hexpm/work/destroot"]

        # 2
        [force: true]

    Attempted function clauses (showing 9 out of 9):

        def parse_args(-[]-, +_opts+)
        def parse_args(-[url_or_path]-, +_opts+)
        def parse_args(-["github" | rest]-, +opts+)
        def parse_args(-["git", url]-, +opts+)
        def parse_args(-["git", url, ref_type, ref]-, +opts+)
        def parse_args(-["git" | [_url | rest]]-, +_opts+)
        def parse_args(-["hex", package_name]-, +opts+)
        def parse_args(-["hex", package_name, version]-, +opts+)
        def parse_args(-["hex" | [_package_name | rest]]-, +_opts+)

    (mix 1.14.3) lib/mix/local/installer.ex:177: Mix.Local.Installer.parse_args/2
    (mix 1.14.3) lib/mix/local/installer.ex:54: Mix.Local.Installer.install/3
    (mix 1.14.3) lib/mix/task.ex:421: anonymous fn/3 in Mix.Task.run_task/4
    (mix 1.14.3) lib/mix/task.ex:479: Mix.Task.run_alias/6
    (mix 1.14.3) lib/mix/cli.ex:84: Mix.CLI.run_task/2
Command failed:  cd "/opt/local/var/macports/build/_opt_PPCRosettaPorts_erlang_hexpm/hexpm/work/hex-2.0.4" && /opt/local/bin/mix install DESTDIR=/opt/local/var/macports/build/_opt_PPCRosettaPorts_erlang_hexpm/hexpm/work/destroot 
Exit code: 1
ericmj commented 1 year ago

The mix install task is only supposed to be used for development and does not support any custom options.

The recommended way to install hex is using the mix local.hex that ships with Elixir and it will install hex in $HOME/.mix/archives or $MIX_HOME/archives.

If you wish to do a local build of Hex you can use mix archive.build with the -o flag to specify an output file path. But note mix will load archives from the archive directory location above.

You can also use mix archive.install to install archives.

You can find the documentation for these tasks here: https://hexdocs.pm/mix/Mix.Tasks.Local.Hex.html

barracuda156 commented 1 year ago

@ericmj Thank you for replying. I want to add hex to Macports, since it is needed to build an Elixir package. For that, we have to build it from source (either tarball or fetch from git branch) and install into destroot (installing directly will violate Macports prefix). In result, all files should be in /opt/local/* (Macports build system will move everything from ${destroot}${prefix} into ${prefix}).

Which option would be suitable for that?

ericmj commented 1 year ago

mix archive.build && MIX_HOME=/opt/local/... mix archive.install hex.ez would do that. You also need to set MIX_HOME before running any mix tasks that use Hex.

EDIT: Although I am not sure how that will work for other Macports users that have Elixir installed and expect MIX_HOME to be unset since other things will also be affected by that environment variable.

barracuda156 commented 1 year ago

EDIT: Although I am not sure how that will work for other Macports users that have Elixir installed and expect MIX_HOME to be unset since other things will also be affected by that environment variable.

Elixir itself is there in Macports (so presumably it will be installed via Macports), but Hex is not, presently. Then, making portfile for Hex, I will set it to depend on port:elixir, that will ensure that Macports’ Elixir is used (if another copy of Elixir is installed, it will be in the path that will not be searched, so hopefully no conflict arises).

ericmj commented 1 year ago

Actually, if you use MIX_ARCHIVES instead of MIX_HOME it should minimize the risk of conflicts since it is specifically for archives and has no other uses.