compbiocore / VariantVisualization.jl

Julia package powering VIVA, our tool for visualization of genomic variation data. Manual:
https://compbiocore.github.io/VariantVisualization.jl/stable/
Other
85 stars 13 forks source link

Install fails due to insufficient permissions in /usr/local/bin #82

Open pikabika opened 4 years ago

pikabika commented 4 years ago

During install on linux an attempt is made to create a symbolic link in /usr/local/bin/ to the executable 'viva' which fails on multi-user systems where users do not have sudo privileges. This occurs in the deps/build.jl file It would be better for the installer to catch the permission error and just output a warning to the user instead of the whole install failing. Or perhaps create the link to the viva executable in the users home directory.

pikabika commented 4 years ago

Here is a possible fix for build.jl

path_ = get_executable_path("VariantVisualization", "viva")
symlink_user_bin(path_)

function get_executable_path(package::AbstractString, exec::AbstractString)
    base_path = Base.find_package(package)
    sep = joinpath("src", "$package.jl")
    exec_path = joinpath(split(base_path, sep)[1], exec)

    return exec_path
end

function symlink_user_bin(path_::AbstractString)
    exec = splitdir(path_)[end]
    if Sys.iswindows()
        bin_path = split(path_, "\\$exec")[1]
        @warn bin_path
        run(`setx path "%path%;$bin_path"`)
    else
        try
            ln = "/usr/local/bin/$exec"
            rm(ln, force=true)
            symlink(path_, ln)
            @warn "Created symlink: $ln -> $path_"

        catch err
            @warn "Error: failed to create link to $path_"
            hmd = homedir()
            rm("$hmd/$exec", force=true)
            symlink(path_, "$hmd/$exec")
            @warn "Created link at $hmd/$exec instead"
            @warn err
        end
    end
end

path_ = get_executable_path("VariantVisualization", "viva")
symlink_user_bin(path_)
gtollefson commented 4 years ago

@pikabika Thanks for your suggested fix - it could also help us address issue #84 . @fernandogelin what do you think about this?