Fetch dependencies from hex.pm with Rebar3 for Erlang - erlang

I have added poison library to rebar.config file:
{
deps, [
poison
]
}.
But when I run rebar3 compile, it shows me an error:
===> Package <<"poison">> not found. Fetching registry updates and trying again...
...
===> Package not found in registry: <<"poison">>.
How do I make it work?

Related

Swift Package Manager failed to resolve dependencies: artifacts already exists in file system. fatalError

I have uploaded my binary artifacts in maven-central repository. I am fetching these libraries through SPM. I am getting the below error most of the times.
xcodebuild: error: Could not resolve package dependencies:
failed downloading which is required by binary target:
DerivedData/SourcePackages/artifacts/MyLib/MyLib.xcframework.zip already exists in file system. fatalError
My Swift package manifest targets as below:
targets: [
// ---- Binaries -----
.binaryTarget(
name: "MyLib",
url: "\(myPrivateArtefactURL)/MyLib.xcframework.zip",
checksum: "checksum"
)
]
However dependencies are getting resolved if I delete artficats folder manually and run the resolving dependencies command. I am not understanding what is the problem?. I want to get rid off this manually deleting the folder.

Compile error cmark Erlang Phoenix on Windows

I am trying to run a Phoenix server on Windows.
On running mix deps.get the following result is given
`Running dependency resolution
* Getting cmark (Hex package)
Checking package (https://repo.hex.pm/tarballs/cmark-0.6.10.tar)
Using locally cached package`
Then when running mix ecto.create the following error is given
`C:\Users\alex\Documents\Alex Docs\Datamo\githubrepo\datamo>mix ecto.create
===> Compiling idna
==> cmark
could not compile dependency :cmark, "mix compile" failed. You can recompile
this dependency with "mix deps.compile cmark", update it with
"mix deps.update cmark" or clean it with "mix deps.clean cmark"
** (ErlangError) erlang error: :enoent
(elixir) lib/system.ex:544: System.cmd("make", [], [stderr_to_stdout: true])
mix.exs:85: Mix.Tasks.Compile.Cmark.run/1
(mix) lib/mix/task.ex:296: Mix.Task.run_task/3
(elixir) lib/enum.ex:1184: Enum."-map/2-lists^map/1-0-"/2
(mix) lib/mix/tasks/compile.all.ex:19: anonymous fn/1 in
Mix.Tasks.Compile.All.run/1
(mix) lib/mix/tasks/compile.all.ex:37:
Mix.Tasks.Compile.All.with_logger_app/1
(mix) lib/mix/task.ex:296: Mix.Task.run_task/3
(mix) lib/mix/tasks/compile.ex:84: Mix.Tasks.Compile.run/1`
Attempting to run mix deps.compile cmark creates an error
`** (Mix) Cannot compile dependency :cmark because it isn't available, run "mix deps.get" first`
But that was already run in the first stage with the error shown above. It seems to be stuck in a loop.
Is this because it's unable to unpack the tar file on windows?

production env does not find OTP module :httpc when using exrm

I'm trying to create a release for my phoenix-framework project.
Everything is working fine, until my code need to do a specific action using :httpc module from OTP.
Apparently exrm, hasn't bundled the httpc module, and therefore could not find it.
I have tried to add it into my mix.exs application dependance, but as soon as I do, it will refuse to create a release due to an "error"
does anyone know how to fix this ?
For mix.env with :httpc as dependency :
$ MIX_ENV=prod mix release --verbosity=vebose
Building release with MIX_ENV=prod.
==> Generating relx configuration...
==> Generating sys.config...
==> Generating boot script...
==> Packaging consolidated protocols...
==> Generating release...
===> Starting relx build process ...
===> Resolving OTP Applications from directories:
/home/morgan/Documents/rateapi/_build/prod/lib
/home/morgan/Documents/rateapi/deps
/usr/local/lib/elixir/bin/../lib/eex/ebin
/usr/local/lib/elixir/bin/../lib/elixir/ebin
/usr/local/lib/elixir/bin/../lib/ex_unit/ebin
/usr/local/lib/elixir/bin/../lib/iex/ebin
/usr/local/lib/elixir/bin/../lib/logger/ebin
/usr/local/lib/elixir/bin/../lib/mix/ebin
/home/morgan/Documents/rateapi/lib
/usr/erlang/otp_R18B03/lib/erlang/lib
/home/morgan/Documents/rateapi/rel
==> ERROR: "Failed to build release. Please fix any errors and try again."
For mix.env without :httpc dependency :
** (exit) an exception was raised:
** (UndefinedFunctionError) function :httpc.request/4 is undefined (module :httpc is not available)
:httpc.request(:get, {'http://free.currencyconverterapi.com/api/v3/currencies', []}, [], [])
(fx_rates) web/controllers/rate_controller.ex:46: FxRates.V1.RateController.reload_currencies/0
(fx_rates) web/controllers/rate_controller.ex:66: FxRates.V1.RateController.show/2
(fx_rates) web/controllers/rate_controller.ex:1: FxRates.V1.RateController.action/2
(fx_rates) web/controllers/rate_controller.ex:1: FxRates.V1.RateController.phoenix_controller_pipeline/2
(fx_rates) lib/phoenix/router.ex:261: FxRates.Router.dispatch/2
(fx_rates) web/router.ex:1: FxRates.Router.do_call/2
(fx_rates) lib/fx_rates/endpoint.ex:1: FxRates.Endpoint.phoenix_pipeline/1
You may be missing the erlang-inets package. Try to install it or reinstall it again. If you are using Ubuntu you may install it with:
sudo apt-get install erlang-inets
Alternatively you may want to try adding the module :inets to your mix.exs application dependencies.

Why does rebar use my erl_opts to compile my deps?

I have a structure similar to the following:
rebar.config
deps/
apps/A/rebar.config
My top-level rebar.config file looks like the following:
{sub_dirs, ["apps/A"]}.
{lib_dirs, ["deps"]}.
A/rebar.config looks like the following:
{deps, [
%% deps
]}.
{erl_opts, [debug_info, warn_missing_spec, warnings_as_errors]}.
Now, one of my dependencies doesn't provide -spec for all of its functions, so the warnings_as_errors causes the compile to fail.
I was expecting the erl_opts to only affect my code, and for the dependencies to have their own options. Why does rebar do this?
It turns out that one of my dependencies doesn't have a rebar.config, so rebar is compiling it using my options.
What's confusing is that erl_opts is not set in the top-level rebar.config, but in a local rebar.config file. This is the file that has the deps clause.
It seems that the options are inherited "sideways" in this case.
I cannot reproduce this using the following version of rebar:
rebar 2.1.0-pre R15B03 20131210_073701 git 2.1.0-pre
On my local setup, using your same config (goldrush is my dependency):
...
==> goldrush (compile)
DEBUG: Matched required ERTS version: 5.9.3.1 -> .*
DEBUG: Matched required OTP release: R15B03 -> .*
DEBUG: Min OTP version unconfigured
DEBUG: erl_opts [debug_info,warn_export_all]
...
==> myapp (compile)
DEBUG: Matched required ERTS version: 5.9.3.1 -> .*
DEBUG: Matched required OTP release: R15B03 -> .*
DEBUG: Min OTP version unconfigured
DEBUG: erl_opts [debug_info,debug_info,warn_missing_spec,warnings_as_errors]
...
As you can see, the two applications receive two different sets of options.
Could you enable debugging and post the relevant output?
./rebar -vvv clean compile
What version of rebar/Erlang are you running?

How do you setup an Erlang NIF project with rebar?

I looked through the questions here on StackOverflow and Googled around for an example of setting up a Basic NIF project in rebar for wrapping a C++ library.
I used to library project on GitHub as a guide:
https://github.com/tuncer/re2
My project is here:
https://github.com/project-z/emutton/
When I do a rebar compile && rebar eunit, I get a failure in the eunit test because it cannot find emtn.so:
$ rebar compile && rebar eunit
==> emutton (compile)
==> emutton (eunit)
undefined
*** test module not found ***
**emtn
=ERROR REPORT==== 25-Jun-2013::12:21:55 ===
The on_load function for module emtn returned {error,
{load_failed,
"Failed to load NIF library: 'dlopen(/.../source/emutton/priv/emtn.so, 2): image not found'"}}
=======================================================
Failed: 0. Skipped: 0. Passed: 0.
One or more tests were cancelled.
ERROR: One or more eunit tests failed.
ERROR: eunit failed while processing /.../source/emutton: rebar_abort
When I call rebar compile, it is only producing a single driver file, emtn_drv.so and no emtn.so:
$ tree priv
priv
└── emtn_drv.so
0 directories, 1 file
I have an echo statement in c_src/build_deps.sh that I don't see output when I call rebar clean. It seems to behave as though my pre_hook and post_hook in rebar.config are completely ignored:
{pre_hooks, [{compile, "c_src/build_deps.sh"}]}.
{post_hooks, [{clean, "c_src/build_deps.sh clean"}]}.
Examples of no output shown from rebar:
$ rebar compile
==> emutton (compile)
$ rebar clean
==> emutton (clean)
Because I have cloned tuncer's RE2 bindings project and when I do a rebar compile see output from his build_deps.sh script. The permissions on mine match those on his:
-rwxr-xr-x 1 ajl staff 891B Jun 25 12:30 c_src/build_deps.sh
Any idea what I'm missing here? I believe that rebar is configured correctly to call out to the script and do the compilation.
Your problem is that the line in your rebar.config
https://github.com/project-z/emutton/blob/master/rebar.config%20#L1
Doesn't match what you attempt to load
https://github.com/project-z/emutton/blob/master/src/emtn.erl#L25
You should either change the rebar.config to
{port_specs, [{"priv/emtn.so",["c_src/emtn_nif.c"]}]}.
and change emtn.erl to
erlang:load_nif(filename:join(PrivDir, "emtn"), 0). % ?MODULE is an atom, I believe you need a string
Or change emtn.erl to
erlang:load_nif(filename:join(PrivDir, "emtn_drv"), 0).

Resources