nanobox-io/nanobox

Elixir Compile Error

vpfaulkner opened this issue · 6 comments

Hello,

I started getting a weird Elixir compile error after making any change in any file:

/app $ iex -S mix phx.server
Erlang/OTP 21 [erts-10.0] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1]

Compiling 1 file (.ex)

== Compilation error in file lib/mockit_web/controllers/mock_controller.ex ==
** (SyntaxError) lib/mockit_web/controllers/mock_controller.ex:123: unexpected token: "^@" (column 1, codepoint U+0000)
    (elixir) lib/kernel/parallel_compiler.ex:198: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/6

If I revert the change, the error goes away.

Moreover, I noticed that I do not get that error when making the same change from within the nanobox environment (ie nanobox run followed by vim lib/mockit_web/controllers/mock_controller.ex). I am using vim in both situations.

I found a very similar issue here: https://elixirforum.com/t/error-unexpected-token-column-1-codepoint-u-0000-when-making-file-changes-with-a-code-editor/15785/4 which he resolved when he "switched to a Ubuntu 18.04 box in Vagrant and the issue no longer occurs."

I am running High Sierra on a Mac and here is my boxfile:

run.config:
  # Elixir runtime
  engine: elixir
  engine.config:
    runtime: elixir-1.6.6
    erlang_runtime: erlang-21

  # we need nodejs in development
  # ensure inotify exists for hot-code reloading
  dev_packages:
    - nodejs
    - inotify-tools

  # add node_module bins to the $PATH
  extra_path_dirs:
    - node_modules/.bin

  # enable the filesystem watcher
  fs_watch: true

deploy.config:
  # just before the new process comes online,
  # let's migrate the database
  before_live:
    web.main:
      - mix ecto.create --quiet
      - mix ecto.migrate

# add postgres as a data component
data.db:
  image: nanobox/postgresql

data.storage:
  image: nanobox/unfs:0.9

web.main:
  writable_dirs:
    - _build
  network_dirs:
    data.storage:
      - request_logs
  start: node-start mix phx.server

Any ideas?

You'll need to switch down a version of Elixir (1.21 to 1.20, I believe) Erlang - from 21 to 20 - or from VirtualBox to Docker Native. There's a bug in the way Elixir Erlang and VirtualBox interact with each other in that specific version.

@danhunsaker thanks! I'm glad I asked because it might have taken me a while to figure that out.

Do you happen to know if newer Elixir versions resolved this? As far as I could tell, 1.6.6 was the latest offered by the Nanobox Elixir Engine.

I don't, no. We have folks on the Slack server that keep better track of that, though!

thanks @danhunsaker I just moved the conversation there.

For anyone who runs into this: I downgraded from Erlang 21 to 20 and resolved the problem.

D'oh! It was the Erlang version, not the Elixir version! Got them reversed, somehow. Edited my initial response accordingly. Sorry about the confusion!