Giter Site home page Giter Site logo

nerves_bootstrap's People

Contributors

akoutmos avatar amclain avatar axelson avatar connorrigby avatar dependabot-preview[bot] avatar dependabot[bot] avatar fhunleth avatar gregmefford avatar jjcarstens avatar lostkobrakai avatar michaelkschmidt avatar milmazz avatar mnishiguchi avatar mobileoverlord avatar paulanthonywilson avatar pojiro avatar supersimple avatar torifukukaiou avatar tverlaan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

nerves_bootstrap's Issues

Link from README to Hexdocs for details

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.

example configuration for erlinit

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

Nerves app not building correctly in umbrella projects

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!

#261

Environment

  • Elixir version (elixir -v): 1.14.2
  • Nerves environment:
  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.

When (S)He does 'mix format', new project changes mix.exs .

Environment

  • Elixir version (elixir -v): 1.14.2
  • Nerves environment: (mix nerves.env --info) n/a
  • Additional information about your host, target hardware or environment that
    may help

I 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 .

hello_nerves/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.

nerves_bootstrap/templates/new/mix.exs

-  @all_targets <%= inspect(Enum.map(targets, &elem(&1, 0))) %>
+  @all_targets [
+<%= Enum.map(targets, &elem(&1, 0)) |> Enum.map(& "    :#{&1}") |> Enum.join(",\n") %>
+  ]

Current behavior

When (S)He does 'mix format', new project changes mix.exs .

Expected behavior

When (S)He does 'mix format', new project changes nothing .

Argument error from Module.put_attribute/3 when installing nerves_bootstrap archive

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.

New projects generated with --init-gadget crash in Host mode

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:

  1. if --init-gadget, we add nerves_init_gadget to the target only deps and also add ring_logger to the all deps.
  2. We always include RingLogger by default and put it in all deps.
  3. We do not configure logger backends when --init-gadget is passed

My 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.

new project tests fail

➜  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 

https://github.com/nerves-project/nerves_bootstrap/blob/master/templates/new/test/app_name_test.exs#L6

Be more opinionated on config file naming

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.

Background

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.

Proposal

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?

Nerves vm.args.eex prevents proper application of cookie through config or env variables

Environment

  • 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

  • Additional information about your host, target hardware or environment that
    may help

Current behavior

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.

Expected behavior

The cookie configured in mix.exs or via the env variables is correctly applied.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.