Git Product home page Git Product logo

rebar_mix's Introduction

rebar_mix

A rebar plugin for building Elixir dependencies with mix.

Requirements:

  • rebar3 3.7.0 or above
  • Elixir 1.7.4 or above, unless your Elixir dependencies have no transitive compile time dependencies in which case any version starting with 1.7.0 may work.
  • mix local.hex, while mix hex isn't used, mix checks for it and will block with a message Could not find Hex, which is needed to build dependency ... if it isn't found. Running mix local.hex will install mix's hex script archive and make the check happy.

Use

Add the plugin to your rebar config:

{plugins, [rebar_mix]}.
{provider_hooks, [
  {post, [{compile, {mix, consolidate_protocols}}]}
]}.

The consolidate_protocols hook places beams in _build/<profile>/consolidated that will need to be included in a release when built. Using:

{overlay, [{copy, "{{base_dir}}/consolidated", "releases/{{release_version}}/consolidated"}]}

And update your vm.args.src to include:

-pa releases/${REL_VSN}/consolidated

rebar_mix's People

Contributors

ferd avatar filmor avatar maximvl avatar paulo-ferraz-oliveira avatar supersonido avatar tsloughter avatar vasu-dasari avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

rebar_mix's Issues

"rebar3 shell" fails with an error

I have a. rebar.config which looks like this:

{erl_opts, [debug_info]}.
{plugins, [
     {rebar_mix, ".*", {git, "https://github.com/tsloughter/rebar_mix.git", {branch, "master"}}}
]}.
{provider_hooks, [
    {pre,  [{compile, {mix, find_elixir_libs}}]},
    {post, [{compile, {mix, consolidate_protocols}}]}
]}.
{deps, [
    libcluster,
    {lager, {git, "https://github.com/basho/lager.git",     {tag, "3.2.1"}}}
]}.
{relx, [
    {release, { foo, "0.1.0" }, [
        foo
    ]},
    {sys_config, "./config/sys.config"},
    {vm_args, "./config/vm.args"}
]}.

And then I did rebar3 shell. This command successfully lands me at Erlang shell. But, when I try to use the shell with custom vm.args and sys.config, it returns in a error.

$ ERL_FLAGS=" -args_file config/vm.args -config config/sys.config" rebar3 shell
===> Verifying dependencies...
===> Compiling foo
===> Unable to run pre hooks for 'compile', command 'elixir_command_failed' in namespace 'rebar_mix_elixir_finder_hook' not found.

Is this a bug or should I be using different recipe to use rebar3 shell

Won't work with ` rebar3_path_deps`

Hey. Long story short trying to add elixir to erlang project. Iโ€™m trying add local elixir dependency to project. It kindly works. Problem is that every second run elixir part is not included.

Steps to reproduce:

$ rebar3 new app local_mix
$ cd local_mix
$ mix new ex_app

rebar.config:

{deps, [
    {ex_app, {path, "./ex_app"}}
  ]
}.

{shell, [
  % {config, "config/sys.config"},
    {apps, [local_mix]}
]}.

{plugins, [
    rebar3_path_deps,
    rebar_mix
]}.
  • rebar3 shell
  • 'Elixir.ExApp':hello(). - works
  • crtl-c
  • rebar3 shell
  • 'Elixir.ExApp':hello(). - undefined function

if you run rebar3 shell once again it will work :slight_smile:

Maybe there is other way to just include elixir files in rebar3 project?

Dependency in _checkouts directory does not work

The following config crashes rebar3 if the dependency is linked in _checkouts
because name is undefined in AppInfo.

{deps, [jason]}.

{plugins, [rebar_mix]}.
{provider_hooks, [
  {pre,  [{compile, {mix, find_elixir_libs}}]},
  {post, [{compile, {mix, consolidate_protocols}}]}
]}.

Using the latest rebar3 master.
rebar 3.12.0+build.4448.refe2ac3217 on Erlang/OTP 22 Erts 10.5

rebar_mix_hex needed?

Is the rebar_mix_hex module needed? It looks like it is doing the same as the regular rebar3 hex resource?

I see it adds some CDN option but that already exists in rebar3 so shouldn't exist twice.

Plugin doesn't work with upcoming Elixir v1.10

Environment

  • Elixir & Erlang/OTP versions (elixir --version): Elixir 1.10.0-dev (46f6ba5) (compiled with Erlang/OTP 22)
  • Operating system: Mac OS

Current behavior

Creating new application and using rebar_mix plugin for example to include jason library, like this in rebar.config:

{erl_opts, [debug_info]}.
{deps, [
         {jason, "1.1.2"}
]}.

{plugins, [rebar_mix]}.
{provider_hooks, [
  {pre,  [{compile, {mix, find_elixir_libs}}]},
  {post, [{compile, {mix, consolidate_protocols}}]}
]}.

{shell, [
    {apps, [mylib]}
]}.

Expected behavior

Jason compiled.

Jason compiles with Elixir v1.9, but with upcoming Elixir v1.10 it produces an error:

rebar3 shell
...
Generated decimal app
===> Failed to read required .app file for processing the application 'decimal': no such file or directory

Tracing back it is dependent on this change:

* [Mix.Project] Make sure `MIX_BUILD_PATH` specifies only the `build_path` prefix and that env+target are still concatenated

So probably this change could fix this:

https://github.com/Supersonido/rebar_mix/blob/master/src/rebar_mix_builder.erl#L14-L15

to:

{env, [{"MIX_BUILD_PATH", filename:join(AppDir, "../../../")},
    {"MIX_ENV", "default"}]}]) of

Or getting MIX_ENV from profiles (I see multiple profiles, but I don't know, which one to use).

Missing hook find_elixir_libs

I noticed that I can't use the current instructions with rebar_mix from hex.pm since find_elixir_libs was introduced in a later release. Maybe it's time for a new release Hex.pm release? =)

not downloading deps dependencies

i have about 6 hours of elixir/mix experience, which may ultimately be the problem.
but after much digging it looks like either a documentation or code error.
i'm trying to include an elixir app in my erlang project for the first time.
following the docs i have this rebar.config file, have tried each of the 3 plugins options,

%% -*- erlang -*-
{plugins, [
           {rebar_mix, ".*", {git, "https://github.com/Supersonido/rebar_mix", {branch, "master"}}}
%           {rebar_mix, ".*", {git, "https://github.com/starbelly/rebar_mix.git", {branch, "fixup-protocol-consolidation"}}}
%           rebar_mix
          ]}.

{provider_hooks, [
    {pre,  [{compile, {mix, find_elixir_libs}}]},
    {post, [{compile, {mix, consolidate_protocols}}]}
]}.

{deps,[{swarm, ".*", {git, "https://github.com/bitwalker/swarm", {tag, "master"}}}]}.

am running these versions:

iex -v
Erlang/OTP 21 [erts-10.3] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [hipe]
IEx 1.10.3 (compiled with Erlang/OTP 21)

mix -v
Erlang/OTP 21 [erts-10.3] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [hipe]
Mix 1.10.3 (compiled with Erlang/OTP 21)

erl
Erlang/OTP 21 [erts-10.3] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [hipe]
Eshell V10.3  (abort with ^G)

rebar3 -v
rebar 3.13.2 on Erlang/OTP 21 Erts 10.3

i can download this elixir dep separately and compile it with mix, but when i try to try to use rebar3 and this rebar_mix plugin it fails to download the swarm deps:

===> Fetching rebar_mix (from {git,"https://github.com/Supersonido/rebar_mix",
                     {branch,"master"}})
===> Compiling rebar_mix
===> Verifying dependencies...
===> Fetching swarm (from {git,"https://github.com/bitwalker/swarm",
                 {ref,"4aee63d83ad5ee6ee095b38b3ff93a4dbb7c3400"}})
===> Compiling swarm
Compiling 1 file (.erl)
Compiling 10 files (.ex)

== Compilation error in file lib/swarm/tracker/tracker.ex ==
** (CompileError) lib/swarm/tracker/tracker.ex:9: module GenStateMachine is not loaded and could not be found
    (elixir 1.10.3) expanding macro: Kernel.use/2
    lib/swarm/tracker/tracker.ex:9: Swarm.Tracker (module)
===> Failed to compile application swarm with mix

No valid version ([]) of .app file found

Hello guys,

OS: Mac OSX

Erlang/OTP 23 [erts-11.1.8] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [hipe] [dtrace]

IEx 1.11.3 (compiled with Erlang/OTP 23)

We're using rebar_mix to use Elixir dependencies inside our rebar3 project. There's a problem while generating a release

===> Compiling oauth
Consolidating 13 implementations of protocol Elixir.Jason.Encoder
===> [relup_helper] running gen_appups
===> Assembling release myapp...
===> Error generating release:
jason: No valid version ([]) of .app file found. Found file "/Users/YYYYYY/Programs/myapp/_build/myapp/rel/myapp/lib/jason-/ebin/jason.app" with version "1.2.2"


make: *** [myapp] Error 1

jason is the transitive dependency and added to the rebar.config deps

    {jason, {git, "[email protected]:michalmuskala/jason.git", {tag, "v1.2.2"}}}

Although, the next attempt seems to be solving it..

$ make
===> Compiling oauth
Consolidating 13 implementations of protocol Elixir.Jason.Encoder
===> [relup_helper] running gen_appups
===> Assembling release myapp...
===> Release successfully assembled: _build/myapp/rel/myapp

Not sure what's happening here.. Please let us know if you need more information !

Regards

rebar3 compile crash as init is expecting {error, string()}

rebar3 version 3.11.1
mix version 1.91.
using https://github.com/sqoring/rebar_mix_example

===> sh info:
        cwd: "c:/vagrant/ubuntu/tmp/rebar_mix_example"
        cmd: elixir -e ':code.get_path |> Enum.filter(fn(p) -> String.contains?(List.to_string(p), "/elixir/") end) |> Enum.map(&IO.puts/1)'

===>    opts: [{env,[{"ERL_FLAGS",[]}]},
               {return_on_error,true},
               {use_stdout,false}]

===> Port Cmd: cmd /q /c elixir -e ':code.get_path |> Enum.filter(fn(p) -> String.contains?(List.to_string(p), "/elixir/") end) |> Enum.map(&IO.puts/1)'
Port Opts: [{env,[{"ERL_FLAGS",[]}]},
            exit_status,
            {line,16384},
            use_stdio,stderr_to_stdout,hide,eof]

===> error: badarg [{erlang,'++',
                        [{rebar_mix_elixir_finder_hook,elixir_command_failed},
                         "~n"],
                        []},
                    {rebar_state,'-create_logic_providers/2-fun-0-',2,
                        [{file,"/opt/rebar3-3.11.1/src/rebar_state.erl"},
                         {line,481}]},
                    {lists,foldl,3,[{file,"lists.erl"},{line,1263}]},
                    {rebar_state,create_logic_providers,2,
                        [{file,"/opt/rebar3-3.11.1/src/rebar_state.erl"},
                         {line,478}]},
                    {rebar_plugins,'-handle_plugins/4-fun-0-',4,
                        [{file,"/opt/rebar3-3.11.1/src/rebar_plugins.erl"},
                         {line,101}]},
                    {lists,foldl,3,[{file,"lists.erl"},{line,1263}]},
                    {rebar_plugins,handle_plugins,4,
                        [{file,"/opt/rebar3-3.11.1/src/rebar_plugins.erl"},
                         {line,99}]},
                    {lists,foldl,3,[{file,"lists.erl"},{line,1263}]}]
===> Failed creating providers. Run with DEBUG=1 for stacktrace or consult rebar3.crashdump.

Not sure if this should be rebar3 issue https://github.com/erlang/rebar3/blob/3.11.1/src/rebar_state.erl#L481. Should format_error be called here ?

Plugin fails if Elixir lib dir contains spaces.

The detection uses IO.puts and removes spaces, which fails if e.g. under default Windows parameters, Elixir is installed under C:\Program Files. Using IO.write and not removing spaces would be the fix.

Could not compile phoenix based application

@tsloughter Could you please advise on the following. I am having a phoenix application: https://github.com/oltarasenko/live_view_counter and I want to package it inside my current erlang project (basic release application generated with rebar).

I have the following in my rebar.config:

{erl_opts, [debug_info]}.
{deps,[
       {poison, {git, "git://github.com/devinus/poison.git", {tag, "4.0.1"}}},
       {live_view_counter, {git, "[email protected]:oltarasenko/live_view_counter.git", {branch, "master"}}}
      ]}.


{relx, [{release, {myapp, "0.1.0"},
         [kernel,
          stdlib,
          sasl]},

        {deps,[
               {git, "[email protected]:devinus/poison.git"}
              ]},

        {sys_config, "./config/sys.config"},
        {vm_args, "./config/vm.args"},

        {dev_mode, true},
        {include_erts, true},

        {extended_start_script, true}]
}.

{profiles, [{dev, [{relx, [
                           {dev_mode, false},
                           {include_erts, true},
                           {deps,[
                                  {git, "[email protected]:devinus/poison.git"}
                                 ]}
                          ]
                   }]
            }]
}.

{overlay, [{copy, "{{base_dir}}/consolidated", "releases/{{release_version}}/consolidated"}]}.


{plugins, [rebar_mix]}.
{provider_hooks, [{post, [{compile, {mix, consolidate_protocols}}]}]}.

I am getting the following error on rebar3 release

rebar3 release
===> Verifying dependencies...
===> Compiling live_view_counter
** (Mix) The task "compile.phoenix" could not be found. Did you mean "compile.elixir"?
===> Failed to compile application live_view_counter with mix```

On a high level, it looks like we can't find phoenix specific tasks?

Can we remove features that rebar3 and hex_core already cover?

As part of 36617e3 some features were added that rebar3 and hex_core already cover :

  • src/rebar_mix_dep.erl
  • src/rebar_mix_hex.erl
  • some of what it's in src/rebar_mix_utils.erl

TL;DR is that rebar3 in conjunction with hex_core which ships with rebar3 handles downloading dependencies from hex, locking them, etc.

I feel this plugin would be best just to handle the compilation part, as it was doing prior to this merge.

How do you feel about removing these parts?

... has invalid version ~> Version_1 or ~> Version_2

Hi,

I am trying to use rebar3_mix, but when ich declare a dependency like
{timex, "~> 3.5"} rebar3 tries to download the dependencies from timex.

But the dependency of the timex package tzdata is declared in the mix.exs as {:tzdata, "~> 0.1.8 or ~> 0.5"} and I think rebar3 can't manage this.

compile fails with {:error, :no_beam_info} with elixir 1.10

mix new rebar_mix_test

rebar_mix_test$ cat rebar.config

{erl_opts, [debug_info]}.
{deps, [
        {jason, "1.2.0"}
       ]}.

{shell, [
    {apps, [rebar_mix_test]}
]}.

{plugins, [rebar_mix]}.
{provider_hooks, [
  {pre,  [{compile, {mix, find_elixir_libs}}]},
  {post, [{compile, {mix, consolidate_protocols}}]}
]}.

rebar_mix_test$ ./rebar3 shell

===> Verifying dependencies...
===> Fetching jason v1.2.0
===> Version cached at /home/dog/.cache/rebar3/hex/hexpm/packages/jason-1.2.0.tar is up to date, reusing it
===> Fetching decimal v1.8.1
===> Version cached at /home/dog/.cache/rebar3/hex/hexpm/packages/decimal-1.8.1.tar is up to date, reusing it
===> Compiling decimal
Compiling 1 file (.ex)
Generated decimal app
===> Compiling jason
Compiling 8 files (.ex)
Generated jason app
===> Compiling rebar_mix_test
Consolidating 13 implementations of protocol Elixir.Jason.Encoder
** (MatchError) no match of right hand side value: {:error, :no_beam_info}
    rebar_mix_protocol_consolidation.exs:14: anonymous fn/3 in :elixir_compiler_0.__FILE__/1
    (elixir 1.10.2) lib/enum.ex:783: Enum."-each/2-lists^foreach/1-0-"/2
    (elixir 1.10.2) lib/enum.ex:783: Enum.each/2
    (elixir 1.10.2) lib/enum.ex:783: Enum."-each/2-lists^foreach/1-0-"/2
    (elixir 1.10.2) lib/enum.ex:783: Enum.each/2
===> Unable to run post hooks for 'compile', command 'elixir_script_failed' in namespace 'rebar_mix_hook' not found.


This error happens with elixir 1.10.2.  Works with elixir 1.9.4

$ iex

Erlang/OTP 21 [erts-10.3.5.10] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Interactive Elixir (1.10.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> 

./rebar3 --version
rebar 3.13.1 on Erlang/OTP 21 Erts 10.3.5.10

Handling optional dependencies

Hi,

Does rebar_mix support optional packages?

Example: this package telemetry_metrics_riemann (https://hex.pm/packages/telemetry_metrics_riemann/0.2.0) has an optional package (https://hexdocs.pm/mix/Mix.Tasks.Deps.html#module-dependency-definition-options). According to https://github.com/hexpm/specifications/blob/master/dependency_resolution.md#dependency-resolution:

A package can define optional dependencies, an optional dependency should only resolve if the top-level project also depends on it.

Even though my toplevel project (https://github.com/joaohf/eclero/blob/metrics/rebar.config#L12) does not declare the 'riemanxx' package, rebar_mix is fetching that dependency (https://github.com/joaohf/eclero/blob/metrics/rebar.lock#L18).

Is possible to handle that using rebar_mix if yes, how we could add this feature to rebar_mix ?

Thanks

[bug] rebar_mix can not load eex, iex ...

Elixir Version: 1.13.3-otp-22
rebar_mix: 0.5.0 or 0.5.1

and I also add elixir in rebar.config, when I run rebar3 as test shell, and rp(code:get_path()). , will miss some elixir libs,only load the following libs:
"/home/tt_gao/.asdf/installs/elixir/1.13.3-otp-22/bin/../lib/elixir/../logger/ebin",
"/home/tt_gao/.asdf/installs/elixir/1.13.3-otp-22/bin/../lib/elixir/../mix/ebin",
"/home/tt_gao/.asdf/installs/elixir/1.13.3-otp-22/bin/../lib/elixir/../elixir/ebin",

and when I change into rebar_mix version as 0.4.0, it is ok, as following:
"/home/tt_gao/.asdf/installs/elixir/1.13.3-otp-22/bin/../lib/elixir/../eex/ebin",
"/home/tt_gao/.asdf/installs/elixir/1.13.3-otp-22/bin/../lib/elixir/../ex_unit/ebin",
"/home/tt_gao/.asdf/installs/elixir/1.13.3-otp-22/bin/../lib/elixir/../mix/ebin",
"/home/tt_gao/.asdf/installs/elixir/1.13.3-otp-22/bin/../lib/elixir/../logger/ebin",
"/home/tt_gao/.asdf/installs/elixir/1.13.3-otp-22/bin/../lib/elixir/../iex/ebin",
"/home/tt_gao/.asdf/installs/elixir/1.13.3-otp-22/bin/../lib/elixir/../elixir/ebin"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.