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

Generated schemas are stored in a full path inside the project folder #2325

Closed
WolfDan opened this issue May 28, 2017 · 23 comments
Closed

Generated schemas are stored in a full path inside the project folder #2325

WolfDan opened this issue May 28, 2017 · 23 comments
Labels

Comments

@WolfDan
Copy link

WolfDan commented May 28, 2017

Environment

  • Elixir version (elixir -v): 1.4.4
  • Phoenix version (mix deps): 1.3.0.rc.2
  • NodeJS version (node -v): -
  • NPM version (npm -v):-
  • Operating system: Microsoft Windows [Version 10.0.15063]

Expected behavior

Run the command and the files will be added on priv/repo/migrations

Actual behavior

When I run the command the migration files are in a full path inside the folder, the log when I run the command its:

C:\Users\********\Documents\Projects\********>mix phx.gen.schema Anime.Anime anime_animes mal_id:integer:unique image:string name:string ori_name:string category:integer episodes:integer status:integer launch:date end:date broadcast:naive_datetime source:integer duration:time premier_temp:integer premier_year:integer
* creating ./lib/********/anime/anime.ex
* creating Users/********/Documents/Projects/********/priv/repo/migrations/20170528020030_create_anime_anime.exs

Remember to update your repository by running migrations:

    $ mix ecto.migrate

The project folder result:
image

PD: of course when I run migration don't work tell me already up, but without tables, also I have unsinstalled and install again erlang/elixir

Greetings

@chrismccord
Copy link
Member

This must be windows specific and the way we expand or join paths together in schema.ex. Thanks for the report! If someone on windows wants to take a look at this one, that would be very helpful!

@WolfDan
Copy link
Author

WolfDan commented May 28, 2017

@chrismccord I found something that can be helpfull:

The versions 1.3.0.rc.0 and 1.3.0.rc.1 works normally, it create the file in the correct path without create the full path, when I update to 1.3.0.rc.2 it is bugged

Greetings

@josevalim
Copy link
Member

@WolfDan is it a regular app or is it an umbrella app?

@josevalim
Copy link
Member

Two addition questions:

  1. If you search for context_app: anywhere in your app. Can you find a place it is set? If so, to which value?

  2. If you start IEx inside your project and run File.cwd!, what does it return?

@WolfDan
Copy link
Author

WolfDan commented May 28, 2017

@josevalim I have a post in Elixir Forum with all the info, I was working with umbrella and don't work, the same with non umbrella (this post here)
Foum link

The aditional questions:

  1. There is not context_app: in the folder project (search with Atom and vs code)

  2. it returns "c:/Users/User/Documents/Projects/the_app_name"

@josevalim
Copy link
Member

@WolfDan I have pushed some changes to master, could you please give them a try locally? You need to clone Phoenix, go to the installer directory and then run the commands outlined here: https://github.com/phoenixframework/phoenix/tree/master/installer

Let me know if you have any questions.

@WolfDan
Copy link
Author

WolfDan commented May 28, 2017

@josevalim I have a problem with the "MIX_ENV=prod mix archive.build" command, it don't work on windows

@josevalim
Copy link
Member

I think on windows it is set MIX_ENV=prod mix archive.build?

@WolfDan
Copy link
Author

WolfDan commented May 28, 2017

@josevalim It's ok, but last command gives me an error:

C:\Users\******\Desktop\phoenix-master\installer>set MIX_ENV=prod mix archive.build

C:\Users\******\Desktop\phoenix-master\installer>mix archive.install
** (Mix) Expected an archive to exist in the current directory or an argument to be given.

Run:

    mix help archive.install

for more information.

C:\Users\******\Desktop\phoenix-master\installer>

@josevalim
Copy link
Member

Please try:

$ mix archive.build
$ mix archive.install

i.e. ignore the MIX_ENV=prod parts.

@WolfDan
Copy link
Author

WolfDan commented May 28, 2017

Gives and error, the result it's:

C:\Users\******\Desktop\phoenix-master\installer>mix archive.build
Compiling 12 files (.ex)
warning: redefining module Mix.Tasks.Local.Phx (current version loaded from c:/Users/******/.mix/archives/phx_new/phx_new/ebin/Elixir.Mix.Tasks.Local.Phx.beam)
  lib/mix/tasks/local.phx.ex:1

warning: redefining module Mix.Tasks.Phx.New.Ecto (current version loaded from c:/Users/******/.mix/archives/phx_new/phx_new/ebin/Elixir.Mix.Tasks.Phx.New.Ecto.beam)
  lib/mix/tasks/phx.new.ecto.ex:1

warning: redefining module Mix.Tasks.Local.Phoenix (current version loaded from c:/Users/******/.mix/archives/phoenix_new/phoenix_new/ebin/Elixir.Mix.Tasks.Local.Phoenix.beam)
  lib/mix/tasks/local.phoenix.ex:1

warning: redefining module Mix.Tasks.Phoenix.New (current version loaded from c:/Users/******/.mix/archives/phoenix_new/phoenix_new/ebin/Elixir.Mix.Tasks.Phoenix.New.beam)
  lib/mix/tasks/phoenix.new.ex:1

warning: redefining module Mix.Tasks.Phx.New.Web (current version loaded from c:/Users/******/.mix/archives/phx_new/phx_new/ebin/Elixir.Mix.Tasks.Phx.New.Web.beam)
  lib/mix/tasks/phx.new.web.ex:1

warning: redefining module Mix.Tasks.Phx.New (current version loaded from c:/Users/******/.mix/archives/phx_new/phx_new/ebin/Elixir.Mix.Tasks.Phx.New.beam)
  lib/mix/tasks/phx.new.ex:1

warning: redefining module Phx.New.Ecto (current version loaded from c:/Users/******/.mix/archives/phx_new/phx_new/ebin/Elixir.Phx.New.Ecto.beam)
  lib/phx_new/ecto.ex:1

warning: redefining module Phx.New.Generator (current version loaded from c:/Users/******/.mix/archives/phx_new/phx_new/ebin/Elixir.Phx.New.Generator.beam)
  lib/phx_new/generator.ex:1


== Compilation error on file lib/phx_new/ecto.ex ==
** (File.Error) could not read file "c:/Users/chris/oss/phoenix/installer/templates/phx_ecto/repo.ex": no such file or directory
    (elixir) lib/file.ex:244: File.read!/1
    lib/phx_new/generator.ex:28: Phx.New.Generator."-MACRO-__before_compile__/2-fun-0-"/3
    (elixir) lib/enum.ex:1755: Enum."-reduce/3-lists^foldl/2-0-"/3
    lib/phx_new/generator.ex:24: Phx.New.Generator."-MACRO-__before_compile__/2-fun-1-"/3
    (elixir) lib/enum.ex:1755: Enum."-reduce/3-lists^foldl/2-0-"/3
    expanding macro: Phx.New.Generator.__before_compile__/1
    lib/phx_new/ecto.ex:1: Phx.New.Ecto (module)


C:\Users\******\Desktop\phoenix-master\installer>mix archive.install
** (Mix) Expected an archive to exist in the current directory or an argument to be given.

Run:

    mix help archive.install

for more information.

C:\Users\******\Desktop\phoenix-master\installer>

@josevalim
Copy link
Member

Can you please use mix archive.uninstall phoenix_new or mix archive.uninstall phx_new and make sure the existing archive is uninstalled? Then you can do:

$ mix archive.build
$ mix archive.install

And this time it should work.

@WolfDan
Copy link
Author

WolfDan commented May 28, 2017

Youre right it works, but when I run any mix command I get this error:

C:\Users\******\Desktop\phoenix-master\installer\mal_api>mix ecto.create
** (Mix.Config.LoadError) could not load config config/prod mix archive.build.exs
    ** (File.Error) could not read file "c:/Users/******/Desktop/phoenix-master/installer/mal_api/config/prod mix archive.build.exs": no such file or directory
    (elixir) lib/file.ex:244: File.read!/1
    (mix) lib/mix/config.ex:180: Mix.Config.read!/2
    (mix) lib/mix/config.ex:217: anonymous fn/3 in Mix.Config.read_wildcard!/2
    (elixir) lib/enum.ex:1755: Enum."-reduce/3-lists^foldl/2-0-"/3
    (stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
    (stdlib) erl_eval.erl:878: :erl_eval.expr_list/6
    (stdlib) erl_eval.erl:404: :erl_eval.expr/5

@josevalim
Copy link
Member

josevalim commented May 28, 2017 via email

@WolfDan
Copy link
Author

WolfDan commented May 28, 2017

@josevalim now the mix commands works normally, but the bug persist, it create a full path of the migration inside the project folder

@josevalim
Copy link
Member

Awesome, thank you for reporting!

@WolfDan
Copy link
Author

WolfDan commented May 28, 2017

@josevalim I saw your post on elixir forum, so I create a VM with windows server 2016, the bug still present on it

@gemantzu
Copy link
Contributor

gemantzu commented May 29, 2017

I can verify that this is an issue on Windows for version 1.3.0.rc2
edit: After bulding and installing from master, the issue seems to be gone.

@pcmarks
Copy link

pcmarks commented Jun 22, 2017

This issue still seems to be a problem with Windows 7
Elixir 1.4.1

My steps:

  1. Cloned Phoenix
  2. Uninstalled current phx_new archive
  3. set MIX_ENV=prod
  4. mix archive.build
  5. mix archive.install

mix archive shows: phx_new-1.3.0-rc.2

And, as described in the original posting, there is a \Users\pcmarks\... folder under the _web folder.

@josevalim
Copy link
Member

We need someone using Windows to help us figure this out. If you have questions, please let us know. :)

@pcmarks
Copy link

pcmarks commented Jun 23, 2017

I think I found the source of this issue for Windows platforms.

In the Mix.Phoenix module, join_target_path() can be called with a target_file_path argument of "c:/Users/pcmarks/" This should match the first def of join_target_path() because the path is starting at the root. However, the characters "c;/" don't match and the second def is used.

If I'm correct, shall I fix it? I'm not sure I can get to it today, however.

Peter

@josevalim
Copy link
Member

Thank you @pcmarks! That makes total sense. I think we should use Path.expand, that takes care of this automatically for us. If you prefer, I can also fix it myself.

@pcmarks
Copy link

pcmarks commented Jun 23, 2017

Unfortunately, I don't think I can get to it until early next week. So, if you don't mind doing it...

Thanks!

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

No branches or pull requests

5 participants