I’m trying to setup an automatic julia artifact download for brainflow. However I am encountering a .tar unpacking error. Let me elaborate.
Here is my script to generate the artifact in a folder with an Artifacts.toml folder:
using SHA
using Pkg
using Pkg.Artifacts
using Tar
url = "https://github.com/brainflow-dev/brainflow/releases/download/3.7.2/compiled_libs.tar"
download_path = "$(tempname())-download.tar"
download(url, download_path)
brainflow_hash = create_artifact() do artifact_dir
Tar.extract(download_path, artifact_dir)
end
artifact_name = "brainflow"
artifacts_toml = abspath(joinpath(@__DIR__, "Artifacts.toml"))
Pkg.Artifacts.bind_artifact!(artifacts_toml, artifact_name, brainflow_hash, force=true)
# now the artifact already works
brainflow_artifact_path = artifact"brainflow"
# adding the download info
function file_hash(path)
return open(path) do file
bytes2hex(sha2_256(file))
end
end
tar_hash_sha256 = file_hash(download_path)
Pkg.Artifacts.bind_artifact!(artifacts_toml, artifact_name, brainflow_hash; download_info=[(url, tar_hash_sha256)], force=true)
Now I remove the artifact and try to download it again, then I get an error:
julia> remove_artifact(brainflow_hash)
julia> brainflow_artifact_path = artifact"brainflow"
ERROR: Unable to automatically install 'brainflow' from 'C:\Users\matcox\Documents\Julia\Artifacts.toml'
Following this discourse discussion on Artifacts I tried to debug:
julia> download_artifact(brainflow_hash, url, tar_hash_sha256; verbose=true)
[ Info: No hash cache found
[ Info: Calculated hash 92bd7485de8ccbd19d27a9b203e8176806269415b1087c767bb36539efe063d9 for file C:\Users\matcox\AppData\Local\Temp\jl_A2FMwHFjeJ-download.tar
[ Info: Unpacking C:\Users\matcox\AppData\Local\Temp\jl_A2FMwHFjeJ-download.tar into C:\Users\matcox\.julia\artifacts\1681bc5c836c0465e02c42dce71db9572d723b6e...
false
So it goes wrong in unpack
:
Pkg.PlatformEngines.unpack(download_path, brainflow_artifact_path; verbose=verbose)
ERROR: Could not unpack C:\Users\matcox\AppData\Local\Temp\jl_PJRsMp1PNn-download.tar into C:\Users\matcox\.julia\artifacts\1681bc5c836c0465e02c42dce71db9572d723b6e
unpack calls a command like such:
julia> excludelist = nothing # I confirmed this was indeed set to nothing inside unpack()
julia> cmd = Pkg.PlatformEngines.gen_unpack_cmd(download_path, brainflow_artifact_path, excludelist)
julia> run(cmd)
ERROR: failed process: Process(`'C:\Users\matcox\AppData\Local\Programs\Julia-1.5.1\bin\..\libexec\7z.exe' x 'C:\Users\matcox\AppData\Local\Temp\jl_PJRsMp1PNn-download.tar' -y -so`, ProcessExited(2)) [2]
I tried typing this line on the command line
C:\>C:\Users\matcox\AppData\Local\Programs\Julia-1.5.1\bin\..\libexec\7z.exe x C:\Users\matcox\AppData\Local\Temp\jl_PJRsMp1PNn-download.tar -y
7-Zip 19.00 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2019-02-21
Scanning the drive for archives:
1 file, 36666880 bytes (35 MiB)
Extracting archive: C:\Users\matcox\AppData\Local\Temp\jl_PJRsMp1PNn-download.tar
--
Path = C:\Users\matcox\AppData\Local\Temp\jl_PJRsMp1PNn-download.tar
Type = tar
Physical Size = 36666880
Headers Size = 23040
Code Page = UTF-8
ERROR: Can not open output file : Access is denied. : .\BoardController.dll
ERROR: Can not open output file : Access is denied. : .\BoardController.lib
...
Now I’m stuck. Any help would be much appreciated. I’d really like to get automatic artifact deployment working.