nerves-project / nerves_bootstrap Goto Github PK
View Code? Open in Web Editor NEWNerves mix integration bootstrap and new project generator
Home Page: http://nerves-project.org
License: Apache License 2.0
Nerves mix integration bootstrap and new project generator
Home Page: http://nerves-project.org
License: Apache License 2.0
build_embedded is no longer needed in the new project generator.
It'd be useful if init-gadget was a string flag instead that would parameterize usb
or eth
The error message for this could be improved.
I'm leaving myself a reminder to come fix this once I get through my training prep, but I noticed that the README is out of sync with the Hexdocs (for example the --init-gadget
flag for mix nerves.new
. I think we should just put a one-liner description (and maybe examples) for each task in the README and link to the specific Hexdocs page for that task to see what flags are supported.
Need a friendly error for "xz" missing
This popped up in training
Creating a new project named nerves
won't work, so don't make a project with that name.
a common use case for Erlinit is configuring the tty. it would be nice to have an example that can be uncommented in the new project generator
When a Nerves app is built inside an umbrella app the mix.exs
file will reference the config files located at the root of the umbrella app. But the nerves.new script doesn't place the config files there.
The app will build but fail silently since the Nerves config.exs
isn't appended to the app config.exs
the host.exs
or target.exs
files aren't referenced.
I made a PR that fixes it in 1 way. Hope that helps!
elixir -v
): 1.14.2 Pkg: nerves_system_br
Vsn: 1.22.5
Type: system_platform
BuildRunner: {nil, []}
Pkg: nerves_system_rpi0
Vsn: 1.22.2
Type: system
BuildRunner: {Nerves.Artifact.BuildRunners.Docker, [make_args: ["source", "all", "legal-info"]]}
Pkg: nerves_toolchain_armv6_nerves_linux_gnueabihf
Vsn: 1.8.0
Type: toolchain
BuildRunner: {Nerves.Artifact.BuildRunners.Local, []}
Pkg: nerves_toolchain_ctng
Vsn: 1.9.3
Type: toolchain_platform
BuildRunner: {nil, []}
I think the main thing is to use the latest version of the phx_new archive, since they older versions had issues with umbrella projects.
elixir -v
): 1.14.2mix nerves.env --info
) n/aI use 690a030 .
I do Local development.
git clone https://github.com/nerves-project/nerves_bootstrap.git
cd nerves_bootstrap
mix do deps.get, archive.build, archive.install
cd ..
mix nerves.new hello_nerves
cd hello_nerves
mix format
hello_nerves project changes mix.exs .
- @all_targets [:rpi, :rpi0, :rpi2, :rpi3, :rpi3a, :rpi4, :bbb, :osd32mp1, :x86_64, :grisp2, :mangopi_mq_pro]
+ @all_targets [
+ :rpi,
+ :rpi0,
+ :rpi2,
+ :rpi3,
+ :rpi3a,
+ :rpi4,
+ :bbb,
+ :osd32mp1,
+ :x86_64,
+ :grisp2,
+ :mangopi_mq_pro
+ ]
I show my humble solution.
If you all prefer this, I'm going to send a pull request tomorrow.
- @all_targets <%= inspect(Enum.map(targets, &elem(&1, 0))) %>
+ @all_targets [
+<%= Enum.map(targets, &elem(&1, 0)) |> Enum.map(& " :#{&1}") |> Enum.join(",\n") %>
+ ]
When (S)He does 'mix format', new project changes mix.exs .
When (S)He does 'mix format', new project changes nothing .
The history of this error is at https://elixirforum.com/t/argumenterror-installing-nerves-bootstrap/57611/1.
Here's a trace of what happens:
$ 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)
Per the forum post, this is on MacOS using Homebrew. All installation seems to have been done the expected way.
https://github.com/nerves-project/nerves_bootstrap/blob/master/templates/new/mix.exs#L48
This should only be in the target deps as it prevents running iex -S mix
as host
I believe this is fixed in Elixir language elixir-lang/elixir#10537. We should remove it at some stage. Maybe this is intentional for backward compatibility? 🤔
When specifying --init-gadget
, the generated mix project will contain nerves_init_gadget
as part of the target
only deps. The issue is that the generated config.exs
configures the logger
backend to use RingLogger
. The application crashes because the application ring_logger
is only available in the target environment.
Here are a few options we have:
--init-gadget
, we add nerves_init_gadget
to the target only deps and also add ring_logger
to the all deps.--init-gadget
is passedMy opinion is that I can not live life without ring logger, so I would move for option 2.
@fhunleth @GregMefford @ConnorRigby
What are your thoughts.
➜ blinky mix nerves.info
Nerves Environment not loaded.
MIX_TARGET is unset
|nerves_bootstrap| Environment Package List
No packages found
|nerves_bootstrap| Loadpaths Start
|nerves_bootstrap| Env Start
|nerves_bootstrap| Env End
NERVES_SYSTEM is unset
NERVES_TOOLCHAIN is unset
|nerves_bootstrap| Environment Variable List
target: host
toolchain: unset
system: unset
app: /home/connor/oss/elixir/nerves/blinky
|nerves_bootstrap| Loadpaths End
Nerves: 1.0.0-rc.0
Nerves Bootstrap: 1.0.0-rc.2
Elixir: 1.6.0
|nerves_bootstrap| Info End
➜ blinky
➜ blinky mix test
Nerves Environment not loaded.
MIX_TARGET is unset
1) test greets the world (BlinkyTest)
test/blinky_test.exs:5
** (UndefinedFunctionError) function Starter.hello/0 is undefined (module Starter is not available)
code: assert Starter.hello() == :world
stacktrace:
Starter.hello()
test/blinky_test.exs:6: (test)
.
Finished in 0.03 seconds
1 doctest, 1 test, 1 failure
Randomized with seed 195828
➜ blinky
There are a lot of opinions on how to handle configuration in Elixir and Nerves. This issue isn't meant to change the general strategy, but to the make organization more consistent between projects and to provide hints to new Nerves users.
Here's the current setup:
config.exs <-- configuration for every mix target and environment
target.exs <-- configuration for all non-host targets
Projects that work on multiple devices uncomment a line at the bottom of target.exs
and have a setup that looks like:
config.exs
target.exs
rpi0.exs
bbb.exs
Non-poncho projects frequently have unit tests. It's probably easier to run mix test
with the --no-start
option to avoid starting the application and instead manually starting GenServers, etc. in the unit tests so that it's easier to inject config. (aka aliases: [test: "test --no-start"]
in the mix.exs
and start_supervised/2
in the tests.) However, if application environment still needs to be set for tests, then the normal thing to do is to add a test.exs
and an if
in config.exs
to conditionally include it.
Finally, for those projects that have differences between MIX_ENV=dev
and MIX_ENV=prod
, the pattern that I've seen most is to add dev.exs
and prod.exs
just like was done for the unit tests.
I have not seen projects with config file names that combine the Mix environment and the Mix target. I feel like at that level, I've only seen conditionals.
I have also never seen someone have host.exs
. I suspect that the contents would be the same as test.exs
. It seems like if you like to run iex -S mix
, then you may want host.exs
, though.
Since Nerves configuration is probably more dependent on the Mix target for most projects, change the generator to make the following files:
config.exs
target.exs
host.exs
In the config.exs
, change the if
at the bottom to always load host.exs
when the target is the host. In the host.exs
add a comment about what to put in this file.
Everything else stays the same. I.e., if you want specialization based on hardware, you still uncomment the line at the end of target.exs
to load the specific target.
Finally, we encourage people to not create dev.exs
, prod.exs
, and test.exs
files, but rather to add conditionals or Mix.env()
checks inside the other files. The rationale is that the differences between those are small, so it will be easier to read if it's not broken out.
Thoughts?
Historically, MIX_TARGET
was just used in the generated mix.exs
files. There really wasn't any magic and you could just remove it's use if you were only making builds using one system. Now it's referenced in https://github.com/nerves-project/nerves_bootstrap/blob/master/lib/nerves_bootstrap/aliases.ex#L6 so it's mandatory.
At the moment, this seems unavoidable, but it would be nice to get back to where it wasn't required.
Elixir version (elixir -v
): 1.10.4
Nerves environment: (mix nerves.env --info
)
|nerves_bootstrap| Environment Package List
No packages found
|nerves_bootstrap| Loadpaths Start
Nerves environment
MIX_TARGET: host
MIX_ENV: dev
NERVES_SYSTEM is unset
NERVES_TOOLCHAIN is unset
|nerves_bootstrap| Environment Variable List
target: host
toolchain: unset
system: unset
app: …/05_elixir/edith
|nerves_bootstrap| Loadpaths End
Running a shoehorn release (on host) results in the cookie being read from $HOME/.erlang.cookie
instead of the one configured through the normal mix release means (config or env variable)
❯❯❯❯ RELEASE_BOOT_SCRIPT=shoehorn RELEASE_COOKIE=shoehorn _build/dev/rel/shoehorn/bin/shoehorn start_iex
heart_beat_kill_pid = 3244
heart_beat_timeout = 30
2021-04-26 15:15:47.218544 Multiple -mode given to erl, using the first, ~p
["embedded"]
Erlang/OTP 23 [erts-11.1.1] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe]
=WARNING REPORT==== 26-Apr-2021::15:15:47.218544 ===
Multiple -mode given to erl, using the first, ["embedded"]
[Shoehorn] Init app :nerves_runtime undefined. Skipping
[Shoehorn] Init app :vintage_net undefined. Skipping
:JKIIVXBQQLKXJEANCEZM
…
Removing the -setcookie
in vm.args.eex
resolves the issue and also doesn't seem to break releases run on targets. Mix releases are always started with an cookie set on the cli. A random cookie is generated when building the release unless a specific one is explicitly set.
The cookie configured in mix.exs or via the env variables is correctly applied.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.