Cannot build 0.7 system image in MacOS

I built the system image but it failed consistency check when I restart Julia, even though it said “System image successfully built”. MacOS. Anyone had success before and is there any advice? thanks

$ /Applications/Julia-0.7.app/Contents/Resources/julia/bin/julia 
ERROR: System image file failed consistency check: maybe opened the wrong version?

Build log:

julia> build_sysimg(force = true)
WARNING: Base.Libdl is deprecated, run `using Libdl` instead
 in module Main
in #4 at /Applications/Julia-0.7.app/Contents/Resources/julia/share/julia/build_sysimg.jl
WARNING: Base.Libdl is deprecated, run `using Libdl` instead
 in module Main
in #4 at /Applications/Julia-0.7.app/Contents/Resources/julia/share/julia/build_sysimg.jl
┌ Warning: `info()` is deprecated, use `@info` instead.
│   caller = (::getfield(Main, Symbol("##4#5")){Bool,String})() at build_sysimg.jl:74
└ @ Main build_sysimg.jl:74
INFO: Building basecompiler.o
┌ Warning: `info()` is deprecated, use `@info` instead.
│   caller = (::getfield(Main, Symbol("##4#5")){Bool,String})() at build_sysimg.jl:75
└ @ Main build_sysimg.jl:75
INFO: /Applications/Julia-0.7.app/Contents/Resources/julia/bin/julia -C native --output-ji /Applications/Julia-0.7.app/Contents/Resources/julia/lib/julia/basecompiler.ji --output-o /Applications/Julia-0.7.app/Contents/Resources/julia/lib/julia/basecompiler.o compiler/compiler.jl
essentials.jl
some.jl
ctypes.jl
generator.jl
reflection.jl
options.jl
promotion.jl
tuple.jl
pair.jl
traits.jl
range.jl
expr.jl
error.jl
bool.jl
number.jl
int.jl
operators.jl
pointer.jl
refvalue.jl
indices.jl
array.jl
abstractarray.jl
reduce.jl
bitarray.jl
bitset.jl
abstractdict.jl
abstractset.jl
iterators.jl
namedtuple.jl
docs/core.jl
subarray.jl
ordering.jl
sort.jl
compiler/utilities.jl
compiler/validation.jl
compiler/inferenceresult.jl
compiler/params.jl
compiler/inferencestate.jl
compiler/typeutils.jl
compiler/typelimits.jl
compiler/typelattice.jl
compiler/tfuncs.jl
compiler/abstractinterpretation.jl
compiler/typeinfer.jl
compiler/optimize.jl
compiler/ssair/driver.jl
compiler/ssair/ir.jl
compiler/ssair/domtree.jl
compiler/ssair/slot2ssa.jl
compiler/ssair/queries.jl
compiler/ssair/passes.jl
compiler/ssair/inlining2.jl
compiler/ssair/verify.jl
compiler/ssair/legacy.jl
compiler/bootstrap.jl
┌ Warning: `info()` is deprecated, use `@info` instead.
│   caller = (::getfield(Main, Symbol("##4#5")){Bool,String})() at build_sysimg.jl:79
└ @ Main build_sysimg.jl:79
INFO: Building sys.o
┌ Warning: `info()` is deprecated, use `@info` instead.
│   caller = (::getfield(Main, Symbol("##4#5")){Bool,String})() at build_sysimg.jl:80
└ @ Main build_sysimg.jl:80
INFO: /Applications/Julia-0.7.app/Contents/Resources/julia/bin/julia -C native --output-ji /Applications/Julia-0.7.app/Contents/Resources/julia/lib/julia/sys.ji --output-o /Applications/Julia-0.7.app/Contents/Resources/julia/lib/julia/sys.o -J /Applications/Julia-0.7.app/Contents/Resources/julia/lib/julia/basecompiler.ji --startup-file=no sysimg.jl
coreio.jl
exports.jl
essentials.jl
ctypes.jl
gcutils.jl
generator.jl
reflection.jl
options.jl
promotion.jl
tuple.jl
pair.jl
traits.jl
range.jl
expr.jl
error.jl
bool.jl
number.jl
int.jl
operators.jl
pointer.jl
refvalue.jl
refpointer.jl
checked.jl
indices.jl
array.jl
abstractarray.jl
subarray.jl
views.jl
reinterpretarray.jl
abstractdict.jl
iterators.jl
namedtuple.jl
hashing.jl
rounding.jl
float.jl
twiceprecision.jl
complex.jl
rational.jl
multinverses.jl
abstractarraymath.jl
arraymath.jl
simdloop.jl
reduce.jl
reshapedarray.jl
bitarray.jl
bitset.jl
some.jl
dict.jl
abstractset.jl
set.jl
char.jl
strings/basic.jl
strings/string.jl
build_h.jl
version_git.jl
osutils.jl
c.jl
io.jl
iostream.jl
iobuffer.jl
intfuncs.jl
strings/strings.jl
strings/substring.jl
strings/search.jl
strings/unicode.jl
strings/util.jl
strings/io.jl
parse.jl
shell.jl
regex.jl
pcre.jl
show.jl
arrayshow.jl
cartesian.jl
multidimensional.jl
permuteddimsarray.jl
broadcast.jl
missing.jl
version.jl
sysinfo.jl
libc.jl
env.jl
libuv.jl
uv_constants.jl
event.jl
task.jl
lock.jl
threads.jl
weakkeydict.jl
logging.jl
stream.jl
filesystem.jl
process.jl
grisu/grisu.jl
methodshow.jl
secretbuffer.jl
floatfuncs.jl
math.jl
reducedim.jl
accumulate.jl
ordering.jl
sort.jl
fastmath.jl
gmp.jl
mpfr.jl
combinatorics.jl
hashing2.jl
irrationals.jl
mathconstants.jl
printf.jl
meta.jl
Enums.jl
channels.jl
deepcopy.jl
download.jl
summarysize.jl
errorshow.jl
stacktraces.jl
initdefs.jl
statistics.jl
threadcall.jl
uuid.jl
loading.jl
util.jl
asyncmap.jl
multimedia.jl
deprecated.jl
docs/basedocs.jl
client.jl
docs/Docs.jl
Base  ─────────── 53.955055 seconds
Base64  ─────────  6.997107 seconds
CRC32c  ─────────  0.024181 seconds
SHA  ────────────  0.263260 seconds
FileWatching  ───  0.129545 seconds
Unicode  ────────  0.026007 seconds
Mmap  ───────────  0.102972 seconds
Serialization  ──  1.617725 seconds
Libdl  ──────────  0.050757 seconds
Markdown  ───────  2.071144 seconds
LibGit2  ────────  9.276232 seconds
Logging  ────────  2.403250 seconds
Sockets  ────────  3.835479 seconds
Printf  ─────────  0.088249 seconds
Profile  ────────  0.466091 seconds
Dates  ──────────  4.863493 seconds
DelimitedFiles  ─  2.883826 seconds
Random  ─────────  1.198052 seconds
UUIDs  ──────────  0.018731 seconds
Future  ─────────  0.012023 seconds
OldPkg  ─────────  5.375042 seconds
LinearAlgebra  ── 25.362887 seconds
SparseArrays  ───  8.735044 seconds
SuiteSparse  ────  2.689433 seconds
SharedArrays  ───  9.213928 seconds
Distributed  ────  1.727962 seconds
Pkg  ──────────── 46.066499 seconds
Test  ───────────  5.167110 seconds
REPL  ───────────  2.480134 seconds
Stdlibs total  ──146.276657 seconds
/Applications/Julia-0.7.app/Contents/Resources/julia/share/julia/base/precompile.jl
Sysimage built. Summary:
Total ─────── 233.649873 seconds 
Base: ───────  53.955055 seconds 23.0923%
Stdlibs: ──── 146.276657 seconds 62.6051%
Precompile: ─  33.412676 seconds 14.3003%

WARNING: Base.Libdl is deprecated, run `using Libdl` instead
 in module Main
WARNING: Base.Libdl is deprecated, run `using Libdl` instead
 in module Main
WARNING: Base.Libdl is deprecated, run `using Libdl` instead
 in module Main
WARNING: Base.Libdl is deprecated, run `using Libdl` instead
 in module Main
WARNING: Base.Libdl is deprecated, run `using Libdl` instead
 in module Main
WARNING: Base.Libdl is deprecated, run `using Libdl` instead
 in module Main
WARNING: Base.Libdl is deprecated, run `using Libdl` instead
 in module Main
WARNING: Base.Libdl is deprecated, run `using Libdl` instead
 in module Main
WARNING: Base.Libdl is deprecated, run `using Libdl` instead
 in module Main
WARNING: Base.Libdl is deprecated, run `using Libdl` instead
 in module Main
WARNING: Base.Libdl is deprecated, run `using Libdl` instead
 in module Main
WARNING: Base.Libdl is deprecated, run `using Libdl` instead
 in module Main
in link_sysimg at /Applications/Julia-0.7.app/Contents/Resources/julia/share/julia/build_sysimg.jl
WARNING: Base.Libdl is deprecated, run `using Libdl` instead
 in module Main
in link_sysimg at /Applications/Julia-0.7.app/Contents/Resources/julia/share/julia/build_sysimg.jl
WARNING: Base.Libdl is deprecated, run `using Libdl` instead
 in module Main
in link_sysimg at /Applications/Julia-0.7.app/Contents/Resources/julia/share/julia/build_sysimg.jl
┌ Warning: `info()` is deprecated, use `@info` instead.
│   caller = link_sysimg(::String, ::String, ::Bool) at build_sysimg.jl:168
└ @ Main build_sysimg.jl:168
INFO: Linking sys.dylib
┌ Warning: `info()` is deprecated, use `@info` instead.
│   caller = link_sysimg(::String, ::String, ::Bool) at build_sysimg.jl:169
└ @ Main build_sysimg.jl:169
INFO: cc -L/Applications/Julia-0.7.app/Contents/Resources/julia/lib -shared -ljulia -o /Applications/Julia-0.7.app/Contents/Resources/julia/lib/julia/sys.dylib /Applications/Julia-0.7.app/Contents/Resources/julia/lib/julia/sys.o
┌ Warning: `info()` is deprecated, use `@info` instead.
│   caller = link_sysimg(::String, ::String, ::Bool) at build_sysimg.jl:179
└ @ Main build_sysimg.jl:179
INFO: System image successfully built at /Applications/Julia-0.7.app/Contents/Resources/julia/lib/julia/sys.dylib
┌ Warning: `info()` is deprecated, use `@info` instead.
│   caller = (::getfield(Main, Symbol("##4#5")){Bool,String})() at build_sysimg.jl:98
└ @ Main build_sysimg.jl:98
INFO: Julia will automatically load this system image at next startup.

There is an issue on this, with a fix in progress. But apparently what the developers would like us to do now is

using PackageCompiler
build_sysimg(...)

Mmm… couldn’t get PackageCompiler to work though:

julia> using PackageCompiler
[ Info: Precompiling module PackageCompiler
ERROR: LoadError: ArgumentError: Package PackageCompiler does not have Sys in its dependencies:
 - If you have PackageCompiler checked out for development and have
   added Sys as a dependency but haven't updated your primary
   environment's manifest file, try `Pkg.resolve()`.
 - Otherwise you may need to report an issue with PackageCompiler.

Stacktrace:
 [1] require(::Module, ::Symbol) at ./loading.jl:862
 [2] top-level scope at /Users/tomkwong/.julia/packages/PackageCompiler/QqA5/src/PackageCompiler.jl:9
 [3] include at ./boot.jl:317 [inlined]
 [4] include_relative(::Module, ::String) at ./loading.jl:1075
 [5] include(::Module, ::String) at ./sysimg.jl:29
 [6] top-level scope at none:0
 [7] eval at ./boot.jl:319 [inlined]
 [8] eval(::Expr) at ./client.jl:394
 [9] top-level scope at ./none:3 [inlined]
 [10] top-level scope at ./<missing>:0
in expression starting at /Users/tomkwong/.julia/packages/PackageCompiler/QqA5/src/PackageCompiler.jl:7
ERROR: Failed to precompile PackageCompiler to /Users/tomkwong/.julia/compiled/v0.7/PackageCompiler/MMV8.ji.
Stacktrace:
 [1] error at ./error.jl:33 [inlined]
 [2] compilecache(::Base.PkgId) at ./loading.jl:1205
 [3] _require(::Base.PkgId) at ./loading.jl:1007
 [4] require(::Base.PkgId) at ./loading.jl:879
 [5] require(::Module, ::Symbol) at ./loading.jl:874

That’s nasty, and I don’t know how to fix it. (Sys is in Base, so that should not happen.)

Meanwhile, what looks to be a fixed version of the old script (from the PR I alluded to above) is
here

That works, thanks!

P.S. …although the new sys img is making my program 10x slower than 0.6… investigation to be continued…

I could load PackageCompiler (master branch) with no problem on 0.7.