Giter Club home page Giter Club logo

mjml_nif's Introduction

Adoptoposs

Build Status

Finding co-maintainers for your open source software project. Visit https://adoptoposs.org.

Adoptoposs offers a platform to put your open source projects up for adoption and make initial contact with potential co-maintainers.

Having a team of multiple maintainers is good for you and your project, because:

  • The workload can be split up between all maintainers
  • It's easier to take decisions as a team
  • There will be no single point of failure
  • It is possible to step down as a maintainer

If you like to learn more about the reasons behind building Adoptoposs you can read the announcement post on Medium.

Contributing

We encourage you to contribute to Adoptoposs. Please check our CONTRIBUTING.md guides for more information.

This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to our CODE_OF_CONDUCT.md.

If you have contributed to this project, don't forget to add your name to the Contributors list.

Copyright and License

Copyright (c) 2020, Paul Götze

Adoptoposs is licensed under the MIT License.

Adoptoposs uses icon assets from the Fontawesome iconset.

mjml_nif's People

Contributors

abstractcoder avatar dependabot[bot] avatar en30 avatar kianmeng avatar moomerman avatar mrdotb avatar paulgoetze avatar philss avatar shritesh avatar tidusio avatar woylie 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  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  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

mjml_nif's Issues

Question: Issues to run in docker?

Hi there,
i got issues to run it in phoenix release generated docker files, for example: hexpm/elixir:1.16.2-erlang-25.2.3-debian-bullseye-20240423-slim

I already tried different Debian linux and elixir / otp versions, but the error remains the same:
The app mostly crashes with:

 exited: {{shutdown,
                 {failed_to_start_child,kernel_safe_sup,
                     {on_load_function_failed,'Elixir.Mjml.Native',
                         {error,
                             {load_failed,
                                 "Failed to load NIF library: '/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /app/lib/mjml-3.1.0/priv/native/libmjml_nif-v3.1.0-nif-2.16-x86_64-unknown-linux-gnu.so)'"}}}}},

Any suggestions to fix this, please?

Error while downloading NIF

Hey there,

My CI is constantly failing with this error:

12:59:54.780 [notice] TLS :client: In state :hello_middlebox_assert at ssl_gen_statem.erl:736 generated 
CLIENT ALERT: Fatal - Unexpected Message 03:23
834 - {:unexpected_msg, {:internal, {:encrypted_extensions, %{sni: {:sni, []}}}}} 03:23
835  03:23
836== Compilation error in file lib/mjml.ex == 03:23
837** (RuntimeError) Error while downloading precompiled NIF: couldn't fetch NIF from 
https://github.com/adoptoposs/mjml_nif/releases/download/v1.3.5/libmjml_nif-v1.3.5-nif-2.16-x86_64-unknown-linux-
gnu.so.tar.gz: {:error, {:failed_connect, [{:to_address, {'objects.githubusercontent.com', 443}}, {:inet, [:inet], {:tls_alert,
{:unexpected_message, 'TLS client: In state hello_middlebox_assert at ssl_gen_statem.erl:736 generated CLIENT ALERT: Fatal -
Unexpected Message\n {unexpected_msg,{internal,{encrypted_extensions,\#{sni => {sni,[]}}}}}'}}}]}}.

Using Erlang 25.0 / Elixir 1.13.4

Any idea what's going on?

Does not work on Centos 7.x

Hello friends, I'm using this project on a Centos 7.x system and running {:ok, html} = Mjml.to_html(mjml) gives me the following error:

** (UndefinedFunctionError) function Mjml.Native.to_html/2 is undefined (module Mjml.Native is not available)                                                               
    (mjml 1.5.0) Mjml.Native.to_html("<mjml>...</mjml>", %Mjml.RenderOptions{keep_comments: true, social_icon_path: nil})                                                   
    iex:2: (file)                                                                     
11:52:56.622 [warning] The on_load function for module Elixir.Mjml.Native returned:   
{:error,                                                                              
 {:load_failed,                                                                       
  'Failed to load NIF library: \'/lib64/libc.so.6: version `GLIBC_2.28\' not found (required by /home/serafeim/plausible/_build/prod/lib/mjml/priv/native/libmjml_nif-v1.5.0-nif-2.16-x86_64-unknown-linux-gnu.so)\''}}   

Running ldd --version gives me ldd (GNU libc) 2.17.

Can you recommend any way to use this on my system without intalling rustc?

Thank you

Segmentation fault while compiling mjml

I am receiving the following error while mjml is compiling:

==> mjml
Compiling 3 files (.ex)

16:35:16.938 [debug] Copying NIF from cache and extracting to /APP_PATH/_build/dev/lib/mjml/priv/native/libmjml_nif-v1.5.0-nif-2.15-x86_64-apple-darwin.so
zsh: segmentation fault  mix phx.server

I'm using a Mac with M1 (Arm64).
Elixir 1.14.3
Erlang 23.3.4.11

Do you know how can I tackle this? Maybe a missing package/dependency in my computer?

precompiled NIF is not available: Compilation fails on M1 with Alpine hex.pm builder for target aarch64-unknown-linux-musl

Issue

Building my app that has an MJML dependency fails as the precompiled NIF is not available for target architecture aarch64-unknown-linux-musl

MJML Version

MJML 1.3.2
Also fails on 1.3.4

Builder Image Version

FROM hexpm/elixir:1.13.4-erlang-24.3.4.2-alpine-3.16.0 as builder

Error

(RuntimeError) Error while downloading precompiled NIF: precompiled NIF is not available for this target: "aarch64-unknown-linux-musl".

Log Output

#15 52.53 ==> rustler_precompiled
#15 52.53 Compiling 4 files (.ex)
#15 52.82 Generated rustler_precompiled app
#15 52.85 ==> mjml
#15 52.85 Compiling 1 file (.ex)
#15 52.89
#15 52.89 == Compilation error in file lib/mjml.ex ==
#15 52.89 ** (RuntimeError) Error while downloading precompiled NIF: precompiled NIF is not available for this target: "aarch64-unknown-linux-musl".
#15 52.89 The available targets are:
#15 52.89  - aarch64-apple-darwin
#15 52.89  - x86_64-apple-darwin
#15 52.89  - x86_64-unknown-linux-gnu
#15 52.89  - x86_64-unknown-linux-musl
#15 52.89  - arm-unknown-linux-gnueabihf
#15 52.89  - aarch64-unknown-linux-gnu
#15 52.89  - x86_64-pc-windows-msvc
#15 52.89  - x86_64-pc-windows-gnu.

Issues with Docker and prebuild archives

Using the prebuild mjml nif archive on GitLab CI within a CI job, an error raises while running the mix compile command.

Compiling 1 file (.ex)
14:45:01.534 [debug] Downloading NIF from https://github.com/adoptoposs/mjml_nif/releases/download/v1.3.5/libmjml_nif-v1.3.5-nif-2.16-x86_64-unknown-linux-musl.so.tar.gz
14:45:01.536 [debug] Using HTTP_PROXY: 
== Compilation error in file lib/mjml.ex ==
** (FunctionClauseError) no function clause matching in String.to_charlist/1    
    
    The following arguments were given to String.to_charlist/1:
    
        # 1
        nil
    
    Attempted function clauses (showing 1 out of 1):
    
        def to_charlist(+string+) when -is_binary(string)-
    
    (elixir 1.13.4) lib/string.ex:2401: String.to_charlist/1
    (rustler_precompiled 0.5.1) lib/rustler_precompiled.ex:611: RustlerPrecompiled.download_nif_artifact/1
    (rustler_precompiled 0.5.1) lib/rustler_precompiled.ex:468: RustlerPrecompiled.download_or_reuse_nif_file/1
    (rustler_precompiled 0.5.1) lib/rustler_precompiled.ex:124: RustlerPrecompiled.__using__/2
    lib/mjml.ex:22: (module)
could not compile dependency :mjml, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile mjml", update it with "mix deps.update mjml" or clean it with "mix deps.clean mjml"

I am using the bitwalker/alpine-elixir:1.13 image.

unable to load included template

In my mjml template I have mj-include but when I run to_html function, I get unable to load included template error.
Here's an example of my template

<mjml>
  <mj-head>
    <mj-include path="./partials/head.mjml" />
  </mj-head>
  <mj-body>
    <mj-include path="./partials/header.mjml" />   
    <mj-wrapper>
      <mj-section>
        <mj-column>
          <mj-text font-size="16px">
           Dear {{ username }},
          </mj-text>
          <mj-text font-size="16px">
           We have received your request
          </mj-text>
        </mj-column>
      </mj-section>
    </mj-wrapper>
    <mj-include path="./partials/simple_footer.mjml" />
  </mj-body>
</mjml>

Any idea how to solve this? I tried replacing the path with the absolute path of the mj-include file but the error persosts.

unable to compile on non-m1 macbook pro

When attempting to compile MJML, it would not finish.

⋊> ~on main ⨯ mix deps.compile mjml                                                                                                                                                                                   
==> mjml
Compiling NIF crate :mjml_nif (native/mjml_nif)...

Compiling on macOS requires special link args in order to compile
correctly.

Rustler is currently working around this issue in the compiler task.
This will be removed in v1.0.0 in favor of a user supplied .cargo/config
file.

To remove this warning, please create /Users/JRock/projects/blackbelt/deps/mjml/native/mjml_nif/.cargo/config
with the following content:

      [target.x86_64-apple-darwin]
      rustflags = [
          "-C", "link-arg=-undefined",
          "-C", "link-arg=dynamic_lookup",
      ]

See https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/MachOTopics/1-Articles/executing_files.html
for more details.


could not compile dependency :mjml, "mix compile" failed. You can recompile this dependency with "mix deps.compile mjml", update it with "mix deps.update mjml" or clean it with "mix deps.clean mjml"
** (ErlangError) Erlang error: :enoent
    (elixir 1.11.2) lib/system.ex:815: System.cmd("cargo", ["rustc", "--release", "--", "-C", "link-arg=-undefined", "-C", "link-arg=dynamic_lookup"], [cd: "/Users/JRock/projects/blackbelt/deps/mjml/native/mjml_nif", stderr_to_stdout: true, env: [{"CARGO_TARGET_DIR", "/Users/JRock/projects/blackbelt/_build/dev/rustler_crates/mjml_nif"}], into: %IO.Stream{device: :standard_io, line_or_bytes: :line, raw: false}])
    (rustler 0.21.1) lib/mix/tasks/compile.rustler.ex:59: Mix.Tasks.Compile.Rustler.compile_crate/1
    (elixir 1.11.2) lib/enum.ex:1399: Enum."-map/2-lists^map/1-0-"/2
    (rustler 0.21.1) lib/mix/tasks/compile.rustler.ex:15: Mix.Tasks.Compile.Rustler.run/1
    (mix 1.11.2) lib/mix/task.ex:394: Mix.Task.run_task/3
    (mix 1.11.2) lib/mix/tasks/compile.all.ex:90: Mix.Tasks.Compile.All.run_compiler/2
    (mix 1.11.2) lib/mix/tasks/compile.all.ex:70: Mix.Tasks.Compile.All.compile/4
    (mix 1.11.2) lib/mix/tasks/compile.all.ex:57: Mix.Tasks.Compile.All.with_logger_app/2

I attempted to follow those instructions, but you'll see in the cargo compilation line that those two args things are listed. So I believe I've done what was asked from that warning.

Here's my system info:

⋊> ~on main ⨯ system_profiler SPSoftwareDataType                                                                                                                                                                      

Software:

    System Software Overview:

      System Version: macOS 11.1 (20C69)
      Kernel Version: Darwin 20.2.0
      Boot Volume: Macintosh HD
      Boot Mode: Normal
      Computer Name: Jonathan’s MacBook Pro
      User Name: Jono
      Secure Virtual Memory: Enabled
      System Integrity Protection: Enabled
      Time since boot: 1 day 2:52

Issues on M1

I am having issues getting this library to work on an M1 Mac. Any ideas on what we need to do to resolve this?

[warning] The on_load function for module Elixir.Mjml returned:
{:error,
 {:load_failed,
  'Failed to load NIF library: \'dlopen(/repo/_build/dev/lib/mjml/priv/native/libmjml_nif.so, 0x0002): tried: \'/Repo/_build/dev/lib/mjml/priv/native/libmjml_nif.so\' (mach-o file, but is an incompatible architecture (have \'x86_64\', need \'arm64e\')), \'/usr/local/lib/libmjml_nif.so\' (no such file), \'/usr/lib/libmjml_nif.so\' (no such file), \'/Repo/deps/mjml/priv/native/libmjml_nif.so\' (mach-o file, but is an incompatible architecture (have \'x86_64\', need \'arm64e\')), \'/usr/local/lib/libmjml_nif.so\' (no such file), \'/usr/lib/libmjml_nif.so\' (no such file)\''}}

[warning] The on_load function for module Elixir.Mjml returned:
{:error,
 {:load_failed,
  'Failed to load NIF library: \'dlopen(/Repo/_build/dev/lib/mjml/priv/native/libmjml_nif.so, 0x0002): tried: \'/Repo/_build/dev/lib/mjml/priv/native/libmjml_nif.so\' (mach-o file, but is an incompatible architecture (have \'x86_64\', need \'arm64e\')), \'/usr/local/lib/libmjml_nif.so\' (no such file), \'/usr/lib/libmjml_nif.so\' (no such file), \'/Repo/deps/mjml/priv/native/libmjml_nif.so\' (mach-o file, but is an incompatible architecture (have \'x86_64\', need \'arm64e\')), \'/usr/local/lib/libmjml_nif.so\' (no such file), \'/usr/lib/libmjml_nif.so\' (no such file)\''}}

Invalid format error when upgrading to v2

I've just upgraded our app to the recently released v2 and I'm now getting errors parsing our MJML templates (they were fine on v1.5.0).

I've tested them in the online editor and they render fine there. Here's an example:

template ="""
<mjml>
  <mj-head>
    <mj-attributes>
      <mj-all font-family="'Inter', 'Helvetica', 'Arial', sans-serif"></mj-all>
    </mj-attributes>
    <mj-font href="https://fonts.googleapis.com/css?family=Inter:normal,italic,bold&display=swap" name="Inter">
    </mj-font>
    <mj-title>Company</mj-title>
    <mj-preview>Reset your password</mj-preview>
  </mj-head>
  <mj-body background-color="#EEEDEA">
    <mj-section background-color="#fff" border-bottom="none" border-left="none" border-right="none" border-top="10px solid #F00" padding-bottom="0px" padding-left="40px" padding-right="40px" padding-top="20px">
      <mj-column padding="0">
        <mj-image src="https://dev.example.com/images/email/logo.png" align="center" border="none" width="50px" height="50px" border-radius="10px" padding-left="0px" padding-right="0px" padding-bottom="0px" padding-top="0">
        </mj-image>
        <mj-spacer height="30px"></mj-spacer>
        <mj-text align="center" color="#231F20" font-family="'Inter', 'Helvetica', 'Arial', sans-serif" font-size="24px" line-height="1.25" padding="10px">
          Reset your password
        </mj-text>
      </mj-column>
    </mj-section>
    <mj-section background-color="#fff" border-radius="0px 0px 10px 10px" padding-bottom="0px" padding-left="40px" padding-right="40px" padding-top="0px">
      <mj-column padding="0">

        <mj-text align="center" color="#231F20" font-size="16px" line-height="1.5" padding="10px">
          <span style="word-spacing: normal;">
            You can reset your password by clicking the button below
          </span>
        </mj-text>
        <mj-spacer height="30px"></mj-spacer>
        <mj-button background-color="#F00" border-radius="10px" color="#fff" font-size="16px" line-height="1.5" padding="0px" width="100%" font-weight="bold" href="https://google.com">

          Reset your password <span aria-hidden="true">→</span>

        </mj-button>

        <mj-spacer height="50px"></mj-spacer>
      </mj-column>
    </mj-section>
    <mj-section padding="20px">
      <mj-column padding="0">
        <mj-text align="center" color="#acacac" font-size="12px" line-height="1.5" padding-bottom="10px" padding-left="50px" padding-right="50px" padding-top="10px" padding="10px">
          &copy; Company
        </mj-text>
      </mj-column>
    </mj-section>
  </mj-body>
</mjml>
"""

Mjml.to_html(template)
{:error, "invalid format at position 250..251"}

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.