Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
barracuda156 opened this issue Feb 3, 2023 · 5 comments

Comments

@barracuda156
Copy link

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
Copy link
Member

ericmj commented Feb 4, 2023

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

@ericmj ericmj closed this as not planned Won't fix, can't repro, duplicate, stale Feb 4, 2023
@barracuda156
Copy link
Author

barracuda156 commented Feb 4, 2023

@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
Copy link
Member

ericmj commented Feb 4, 2023

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
Copy link
Author

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
Copy link
Member

ericmj commented Feb 4, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants