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

Wrong symlink to non-existent priv and include dirs on Windows #1173

Open
emtenet opened this issue May 1, 2016 · 8 comments
Open

Wrong symlink to non-existent priv and include dirs on Windows #1173

emtenet opened this issue May 1, 2016 · 8 comments
Labels
enhancement new behaviour or additional functionality help wanted unlikely to be tackled by core maintainers minor bug bug that does not prevent major features from working
Projects

Comments

@emtenet
Copy link

emtenet commented May 1, 2016

When app directories are copied into the _build directory symlinks are created to for the include, priv & source directories. https://github.com/erlang/rebar3/blob/master/src/rebar_prv_compile.erl#L204

If the source directory does not exist (for example apps/myapp/priv) then a "file" symlink is created rather than a "directory" symlink.

If the source directory is created in the future, the symlink is not usable as either a directory or a file.

This can be reproduced with:

> rebar3 new release myrel
> cd myrel
> rebar3 compile
> mkdir apps\myrel\priv
> dir _build\default\lib\myrel
<DIR> .rebar3
<DIR> ebin
<SYMLINK> include [c:/Source/Erlang/myrel/apps/myrel/include]
<SYMLINK> priv [c:/Source/Erlang/myrel/apps/myrel/priv]
<SYMLINKD> src [c:/Source/Erlang/myrel/apps/myrel/src]
> rebar3 release
===> Verifying dependencies...
===> Compiling myrel
===> Starting relx build process ...
===> Resolving OTP Applications from directories:
          c:/Source/Erlang/myrel/_build/default/lib
          c:/Source/Erlang/myrel/apps
          c:/Program Files/erl7.3/lib
===> error (eio) accessing file c:/Source/Erlang/myrel/_build/default/lib/myrel/priv

This behavior is on Windows, in a non-Administrator user account that has the SeCreateSymbolicLinkPrivilege

@emtenet
Copy link
Author

emtenet commented May 1, 2016

The decision to make a "file" symlink rather than a "directory" symlink is made in the erlang runtime. https://github.com/erlang/otp/blob/maint/erts/emulator/drivers/win32/win_efile.c#L2019-L2023

@emtenet
Copy link
Author

emtenet commented May 1, 2016

Perhaps rebar_file_utils:symlink_or_copy/2 could be split into two separate functions: symlink_or_copy_dir/2 and symlink_or_copy_file/2. (A quick search of rebar3 sources suggests that the second variation is not needed at this time)

symlink_or_copy_dir/2 could then check the existence of the source directory and use something other than file:make_symlink/2 such as rebar_file_utils:win32_symlink/2 (which creates a JUNCTION) or a SYMLINKD equivalent that uses the MKLINK /D option.

@emtenet
Copy link
Author

emtenet commented May 1, 2016

I have done some work in erlware/relx#472 relating to symlinks on Windows. These two projects seem to have shared common Windows symlink code in the past but have since received their own fixes to common problems.

@ferd
Copy link
Collaborator

ferd commented May 1, 2016

Ah, this probably explains the problems with #1171

@ferd ferd added the bug label May 1, 2016
@ferd ferd added enhancement new behaviour or additional functionality Windows platform-specific issue labels Aug 14, 2016
@Taure
Copy link
Contributor

Taure commented Sep 8, 2016

They share codes and if I remember right there was something that I tried to solve. And relx was using old copy for windows. Old copy have the 256 chars restriction in paths.

What I could see in relx issue was that there is a logic error. Will look into that. If you want I can try to give some of my ideas about this.

If I have time I can try to solve this.

@ferd
Copy link
Collaborator

ferd commented Oct 21, 2016

This issue has been reported as happening on OSX as well.

@ferd ferd added the help wanted unlikely to be tackled by core maintainers label Oct 21, 2016
@ferd ferd removed the Windows platform-specific issue label Jan 29, 2017
@talentdeficit
Copy link
Contributor

i believe the osx issue may be slightly different and may be caused by filelib:ensure_dir/1 failing to create a missing directory because of the existence of a symlink to a non-existent directory

@goertzenator
Copy link

The situation described by @talentdeficit is happening to me on linux.

@ferd ferd added minor bug bug that does not prevent major features from working and removed bug labels Jun 8, 2019
@tsloughter tsloughter added this to To do in Features Jan 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new behaviour or additional functionality help wanted unlikely to be tackled by core maintainers minor bug bug that does not prevent major features from working
Projects
Features
  
To do
Development

No branches or pull requests

5 participants