# Code fails in jupyter notebook, but succeeds in REPL

**URL:** <https://discourse.julialang.org/t/code-fails-in-jupyter-notebook-but-succeeds-in-repl/61793>\
**Category:** General Usage\
**Tags:** question\
**Created:** [May 25, 2021, 4:40pm UTC](https://discourse.julialang.org/t/code-fails-in-jupyter-notebook-but-succeeds-in-repl/61793 "2021-05-25T16:40:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![PeterVincent96](https://avatars.discourse-cdn.com/v4/letter/p/9fc348/32.png) [@PeterVincent96](https://discourse.julialang.org/u/PeterVincent96)\
**Post date:** [May 25, 2021, 4:40pm UTC](https://discourse.julialang.org/t/code-fails-in-jupyter-notebook-but-succeeds-in-repl/61793/1 "2021-05-25T16:40:31Z")

</div>

I have the following code

```julia
using Statistics
using LinearAlgebra
using ForwardDiff
using Plots
plotlyjs()
ENV["JULIA_REVISE_POLL"] = "1"
using Revise
using Distributions
using DelimitedFiles
include("path/to/files.jl")

dim=20

## Construct the offsets

offsetrange=(0,10)

cur_offset = collect([range(reverse(offsetrange)...,length=Int(dim/2));range(offsetrange...,length=Int(dim/2))]);

print(typeof(cur_offset))

```

`cur_offset` is then used as an argument all over my code, and that all seems to work fine. I then try and modify the parameter with the following

`cur_offset = cur_offset .+ (m_grads_α .* dropdims(norm_α_grad;dims=1));`

and this simply will not run inside the jupyter notebook, or inside a script. The code hangs there and will not execute the next line, which is printing `cur_offset`. It will run fine in the REPL.

If I run the command

```julia
println( cur_offset .+ (m_grads_α .* dropdims(norm_α_grad;dims=1)))

```

then this will succeed wherever I run it. So it seems to me that the assigment in the compiler is what is causing problems.

I also have issues with the command  
`println(typeof(cur_offset .+ (m_grads_α .* dropdims(norm_α_grad;dims=1))));`  
in the notebook or scripts, but again no problems at all in the REPL.

Please advise on how I can fix this, or on further information I need to give so that this bug can be resolved!
