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

Make release issue on Windows #1049

Open
saleyn opened this issue Feb 3, 2016 · 8 comments
Open

Make release issue on Windows #1049

saleyn opened this issue Feb 3, 2016 · 8 comments
Labels
bug dependency issue resides in a rebar3 dependency must reproduce TODO item for maintainers to confirm a bug or behaviour Windows platform-specific issue

Comments

@saleyn
Copy link
Contributor

saleyn commented Feb 3, 2016

Running rebar3 release on Windows with cygwin results in the following error:

$ ./rebar3 release
�[0;32m===> Verifying dependencies...
�[0mmake: Nothing to be done for 'all'.
�[0;32m===> Compiling mta
�[0m�[0;32m===> Compiling misc
�[0m�[0;32m===> Starting relx build process ...
�[0m�[0;32m===> Resolving OTP Applications from directories:
          d:/data/projects/mta/build/default/lib
          d:/data/projects/mta/apps
          c:/Program Files/erl7.1/lib
          d:/data/projects/mta/build/default/rel�[0m
�[0;35m===> Missing beam file elf_format <<"c:/Program Files/erl7.1/lib/hipe-3.13/ebin/elf_format.beam">>
�[0m�[0;32m===> Resolved mta-0.1
�[0m�[0;32m===> Dev mode enabled, release will be symlinked
�[0mCannot create a file when that file already exists.
Cannot create a file when that file already exists.
Cannot create a file when that file already exists.
Cannot create a file when that file already exists.
�[0;32m===> release successfully created!
�[0m�[0;31m===> Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace
�[0m�[0;32m===> When submitting a bug report, please include the output of `rebar3 report "your command"`
�[0m

I am not sure if the erl_format issue above is bogus.
The failing bit is in the overlay section which has:

{relx, [
    {overlay, [
        {link,     "apps/mta/etc/mta.test.config","{{output_dir}}/releases/{{rel_vsn}}/mta.test.config"}
...
]}.

The error below indicates that relx is failing with eperm though when creating the link by hand it works fine:
$ ln -s apps/mta/etc/mta.test.config build/default/rel/mta/releases/0.1/mta.test.config

�[0m�[0;31m===> Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace
�[0m�[0;36m===> Uncaught error: function_clause
�[0m�[0;36m===> Stack trace to the error location: [{rlx_prv_overlay,
                                                 format_error,
                                                 [{link_failed,
                                                   <<"d:/data/projects/mta/apps/mta/etc/mta.test.config">>,
                                                   <<"d:/data/projects/mta/build/default/rel/mta/releases/0.1/mta.test.config">>,
                                                   eperm}],
                                                 [{file,
                                                   "/home/travis/build/rebar/rebar3/_build/default/lib/relx/src/rlx_prv_overlay.erl"},
                                                  {line,72}]},
                                                {rlx_prv_overlay,
                                                 '-format_error/1-lc$^0/1-1-',
                                                 1,
                                                 [{file,
                                                   "/home/travis/build/rebar/rebar3/_build/default/lib/relx/src/rlx_prv_overlay.erl"},
                                                  {line,84}]},

Executing the same code in erlang by hand results in:

1> file:make_symlink("apps/mta/etc/mta.test.config", "build/default/rel/mta/releases/0.1/mta.test.config").
{error,eperm}

So, this works in cygwin's bash without issues, but fails when making file:make_symlink/2 call. Maybe a bug in this function that needs to be worked around by relx?

@ferd
Copy link
Collaborator

ferd commented Feb 3, 2016

What's the version of rebar3 you're using? THat sounds like an older one from the broken color codes I see.

@saleyn
Copy link
Contributor Author

saleyn commented Feb 3, 2016

My Windows Makefile is fetching it from "the official" pre-built location at amazonaws:

ifeq "$(REBAR)" ""
REBAR    := $(shell rm -f rebar3; wget -q https://s3.amazonaws.com/rebar3/rebar3; \
                            chmod a+x rebar3)$(wildcard ./rebar3)
endif

Here it is:

$ ./rebar3 version
rebar 3.0.0-beta.4+build.155.refa229a21 on Erlang/OTP 18 Erts 7.1

@ferd
Copy link
Collaborator

ferd commented Feb 3, 2016

So the error has to do with:

[{link_failed, <<"d:/data/projects/mta/apps/mta/etc/mta.test.config">>,  <<"d:/data/projects/mta/build/default/rel/mta/releases/0.1/mta.test.config">>, eperm}],

Seems to indicate issues with permissions on either of the paths mentioned. Are all of these readable and/or writeable where required?

@saleyn
Copy link
Contributor Author

saleyn commented Feb 3, 2016

Yes, as I've illustrated above, I am able to read/write to that location/file, and the link is created successfully when using ln -s in the cygwin's bash shell. The fact that this is Windows 10, I believe is irrelevant because it does support file linking (though mklink), and otherwise file:make_symlink/2 would have returned {error, enotsup} and it doesn't. This is likely the problem inside the file driver in erlang, though relx/rebar probably need to be aware of it and do some workaround.

Here's an example:

$ ln -s rebar3 rebar3.exe
$ ls -l rebar3*
-rwxrwxr-x+ 1 serge None 1129551 Feb  1 17:24 rebar3
lrwxrwxrwx  1 serge None       6 Feb  3 16:45 rebar3.exe -> rebar3
$ erl
Eshell V7.1  (abort with ^G)
1> file:make_symlink("rebar3", "rebar3.test.exe").
{error,eperm}

I also created a bug report here

@ferd ferd added Windows platform-specific issue bug labels Feb 3, 2016
@Taure
Copy link
Contributor

Taure commented Feb 4, 2016

Have you tried running it in Powershell?

I know I could do releases for some months ago with rebar3. Then I used Powershell and not cygwin.

@saleyn
Copy link
Contributor Author

saleyn commented Feb 4, 2016

Apparently, as Lukas found out, this is a Windows issue that it only allows to create symlinks when a user has a special privilege granted. Somehow cygwin's ln works around the issue:

D:\data\projects\mta>mklink mta.iml.link mta.iml
You do not have sufficient privilege to perform this operation.

D:\data\projects\mta>ln -s mta.iml mta.iml.link

D:\data\projects\mta>ls -l mta.iml*
-rwxrwxr--+ 1 serge None 767 Feb  3 11:27 mta.iml
lrwxrwxrwx  1 serge None   7 Feb  4 08:25 mta.iml.link -> mta.iml

Not sure if it's a feasible solution, but maybe relx could check on Windows if ln is available and use it instead of file:make_symlink/2 or perhaps in case of a link command to check if the user has SeCreateSymbolicLinkPrivilege set and produce a more meaningful error.

@ferd ferd added the dependency issue resides in a rebar3 dependency label Feb 4, 2016
@ferd
Copy link
Collaborator

ferd commented Feb 4, 2016

Yeah in rebar3 we have to shell out to create symlinks in windows: https://github.com/rebar/rebar3/blob/master/src/rebar_file_utils.erl#L67-L112

I've marked this bug as related to a dependency if the problem only happens with relx.

@emtenet
Copy link

emtenet commented May 1, 2016

I have done some work in erlware/relx#472 in relation to creating symlinks on Windows that may help with this issue. I did not look or test its usage for overlays.

@ferd ferd added the must reproduce TODO item for maintainers to confirm a bug or behaviour label Jun 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug dependency issue resides in a rebar3 dependency must reproduce TODO item for maintainers to confirm a bug or behaviour Windows platform-specific issue
Projects
None yet
Development

No branches or pull requests

4 participants