Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Symlink warning on Windows 10 #149

Closed
barche opened this issue Jan 23, 2019 · 10 comments
Closed

Symlink warning on Windows 10 #149

barche opened this issue Jan 23, 2019 · 10 comments

Comments

@barche
Copy link

barche commented Jan 23, 2019

When loading the package on Windows, the following warning appears:

julia> using BinaryProvider
 Warning: On Windows, creating file symlinks requires Administrator privileges

This can be traced back to this call:
https://github.com/JuliaPackaging/BinaryProvider.jl/blob/master/src/PlatformEngines.jl#L121

Full backtrace:

Stacktrace:
 [1] uv_error at .\libuv.jl:85 [inlined]
 [2] symlink(::String, ::String) at .\file.jl:797
 [3] probe_symlink_creation(::String) at C:\Users\bartj\.julia\packages\BinaryProvider\4F5Hq\src\PlatformEngines.jl:121
 [4] #probe_platform_engines!#30(::Bool, ::Function) at C:\Users\bartj\.julia\packages\BinaryProvider\4F5Hq\src\PlatformEngines.jl:175
 [5] probe_platform_engines! at C:\Users\bartj\.julia\packages\BinaryProvider\4F5Hq\src\PlatformEngines.jl:169 [inlined]
 [6] __init__() at C:\Users\bartj\.julia\packages\BinaryProvider\4F5Hq\src\BinaryProvider.jl:28
 [7] _include_from_serialized(::String, ::Array{Any,1}) at .\loading.jl:633
 [8] _require_search_from_serialized(::Base.PkgId, ::String) at .\loading.jl:713
 [9] _require(::Base.PkgId) at .\loading.jl:937
 [10] require(::Base.PkgId) at .\loading.jl:858
 [11] require(::Module, ::Symbol) at .\loading.jl:853
 [12] eval(::Module, ::Any) at .\boot.jl:328
 [13] eval_user_input(::Any, ::REPL.REPLBackend) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.1\REPL\src\REPL.jl:85
 [14] macro expansion at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.1\REPL\src\REPL.jl:117 [inlined]
 [15] (::getfield(REPL, Symbol("##26#27")){REPL.REPLBackend})() at .\task.jl:259

See also JuliaInterop/CxxWrap.jl#124

visr pushed a commit to visr/BinaryProvider.jl that referenced this issue May 10, 2019
* Invert installation checks

Allow binaries installed within the prefix to be used regardless of our
currently running platform.

* Include Top-Secret Arslanian Optimization Techniques

* Add a slightly more verbose comment
@hhaensel
Copy link
Contributor

I am not sure whether this is the right place to put it.
I am still wondering whether we could find an elegant way to circumvent symlink problems on windows.
I have started to write some lines that exclude the symlinks upon extraction and copy the sources of the symlinks instead. But I am a bit confused about the functor definitions and don't know how to integrate that. Perhaps someone else could jump in?

#demo directory
cd(joinpath(homedir(),".julia\\packages\\ImageMagick\\J74FC\\deps\\usr\\downloads\\"))
# get a technical listing of the file "libpng.v1.6.31.x86_64-w64-mingw32.tar.gz"
p = pipeline(`7z x "libpng.v1.6.31.x86_64-w64-mingw32.tar.gz" -y -so`, 
             `7z l -si -slt -y -ttar`)
o = read(p, String)

# retrieve links and their sources via a clever regex expression
mm = eachmatch(r"Path = ([^\r\n]+)\r?\n([^\r\n]+\r?\n)+Symbolic Link = ([^\r\n]+)"s, o)
symlinks = [m.captures[1] => joinpath(splitdir(m.captures[1])[1], m.captures[3]) for m in mm]

excludelist = join([s[1] for s in symlinks], "\n")
write("exclude.txt", excludelist)

#extract everything except symlinks to the folder "hhtest"
p = pipeline(`7z x "libpng.v1.6.31.x86_64-w64-mingw32.tar.gz" -y -so`, 
             `7z x -si -y -ttar [email protected] -ohhtest`)
o = read(p, String)

[isfile(joinpath("hhtest", s[2])) && cp(joinpath("hhtest", s[2]), joinpath("hhtest", s[1]), force = true) for s in symlinks]

rm("exclude.txt", force = true)

@hhaensel
Copy link
Contributor

I worked myself through now and got the code working.
I will make the code a bit nicer and submit a PR.

@hhaensel
Copy link
Contributor

As promised: PR163

@hhaensel
Copy link
Contributor

hhaensel commented Jun 13, 2019

The PR has been merged.

In order to suppress the above warning during probe_symlink_creation I propose the following.

    using Logging
    loglevel = Logging.min_enabled_level(current_logger())
    try
        disable_logging(Logging.Warn)
        symlink("foo", link_path)
        return true
    catch e
        if isa(e, Base.IOError)
            return false
        end
        rethrow(e)
    finally
        disable_logging(loglevel-1)
        rm(link_path; force=true)
    end

But I am not a hero in Logging.
Maybe, @staticfloat might comment whether this is a good idea?
I would then make a PR

@staticfloat
Copy link
Member

I'm not a hero in logging either, but this seems reasonable to me. Let's try it!

@hhaensel
Copy link
Contributor

I did file a #165 for this and I also included a slight modification to prevent test failure when testing products with isolate = true on Windows.

@hhaensel
Copy link
Contributor

I think, we can now close this (see #166)

@hhaensel
Copy link
Contributor

hhaensel commented Jul 3, 2019

@staticfloat this should be closed now as version 5.5 is out :-)

@staticfloat
Copy link
Member

Thanks @hhaensel! Really appreciate your help with improving Windows here!

@hhaensel
Copy link
Contributor

hhaensel commented Jul 6, 2019

I'm happy I could contribute, it's been a pleasure and and honor :-)

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

3 participants