# Julia Client – Internal Error: Julia stopped if running codes in script rather than REPL

**URL:** <https://discourse.julialang.org/t/julia-client-internal-error-julia-stopped-if-running-codes-in-script-rather-than-repl/35087>\
**Category:** General Usage\
**Tags:** question\
**Created:** [February 24, 2020, 7:54pm UTC](https://discourse.julialang.org/t/julia-client-internal-error-julia-stopped-if-running-codes-in-script-rather-than-repl/35087 "2020-02-24T19:54:51Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![1634](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/1634/32/12119_2.png) [@1634](https://discourse.julialang.org/u/1634)\
**Post date:** [February 24, 2020, 7:54pm UTC](https://discourse.julialang.org/t/julia-client-internal-error-julia-stopped-if-running-codes-in-script-rather-than-repl/35087/1 "2020-02-24T19:54:51Z")

</div>

After starting Julia by Enter, any code pasted from script to REPL is running well. However, directly running the codes in script (by Ctrl+Enter) leads to stop Julia every time and report the Internal Error:

```julia
Julia Client – Internal Error
TypeError: non-boolean (Nothing) used in boolean context

hideprompt(::Atom.var"#184#188"{String,Int64,String,Bool}) at repl.jl:126

macro expansion at eval.jl:71 [inlined]

macro expansion at dynamic.jl:24 [inlined]

eval(::String, ::Int64, ::String, ::String, ::Bool) at eval.jl:67

(::Atom.var"#182#183")(::Dict{String,Any}) at eval.jl:62

handlemsg(::Dict{String,Any}, ::Dict{String,Any}) at comm.jl:166

(::Atom.var"#19#21"{Array{Any,1}})() at task.jl:333

```

This error has emerged just after I ran a function printing e.g. 1.77798…e303 (this is due to bugs I am still working on), which shocked me for not overwhelming the memory. And now appreciated luck come with later cost. Could anyone give a hint (I already reboost my laptop and atom many times but the error is the same)?

---

<div class="post-metadata">

**Author:** ![ssfrr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ssfrr/32/3736_2.png) [@ssfrr](https://discourse.julialang.org/u/ssfrr)\
**Post date:** [February 24, 2020, 8:05pm UTC](https://discourse.julialang.org/t/julia-client-internal-error-julia-stopped-if-running-codes-in-script-rather-than-repl/35087/2 "2020-02-24T20:05:10Z")

</div>

Looks like some code you’re running has a `nothing` in it where it’s not expected. I think to help any further you’d need to post the code that generates the error (preferably in a form that’s easily runnable for others so they can reproduce the issue you’re seeing.

---

<div class="post-metadata">

**Author:** ![1634](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/1634/32/12119_2.png) [@1634](https://discourse.julialang.org/u/1634)\
**Post date:** [February 24, 2020, 8:35pm UTC](https://discourse.julialang.org/t/julia-client-internal-error-julia-stopped-if-running-codes-in-script-rather-than-repl/35087/3 "2020-02-24T20:35:58Z")

</div>

Here’ s the MWE. Hopefully it won’t bring trouble to others’ laptop 😢

```julia
#minimum working example
using Distributions #Multinomial()
using Random #Multinomial()
using PoissonRandom #pois_rand
using LazyArrays #ApplyArray(vcat,)

#For test the function
Nmax=5.5e7
Nmin=5.5e6
D= gaussian_1d_localmig3(Nmax,Nmin,1,0.1,5e-5,5) #8 seconds
# plot(D[2]',yscale=:log10,ylims=(1e-3,1),legend=false)
# savefig("..\\photo\\oscipopu_without migration")

function gaussian_1d_localmig3(Nmax, Nmin,twoNmu,s0,mig,nDemes)

    T=200
    ## Preallocating dataframes
    migCell=Array{Array{Float64,1},1}(undef,nDemes) # stores how many migrants per deme
                               #one column is enough
    migLR=Array{Array{Float64,2},1}(undef,nDemes) #left right migration amount
    D=Array{Array{Float64,2},1}(undef,nDemes)#deme cell array - each with their own frequency array
    x = zeros(1,T+1)
    x[end,1] = 1 #Initial frequency array of the wt (no mutants present yet)

    for i in 1:nDemes # populate deme cell array with initial wt-frequency of 1 @ T= 0
        D[i] = x
    end

    #enable input s0, mig instead of population-scaled parameter twoNs, twoNmig
    N=2(Nmax^(-1)+Nmin^(-1))^-1
    twoNs=s0*N*2
    twoNmig=mig*N*2

 for t in 2:T+1 #Generations #T+1
    println("generation############",t)
    prd=12 #a period of 12 generation
    NDeme=0.5(Nmax+Nmin)+0.5(Nmax+Nmin)*sin(2pi*t/prd) #oscillating population size

    if NDeme==0 #usually in (9+12n) generation
        NDeme=200 #to avoid casuing NANs after being dividing NDeme
    end
    NDeme=round(Int,NDeme)
    println("oscillating NDeme ", NDeme)

    ## Population Parameters
    mu = twoNmu/2/NDeme/nDemes # mutation coefficient
    s0 = twoNs/2/NDeme/nDemes #selection coefficient, s_ to avoid name crash with s in Julia
    mig = twoNmig/2/NDeme/nDemes # dispersal rate

     for i in 1:nDemes
        println("deme#####", i)

        x=D[i]
        nan=findall(isnan,x)
        println("nan in x_beginning of Selection ",nan) #check the input at the beginning
        if !isempty(nan)
            println("x ",D[i][:,t-1])
        end

       ## Filling up the frequency array
        ##Selection

        ##Selection, genetic drift
        xwt = x[end,t-1] #wild type frequency at t-1
        X = x[1:end-1,t-1] # mutant frequencies at t-1
        ss=xwt*s0 #selection modification
        xx=X+ss*X

        xx[xx.<0].=0
        xxK = 1-sum(xx) #Frequency of wild type (wt is the Kth allele)

        if xxK < 0 # in case wild type frequency is negative
            xxK = 0 # set wt frequency to 0
            xx = xx/sum(xx) #resets all mutant frequencies to sum to 1
        end

        ## Genetic drift
        println("NDeme",NDeme)
        n = rand(Multinomial(Int(NDeme),[xx;xxK])) #Multinomial random numbers
        z=n/NDeme
        x[:,t] = z #n outputed in individuals
        D[i]=x

        nan=findall(isnan,x)
        println("nan in x_end of drift ",nan)
        #[3:7,9], problem in frequency vector in 9th generation
        if !isempty(nan)
            println("x ",D[i][:,t])
        end

        ##Mutation
        xwt = x[end,t] #wild type frequency at t-1
        m = pois_rand(NDeme*mu*xwt) #number of de novo mutants generated

        if m != 0 # with >= mutant alleles generated
            xN = zeros(m,T+1) #rows of new mutant alleles
            for f in 1:nDemes #add xN to all demes
                x = D[f]
                x=ApplyArray(vcat,xN,x) #new mutant piled on top
                if f==i #frequency of the deme that mutant emerged as 1/NDeme
                    x[1:m,t] .= 1/NDeme # 1 individual arising per mutant seeding into above array
                    x[end,t] = x[end,t] - m/NDeme
                end
                D[f]=x
            end
        end

        # x=D[i]#x still in this module
        nan=findall(isnan,x)
        println("nan_end of mutation ",nan)

        #[3:7,9], problem in frequency vector in 9th generation
        if !isempty(nan)
            println("x ",D[i][:,t])
        end

    end # for i in 1:nDemes

    D = NDeme*D #frequency=>individuals

    ##Migration
    ## Determining the number of migrants leaving the demes
    for i in 1:nDemes
        n_i = D[i] #extract from cell array, multi-step=>better computational efficiency
        n_B = n_i[:,t] #frequency column in t generation, i-th deme
        println("n_B _before MIG",n_B)
        MIG = mig*n_B #expected number of migrants individuals #column vec
        migLV = pois_rand.(MIG) #actual number of migrants

                          #Before leaving in migration
                          #column vector
        for g in 1:length(n_B) # poisson may generate>there is=>negative frequency
            #"migCell[i] = poissrnd(MIG)' #actual number of migrants"--line111
            if migLV[g] > n_B[g] # looks for negative values and sets to zero
                println("migLV[g] ", migLV[g])
                println("n_B[g] ", n_B[g])
                migLV[g] = trunc(n_B[g]) #both float vector
            end
        end

        n_lv = n_B - migLV #after leaving; both column vector
        n_i[:,t] = n_lv # storing population after migrants leave in
        # println("migration_leaving_size(n_lv)",size(n_lv))
        D[i] = n_i # stores "frequency" array back in to deme cell array

        migCell[i] = migLV # leaving array! not left-right array (migLR)
        # println("migLV ", migLV)

        nan=findall(isnan,migLV)
        println("nan_end of migLV ",nan)#NaN in which column=>which generation

    end

        ## Determining if migrants move left or right
    for i in 1:nDemes
        c = size(migCell[i])[1] #c=column number, registers size of migrant
        #array to preallocate size of migLR_i array
        migLR_i = Int.(zeros(c,2)) #column 1 amount going left, 2 going right
        tot_mig = migCell[i] #total: left+right
        # println("tot_mig ", " max " maximum(tot_mig)," type ",typeof(tot_mig))
        tot_mig = Int.(tot_mig)
        if i == 1 #first deme
            # println("first_size",size(tot_mig))
            migLR_i[:,2] = tot_mig # left end, only toward right
            migLR[i] = migLR_i
        elseif i == nDemes #last deme
            # println("last_size", size(tot_mig))
            migLR_i[:,1] = tot_mig # right end, only toward left
            migLR[i] = migLR_i
        else # middle demes
            # migLR_i(1,:) = binornd(tot_mig,0.5);
            # println("middle_size", size(tot_mig))
            # println("mig")
            # println("middle_size",size(tot_mig))
            migLR_i[:,1] = rand.(Binomial.(tot_mig,0.5))#toward left
                            #two elemetwise dot is needed
            migLR_i[:,2] = tot_mig - migLR_i[:,1] #toward right
            migLR[i] = migLR_i
        end

        nan=findall(isnan,migLR[i])
        println("nan position_end of migLR ",nan)#NaN in which column=>which generation
        #[3:7,9], problem in frequency vector in 9th generation

    end
    #migLR: column1 column2
    #leaving: toward left toward right
    #entering: fr Right fr Left

    ## Accounting for migrants entering in the "frequency" array, D
    for i in 1:nDemes
        if i == 1 # for first deme
            n_i = D[i] # n before accounting for entering migrants
            n_B = n_i[:,t]
            n_frR = migLR[i+1] # n entering array !ROW VECTOR
            n_frR = n_frR[:,1] #only migration from right, columnn vector
            #column vector
            println("size(n_B)",size(n_B))
            println("size(n_frR)",size(n_frR))

            n_aft = n_B + n_frR
            n_i[:,t]=n_aft
            D[i] = n_i # stores back into deme cell array
            elseif i == nDemes # for last deme
            n_i = D[i]
            n_B = n_i[:,t]
            n_frL = migLR[i-1] # n entering array !ROW VECTOR
            n_frL = n_frL[:,2] #only migration from left, columnn vector
            println("size(n_B)",size(n_B))
            println("size(n_frL)",size(n_frL))
            n_aft = n_B + n_frL # adds entering array into existing array
            n_i[:,t]=n_aft
            D[i] = n_i # stores back into deme cell array
        else # for the middle demes
            n_i = D[i] # n before entering, COLUMN VECTOR
            n_B = n_i[:,t]
            # println("migLR_size",size(migLR))
            n_frR = migLR[i+1] # n entering array from right deme !ROW VECTOR
            n_frR = n_frR[:,1] # n entering (only left migration therefore #row 1)!COLUMN VECTOR
            n_frL = migLR[i-1] # n entering array from left deme !ROW VECTOR
            n_frL = n_frL[:,2] # n entering (only right migration therefore
                #row 2)!COLUMN VECTOR

                 println("size(n_B)",size(n_B),
                         "size(n_frL)",size(n_frL),
                         "size(n_frR))",size(n_frR))

            n_aft = n_B + n_frR + n_frL # adds entering array into existing array
            n_i[:,t]=n_aft
            D[i] = n_i # stores back into deme cell array

        end
        nan=findall(isnan,n_i)
        println("nan position_just after migration ",nan)
        println("n_i just after migration ", n_aft)
    end

    #individuals=>frequency
    for i in 1:nDemes
        x_i=D[i]#column in frequency except in this generation
        n_B=x_i[:,t]
        x_aft=n_B/sum(n_B)
        println("sum(n_B) ",sum(n_B))
        x_i[:,t]=x_aft
        D[i]=x_i

        #check NaNs contained at the end of migration or not
        nan=findall(isnan,x_i)
        println("x_i ", size(x_aft))#how much elements in this column
        println("nan position_after individuals=>frequency ",nan)
        #how much NaNs in this column

    end

  end #for t = 2:T+1

  return D
 end #function

```

---

<div class="post-metadata">

**Author:** ![1634](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/1634/32/12119_2.png) [@1634](https://discourse.julialang.org/u/1634)\
**Post date:** [February 25, 2020, 12:10am UTC](https://discourse.julialang.org/t/julia-client-internal-error-julia-stopped-if-running-codes-in-script-rather-than-repl/35087/4 "2020-02-25T00:10:31Z")

</div>

Shift the pathway to former version Julia-1.2.0 in setting, and the script serve normally. I have no idea what my demon codes have done to the file of Julia-1.3.1 and whether version matters or not.

---

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [February 25, 2020, 2:19am UTC](https://discourse.julialang.org/t/julia-client-internal-error-julia-stopped-if-running-codes-in-script-rather-than-repl/35087/5 "2020-02-25T02:19:34Z")

</div>

First, that is not a MWE.

Second, if rather than copy-pasting the code or running via some Atom shortcut, you instead use `include()` in the REPL, the error message will actually tell you what line is the problem.

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [February 25, 2020, 9:06am UTC](https://discourse.julialang.org/t/julia-client-internal-error-julia-stopped-if-running-codes-in-script-rather-than-repl/35087/6 "2020-02-25T09:06:26Z")

</div>

This error happens if you are _not_ on the latest version of julia-client _and_ on Atom.jl 0.12.5. I’d recommend updating both julia-client and Atom.jl to their latest version.

---

<div class="post-metadata">

**Author:** ![1634](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/1634/32/12119_2.png) [@1634](https://discourse.julialang.org/u/1634)\
**Post date:** [February 25, 2020, 12:03pm UTC](https://discourse.julialang.org/t/julia-client-internal-error-julia-stopped-if-running-codes-in-script-rather-than-repl/35087/7 "2020-02-25T12:03:09Z")

</div>

While updating it appeared that only 0.12.2 version of ink and julia-client are available. After the two above and atom.jl (pkg\>update atom) got successfully updated, I restarted atom and all the shortcut key changed. Ctrl+enter before as running the line now is like enter, Ctrl+j +Ctrl+o to open the REPL now is to open the folder.

The keybindings in setting appear to be (nowhere clickable and amendable):

 ![image](https://global.discourse-cdn.com/julialang/original/3X/9/8/986560e89fe8ffe9981d7083ab4d9c7335ac5c75.png)  
No ouput if searching REPL or terminal in the box while for ctrl-j  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/9/4/94916004e16ee71001df083942b5b8433ec4ee83.png)

> [@Juno keyboard shortcuts and source navigation](https://discourse.julialang.org/t/juno-keyboard-shortcuts-and-source-navigation/16262/6):
>
> Yeah, there are cases when the updater fails. I hope to fix that soon. On what version of Atom.jl are you? You should be on [v0.6.17](https://github.com/JunoLab/Atom.jl/releases/tag/v0.6.17).

Referring to this early version discussion of keybinding issue, I alos tried to uninstall and reinstall julia-client but it’s not uninstall after the uninstall button reacted for a while.

 ![image](https://global.discourse-cdn.com/julialang/original/3X/6/0/60c58150ee40c3d09ac41a1d95f40e872bdb7fe7.png)  
My current julia version is 1.3.1. Could you please help me with this?

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [February 25, 2020, 12:06pm UTC](https://discourse.julialang.org/t/julia-client-internal-error-julia-stopped-if-running-codes-in-script-rather-than-repl/35087/8 "2020-02-25T12:06:49Z")

</div>

Try

1. Close all Atom instances.
2. Start a terminal (e.g. `cmd` on Windows or the Terminal App on MacOS)
3. Execute `apm uninstall julia-client` .
4. Execute `apm install julia-client` .
5. Start Juno. Everything should work again.

as per the [FAQ](http://docs.junolab.org/latest/man/faq/#Juno-doesn't-work-properly-after-some-Atom-packages-were-updated.-What-do-I-do?-1).

---

<div class="post-metadata">

**Author:** ![1634](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/1634/32/12119_2.png) [@1634](https://discourse.julialang.org/u/1634)\
**Post date:** [February 25, 2020, 3:41pm UTC](https://discourse.julialang.org/t/julia-client-internal-error-julia-stopped-if-running-codes-in-script-rather-than-repl/35087/9 "2020-02-25T15:41:36Z")

</div>

For who met the same problem:  
`apm uninstall julia-client` on window terminal failed cause `package.json` not found in the pathway `C:\Users\Amend\.atom\packages\julia-client`. After uninstall and reinstall Atom, `C:\Users\Amend\.atom\packages\julia-client` gets decent, while the condition still appears to be

> [@1634](#):
>
> I restarted atom and all the shortcut key changed. Ctrl+enter before as running the line now is like enter, Ctrl+j +Ctrl+o to open the REPL now is to open the folder.

After getting `ink` uninstalled and reinstalled in `packages` in `setting`, finally everything get back to track~
