{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/22803","repository_url":"https://api.github.com/repos/JuliaLang/julia","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/22803/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/22803/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/22803/events","html_url":"https://github.com/JuliaLang/julia/issues/22803","id":242853297,"number":22803,"title":"make \"julia -e expr file.jl\" execute both expr and file.jl","user":{"login":"irislieuw","id":11950094,"avatar_url":"https://avatars6.githubusercontent.com/u/11950094?v=4","gravatar_id":"","url":"https://api.github.com/users/irislieuw","html_url":"https://github.com/irislieuw","followers_url":"https://api.github.com/users/irislieuw/followers","following_url":"https://api.github.com/users/irislieuw/following{/other_user}","gists_url":"https://api.github.com/users/irislieuw/gists{/gist_id}","starred_url":"https://api.github.com/users/irislieuw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/irislieuw/subscriptions","organizations_url":"https://api.github.com/users/irislieuw/orgs","repos_url":"https://api.github.com/users/irislieuw/repos","events_url":"https://api.github.com/users/irislieuw/events{/privacy}","received_events_url":"https://api.github.com/users/irislieuw/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-07-13T22:57:27Z","updated_at":"2017-07-14T18:40:04Z","closed_at":null,"body":"I am trying to create a custom Julia kernel that executes code whenever the kernel is started.\r\n(Side note, editing the .juliarc file is not an option for me since I need this custom code to be executed with a subset of kernels only)\r\n\r\nI tried using the `-e` argument, documented [here](https://docs.julialang.org/en/release-0.6/manual/getting-started/), but it causes the kernel to restart a few times and then give up and die.\r\n\r\nEach time the kernel is started/restarted, it does evaluate the code passed with the `-e` arg, but the following arguments do not get executed (like kernel.jl) from what I can tell.\r\n\r\nThis is my kernel.json file:\r\n```{\r\n  \"display_name\": \"Julia 0.6.0\",\r\n  \"argv\": [\r\n    \"/Volumes/Julia-0.6.0/Julia-0.6.app/Contents/Resources/julia/bin/julia\",\r\n    \"-i\",\r\n    \"--startup-file=yes\",\r\n    \"-e println(123)\",\r\n    \"--color=yes\",\r\n    \"/Users/ilieuw/.julia/v0.6/IJulia/src/kernel.jl\",\r\n    \"{connection_file}\"\r\n  ],\r\n  \"language\": \"julia\"\r\n}\r\n```\r\n\r\nIf I use the `-L` arg in kernel.json, instead of `-e`, and pass along a file containing `println(123)` then everything works as expected.\r\n\r\n`versioninfo()` gives back:\r\n```\r\nJulia Version 0.6.0\r\nCommit 903644385b (2017-06-19 13:05 UTC)\r\nPlatform Info:\r\n  OS: macOS (x86_64-apple-darwin13.4.0)\r\n  CPU: Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz\r\n  WORD_SIZE: 64\r\n  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)\r\n  LAPACK: libopenblas64_\r\n  LIBM: libopenlibm\r\n  LLVM: libLLVM-3.9.1 (ORCJIT, haswell)\r\n```\r\n\r\nIs this expected behavior? "},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/315435678","html_url":"https://github.com/JuliaLang/julia/issues/22803#issuecomment-315435678","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/22803","id":315435678,"user":{"login":"stevengj","id":2913679,"avatar_url":"https://avatars7.githubusercontent.com/u/2913679?v=4","gravatar_id":"","url":"https://api.github.com/users/stevengj","html_url":"https://github.com/stevengj","followers_url":"https://api.github.com/users/stevengj/followers","following_url":"https://api.github.com/users/stevengj/following{/other_user}","gists_url":"https://api.github.com/users/stevengj/gists{/gist_id}","starred_url":"https://api.github.com/users/stevengj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevengj/subscriptions","organizations_url":"https://api.github.com/users/stevengj/orgs","repos_url":"https://api.github.com/users/stevengj/repos","events_url":"https://api.github.com/users/stevengj/events{/privacy}","received_events_url":"https://api.github.com/users/stevengj/received_events","type":"User","site_admin":false},"created_at":"2017-07-14T18:40:04Z","updated_at":"2017-07-14T18:40:04Z","body":"In any case, there is an easy workaround: just `include` the desired file in your `-e` expression:\r\n```\r\njulia -e 'println(123); include(\"foo.jl\")'\r\n```\r\nIn particular, use the following in your `kernel.json` file:\r\n```\r\n  \"argv\": [\r\n    \"/Volumes/Julia-0.6.0/Julia-0.6.app/Contents/Resources/julia/bin/julia\",\r\n    \"-i\",\r\n    \"--startup-file=yes\",\r\n    \"--color=yes\",\r\n    \"-e println(123); include(\\\"/Users/ilieuw/.julia/v0.6/IJulia/src/kernel.jl\\\")\",\r\n    \"{connection_file}\"\r\n  ],\r\n```\r\n(You may need additional quoting around the `-e` args, I'm not sure how Jupyter handles quoting of command-line arguments.)"}}
{"actor":{"display_login":"stevengj"}}