ArgumentError installing nerves_bootstrap

Hi there, I’m trying to get started with Nerves but I get an error on the final step of the installation process.

I’m on an M1 Mac,
Elixir 1.15.1
Erlang 26.0.2

When I try to install nerves_bootstrap, the following is the result:

$ mix archive.install hex nerves_bootstrap
Resolving Hex dependencies…
Resolution completed in 0.019s
New:
nerves_bootstrap 1.11.5

  • Getting nerves_bootstrap (Hex package)
    All dependencies are up to date
    Compiling 12 files (.ex)

== Compilation error in file lib/attic/env.ex ==
** (ArgumentError) could not call Module.put_attribute/3 because the module Nerves.Bootstrap.Aliases is in read-only mode (@after_compile)
(elixir 1.15.1) lib/module.ex:2305: Module.assert_not_readonly!/2
(elixir 1.15.1) lib/module.ex:2007: Module.put_attribute/5
lib/attic/env.ex:2: (module)

Any ideas?

Hi @tobytripp,

I think this is the first time we’ve seen this error. I just tried reproducing the error on an M1 Mac w/ Elixir 1.15.1 and Erlang 26.0.2 and couldn’t.

Could you give more details on your setup? How did you install Elixir and are there other archives installed? (run mix archive to get the installed archive list)

I installed elixir with asdf as described in the Nerves installation page. It’s a fresh install of elixir, so there are no other–aside from hex–archives installed.

So, I blitzed my asdf dir and started over. Now I get a different error:

$ mix archive.install hex nerves_bootstrap

Resolving Hex dependencies…
Resolution completed in 0.018s
New:
nerves_bootstrap 1.11.5

  • Getting nerves_bootstrap (Hex package)
    All dependencies are up to date
    Compiling 12 files (.ex)
    ** (FunctionClauseError) no function clause matching in Mix.Tasks.Local.Nerves.info/1

    The following arguments were given to Mix.Tasks.Local.Nerves.info/1:

      # 1
      :exports_md5
    

    Mix.Tasks.Local.Nerves.info/1
    (mix 1.15.1) lib/mix/compilers/elixir.ex:1015: Mix.Compilers.Elixir.compiler_loop/4
    (mix 1.15.1) lib/mix/compilers/elixir.ex:168: Mix.Compilers.Elixir.compile/7
    (mix 1.15.1) lib/mix/state.ex:15: Mix.State.lock/2
    (mix 1.15.1) lib/mix/task.ex:447: anonymous fn/3 in Mix.Task.run_task/5
    (mix 1.15.1) lib/mix/task.ex:502: Mix.Task.run_alias/6
    (mix 1.15.1) lib/mix/tasks/compile.all.ex:124: Mix.Tasks.Compile.All.run_compiler/2
    (mix 1.15.1) lib/mix/tasks/compile.all.ex:104: Mix.Tasks.Compile.All.compile/4

Even more puzzling, if I run it again, I get a third error:

$ mix archive.install hex nerves_bootstrap

Resolving Hex dependencies…
Resolution completed in 0.019s
New:
nerves_bootstrap 1.11.5

  • Getting nerves_bootstrap (Hex package)
    All dependencies are up to date
    Compiling 12 files (.ex)

== Compilation error in file lib/attic/deps.get.ex ==
** (ArgumentError) could not call Module.put_attribute/3 because the module Mix.Nerves.IO is already compiled
(elixir 1.15.1) lib/module.ex:2310: Module.assert_not_readonly!/2
(elixir 1.15.1) lib/module.ex:2007: Module.put_attribute/5
lib/attic/deps.get.ex:2: (module)

Could you check if Erlang was built with SSL?

$ iex
Erlang/OTP 26 [erts-14.0.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]

Interactive Elixir (1.15.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> Application.ensure_all_started(:ssl)
{:ok, [:crypto, :asn1, :public_key, :ssl]}

If you don’t get what I got, you’ll need to brew install openssl and reinstall Erlang. There might be something else that’s helpful at GitHub - asdf-vm/asdf-erlang: Erlang plugin for asdf version manager.

I’m really grasping, though. If you could copy all output starting from installing asdf, Erlang, and Elixir and finally the mix install hex nerves_bootstrap line, perhaps there’s a warning buried in there.

I get:

$ iex
Erlang/OTP 26 [erts-14.0.2] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit:ns]

Interactive Elixir (1.15.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> Application.ensure_all_started(:ssl)
{:ok, [:crypto, :asn1, :public_key, :ssl]}

I’ll dig up the installation output momentarily.

Installation output:

$ asdf install erlang 26.0.2
Downloading kerl…
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 85117 100 85117 0 0 340k 0 --:–:-- --:–:-- --:–:-- 344k
asdf_26.0.2 is not a kerl-managed Erlang/OTP installation
No build named asdf_26.0.2
Downloading 26.0.2 to /Users/toby/.asdf/downloads/erlang/26.0.2…
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0
100 102M 100 102M 0 0 10.3M 0 0:00:09 0:00:09 --:–:-- 11.1M
Extracting source code
Building Erlang/OTP 26.0.2 (asdf_26.0.2), please wait…
DOCUMENTATION INFORMATION (See: /Users/toby/.asdf/plugins/erlang/kerl-home/builds/asdf_26.0.2/otp_build_26.0.2.log)

  • documentation :
  •              fop is missing.
    
  •              Using fakefop to generate placeholder PDF files.
    

Erlang/OTP 26.0.2 (asdf_26.0.2) has been successfully built
Cleaning up compilation products for 26.0.2
Cleaned up compilation products for 26.0.2 under /Users/toby/.asdf/plugins/erlang/kerl-home/builds

$ asdf install elixir 1.15.1-otp-26
==> Checking whether specified Elixir release exists…
==> Downloading 1.15.1-otp-26 to /Users/toby/.asdf/downloads/elixir/1.15.1-otp-26/elixir-precompiled-1.15.1-otp-26.zip
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6641k 100 6641k 0 0 5945k 0 0:00:01 0:00:01 --:–:-- 5972k
==> Copying release into place

Can you run echo $KERL_CONFIGURE_OPTIONS and brew info openssl

Also, is Elixir 1.15.1 a hard requirement? Are you able to try 1.15.4?

$ echo $KERL_CONFIGURE_OPTIONS

$ brew info openssl
==> openssl@3: stable 3.1.2 (bottled)
Cryptography and SSL/TLS Toolkit
https://openssl.org/
/usr/local/Cellar/openssl@3/3.1.2 (6,495 files, 30.0MB) *
  Poured from bottle on 2023-08-12 at 12:39:26
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/openssl@3.rb
License: Apache-2.0
==> Dependencies
Required: ca-certificates ✔
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl@3/certs

and run
  /usr/local/opt/openssl@3/bin/c_rehash
==> Analytics
install: 419,609 (30 days), 945,723 (90 days), 1,199,741 (365 days)
install-on-request: 42,295 (30 days), 196,058 (90 days), 264,268 (365 days)
build-error: 1,658 (30 days)

I’ll try 1.15.4

mix archive.install hex nerves_bootstrap

* creating /Users/toby/.asdf/installs/elixir/1.15.4-otp-26/.mix/archives/hex-2.0.6
Resolving Hex dependencies...
Resolution completed in 0.018s
New:
  nerves_bootstrap 1.11.5
* Getting nerves_bootstrap (Hex package)
All dependencies are up to date
Compiling 12 files (.ex)

== Compilation error in file lib/mix/tasks/nerves/local.ex ==
** (ArgumentError) could not call Module.put_attribute/3 because the module Nerves.Bootstrap.MixProject is already compiled
    (elixir 1.15.4) lib/module.ex:2310: Module.assert_not_readonly!/2
    (elixir 1.15.4) lib/module.ex:2007: Module.__put_attribute__/5
    lib/mix/tasks/nerves/local.ex:2: (module)

What directory are you in when running mix archive.install hex nerves_bootstrap?

Can you also try building Erlang with OpenSSL 1.1

brew install openssl@1.1
KERL_CONFIGURE_OPTIONS="--disable-debug --without-javac --with-ssl=$(brew --prefix openssl@1.1)" asdf install Erlang 26.0.2

I’m in an empty directory off of $HOME

Same error. :person_shrugging:

Hi @tobytripp,

Sorry for the delays in responding. It seems like mid-August caught up with Jon and me.

As far as I can tell, you’re doing everything right. The error that you’re getting should have been a good hint, but I can not reproduce it. I created an issue to track it.

Could you try installing nerves_bootstrap like this and let me know if it works?

mix archive.install github nerves-project/nerves_bootstrap branch support-nerves-1.8-and-later

# If successful, try this
mix nerves.new test_project # answer y to the question
cd test_project
export MIX_TARGET=rpi0
mix deps.get
mix firmware

You won’t be able to use Nerves versions before v1.8.0, but that version is over a year old now.

Thanks for your patience with what should have been an easy step.

fishing, but I wonder if installing Xcode Command Line Tools is required by asdf nowadays?

maybe try xcode-select --install in terminal, and then (re)install erlang/elixir using asdf

✗ mix archive.install github nerves-project/nerves_bootstrap branch support-nerves-1.8-and-later

Error while loading project :mix_local_installer at /private/var/folders/q0/5bh7by3s5ydfxx6pslz3z9vc0000gn/T/mix-local-installer-fetcher-wHyuNA
** (ArgumentError) could not call Module.put_attribute/3 because the module Blinker.MixProject is already compiled
    (elixir 1.15.4) lib/module.ex:2310: Module.assert_not_readonly!/2
    (elixir 1.15.4) lib/module.ex:2007: Module.__put_attribute__/5
    /private/var/folders/q0/5bh7by3s5ydfxx6pslz3z9vc0000gn/T/mix-local-installer-fetcher-wHyuNA/mix.exs:2: (module)
✗ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" in System Settings to install updates
1 Like

What’s Blinker.MixProject? That sounds like the problem.

Oops. Forgot to do it in an empty directory. Let me try again…

Hm, looks like it might be an ssl error?

mix archive.install github nerves-project/nerves_bootstrap branch support-nerves-1.8-and-later

* Getting new package (https://github.com/nerves-project/nerves_bootstrap.git - origin/support-nerves-1.8-and-later)
remote: Enumerating objects: 2883, done.
remote: Counting objects: 100% (262/262), done.
remote: Compressing objects: 100% (120/120), done.
remote: Total 2883 (delta 157), reused 193 (delta 136), pack-reused 2621

16:35:33.356 [notice] Application ssl exited: exited in: :ssl_app.start(:normal, [])
    ** (EXIT) an exception was raised:
        ** (MatchError) no match of right hand side value: {:format_warning, 1}
            (elixir 1.15.4) src/elixir_def.erl:134: :elixir_def.store_definition/3
            (ssl 11.0.2) ssl_app.erl:47: :ssl_app.start_logger/0
            (ssl 11.0.2) ssl_app.erl:32: :ssl_app.start/2
            (kernel 9.0.2) application_master.erl:293: :application_master.start_it_old/4

16:35:33.366 [notice] Application public_key exited: :stopped

16:35:33.366 [notice] Application asn1 exited: :stopped
==> nerves_bootstrap

16:35:33.366 [notice] Application crypto exited: :stopped
Could not start Hex. Try fetching a new version with "mix local.hex" or uninstalling it with "mix archive.uninstall hex.ez"
** (MatchError) no match of right hand side value: {:error, {:ssl, {:bad_return, {{:ssl_app, :start, [:normal, []]}, {:EXIT, {{:badmatch, {:format_warning, 1}}, [{:elixir_def, :store_definition, 3, [file: ~c"src/elixir_def.erl", line: 134]}, {:ssl_app, :start_logger, 0, [file: ~c"ssl_app.erl", line: 47]}, {:ssl_app, :start, 2, [file: ~c"ssl_app.erl", line: 32]}, {:application_master, :start_it_old, 4, [file: ~c"application_master.erl", line: 293]}]}}}}}}
    (hex 2.0.6) lib/hex.ex:5: Hex.start/0
    (mix 1.15.4) lib/mix/hex.ex:60: Mix.Hex.start/0
    (mix 1.15.4) lib/mix/dep/loader.ex:189: Mix.Dep.Loader.with_scm_and_app/5
    (mix 1.15.4) lib/mix/dep/loader.ex:141: Mix.Dep.Loader.to_dep/4
    (elixir 1.15.4) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2
    (mix 1.15.4) lib/mix/dep/loader.ex:364: Mix.Dep.Loader.mix_children/3
    (mix 1.15.4) lib/mix/dep/loader.ex:317: anonymous fn/5 in Mix.Dep.Loader.mix_dep/3
    (mix 1.15.4) lib/mix/project.ex:458: Mix.Project.in_project/4

@tobytripp Can you try the newly released nerves_boostrap v1.12.1? It completely removes the legacy tasks that are showing in your failure traces here so I’m hopeful it fixes things for you

1 Like

That seems to have worked, thanks! At least, it ran without error.

Thanks again!