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

(ArgumentError) could not fetch application environment :globals for application :soap because configuration :globals was not set #88

Open
ismailunal opened this issue Dec 20, 2020 · 5 comments

Comments

@ismailunal
Copy link

Hi there,

With Elixir 1.9.1 I couldn't go further instead I receive this error: "(ArgumentError) could not fetch application environment :globals for application :soap because configuration :globals was not set"

I tried creating a config/config.exs

import Config

config :soap, :globals, version: "1.1"

import_config "#{config_env()}.exs"

And mix.exs file is as follows;

defmodule Countryinfoserv.MixProject do
  use Mix.Project

  def project do
    [
      app: :countryinfoserv,
      version: "0.1.0",
      elixir: "~> 1.9",
      start_permanent: Mix.env() == :prod,
      deps: deps()
    ]
  end

  # Run "mix help compile.app" to learn about applications.
  def application do
    [
      extra_applications: [:logger, :soap]
    ]
  end

  # Run "mix help deps" to learn about dependencies.
  defp deps do
    [
      # {:dep_from_hexpm, "~> 0.3.0"},
      # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}
      {:soap, "~> 1.0"}
    ]
  end
end

@Nitrino
Copy link
Member

Nitrino commented Dec 20, 2020

You don't need to add soap to extra_applications

@ismailunal
Copy link
Author

Hi, thanks for your response. It didn't make any difference unfortunately.

@ismailunal
Copy link
Author

So, if anybody can help this is the full text of the error;

** (ArgumentError) could not fetch application environment :globals for application :soap because configuration :globals was not set
(elixir) lib/application.ex:493: Application.fetch_env!/2
(soap) lib/soap/wsdl.ex:217: Soap.Wsdl.soap_version/0
(soap) lib/soap/wsdl.ex:218: Soap.Wsdl.soap_version/1
(soap) lib/soap/wsdl.ex:198: Soap.Wsdl.get_soap_namespace/2
(soap) lib/soap/wsdl.ex:29: Soap.Wsdl.parse/3

@fmbraga
Copy link

fmbraga commented Dec 14, 2021

Hi,

You need to define :config_path in your project.

Something like this:

def project do
    [
      app: :ssl_demo_01,
      version: "0.1.0",
      elixir: "~> 1.13",
      config_path: "config/config.exs",
      start_permanent: Mix.env() == :prod,
      deps: deps()
    ]
  end

@waseigo
Copy link

waseigo commented Mar 7, 2023

This is an unnecessary complication. For one, libraries apparently should not utilize application configuration.

Secondly, in the absence of such an entry, soap_version/0 of line 108 in parser.ex could first check if something is defined before using Application.fetch_env! and fallback to version 1.1 if not.

waseigo added a commit to waseigo/soap that referenced this issue Mar 7, 2023
In partial response to [issue 88](elixir-soap#88), I noticed that Soap fails completely if my application does not define `config :soap, :globals` in its `config/config.exs`, even though a) HTTPoison is the default client and b) version 1.1 is claimed in the documentation to be the default.

Applications using a dependency that itself depends on Soap should not need to add anything to their `config/config.exs`, especially if what is expected to be defined therein has a sane default value (version 1.1, and HTTPoison), I redefined `soap_version/0` to first see if it can fetch its configuration; if not, it gracefully returns the (default, according to the docs) version 1.1.

Note that the test suite of Soap still assumes that `config/config.exs` contains a configuration. Removing these lines from it makes tests fail. It might be a good idea to get rid of this caveat entirely, and follow the official recommendation to [avoid application configuration for libraries](https://hexdocs.pm/elixir/library-guidelines.html#avoid-application-configuration).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants