Skip to content
This repository has been archived by the owner on Mar 10, 2021. It is now read-only.

thesis.install not working in Umbrella project #171

Open
rasputin243 opened this issue May 11, 2020 · 9 comments
Open

thesis.install not working in Umbrella project #171

rasputin243 opened this issue May 11, 2020 · 9 comments

Comments

@rasputin243
Copy link

I created a new umbrella project, and added Thesis to MY_APP_umbrella/apps/MY_APP/mix.ex.

When I mix thesis.install from the umbrella directory, I see an error about /priv/repo/migrations not existing. When I run mix thesis.install from the project directory, the migrations are added, but it cannot find ./config/config.ex (which is in the umbrella directory).

I was able to follow the README_INSTALL instructions to successfully install Thesis

@garland
Copy link

garland commented May 11, 2020

@rasputin243 is your umbrella application a Phoenix application?

@rasputin243
Copy link
Author

rasputin243 commented May 11, 2020 via email

@garland
Copy link

garland commented May 11, 2020

Can you share your top level mix.exs file?

@rasputin243
Copy link
Author

defmodule MyProj.Umbrella.MixProject do
  use Mix.Project

  def project do
    [
      apps_path: "apps",
      version: "0.1.0",
      start_permanent: Mix.env() == :prod,
      deps: deps(),
      aliases: aliases()
    ]
  end

  # Dependencies can be Hex packages:
  #
  #   {:mydep, "~> 0.3.0"}
  #
  # Or git/path repositories:
  #
  #   {:mydep, git: "https://github.com/elixir-lang/mydep.git", tag: "0.1.0"}
  #
  # Type "mix help deps" for more examples and options.
  #
  # Dependencies listed here are available only for this project
  # and cannot be accessed from applications inside the apps/ folder.
  defp deps do
    []
  end

  # Aliases are shortcuts or tasks specific to the current project.
  # For example, to install project dependencies and perform other setup tasks, run:
  #
  #     $ mix setup
  #
  # See the documentation for `Mix` for more info on aliases.
  #
  # Aliases listed here are available only for this project
  # and cannot be accessed from applications inside the apps/ folder.
  defp aliases do
    [
      # run `mix setup` in all child apps
      setup: ["cmd mix setup"]
    ]
  end
end

@rasputin243
Copy link
Author

This is the mix.exs from the app that uses Thesis

defmodule MyApp.MixProject do
  use Mix.Project

  def project do
    [
      app: :myapp,
      version: "0.1.0",
      build_path: "../../_build",
      config_path: "../../config/config.exs",
      deps_path: "../../deps",
      lockfile: "../../mix.lock",
      elixir: "~> 1.7",
      elixirc_paths: elixirc_paths(Mix.env()),
      start_permanent: Mix.env() == :prod,
      aliases: aliases(),
      deps: deps()
    ]
  end

  # Configuration for the OTP application.
  #
  # Type `mix help compile.app` for more information.
  def application do
    [
      mod: {MyApp.Application, []},

      extra_applications: [:logger, :runtime_tools, :thesis]
    ]
  end

  # Specifies which paths to compile per environment.
  defp elixirc_paths(:test), do: ["lib", "test/support"]
  defp elixirc_paths(_), do: ["lib"]

  # Specifies your project dependencies.
  #
  # Type `mix help deps` for examples and options.
  defp deps do
    [
      {:phoenix_pubsub, "~> 2.0"},
      {:ecto_sql, "~> 3.4"},
      {:postgrex, ">= 0.0.0"},
      {:jason, "~> 1.0"},
      {:thesis, "~> 0.3.4"}
    ]
  end

  # Aliases are shortcuts or tasks specific to the current project.
  #
  # See the documentation for `Mix` for more info on aliases.
  defp aliases do
    [
      setup: ["deps.get", "ecto.setup"],
      "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
      "ecto.reset": ["ecto.drop", "ecto.setup"],
      test: ["ecto.create --quiet", "ecto.migrate", "test"]
    ]
  end
end

@garland
Copy link

garland commented May 11, 2020

I can see that in the the mix.exs from "the app that uses Thesis", in your deps block, thesis is defined as {:thesis, "~> 0.3.4"}, but umbrella deps should be defined like: {:thesis, in_umbrella: true}]. Please try this alternative configuration and let me know how you go.

@rasputin243
Copy link
Author

I tried that alternative config but was not successful. I tried this on a new umbrella project (mix phx.new test --umbrella) and was able to get it working by adding :thesis to the umbrella project mix.exs, as described in the manual install instructions.

@rasputin243
Copy link
Author

Does the thesis.install task support umbrella projects? Based on the error log (described in issue) it seems that the task is expecting the directory structure of a non-umbrella app.

@garland
Copy link

garland commented May 11, 2020

Sorry I could not be of more assistance, I have not used this app in a while but I would suggest that you're more than likely spot on with your diagnosis. This seems to be a valid issue.

Specifically in thesis-phoenix/lib/mix/tasks/thesis.install.ex, in the thesis_templates/0 function the: Stream.map(&replace_yourapp(&1, to_string(Mix.Phoenix.otp_app))) # TODO: better way to infer app path?

It's getting a standard app path, not switching between whether it's an umbrella or not.

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

No branches or pull requests

2 participants