Giter Site home page Giter Site logo

Instructions for Examples about magnus HOT 3 CLOSED

matsadler avatar matsadler commented on August 27, 2024
Instructions for Examples

from magnus.

Comments (3)

matsadler avatar matsadler commented on August 27, 2024 1

You didn't give an example of the exact situation you're experiencing the warning, but there is a bug somewhere in RubyGems and/or Bundler that causes that message to appear for any native extension gem (Rust or C) that is in the Gemfile as a path dependency, e.g. gem "foo", path: "/path/to/foo" (the gemspec line in a Gemfile will also create a path dependency to the current directory), so I'm guessing it's that.

from magnus.

matsadler avatar matsadler commented on August 27, 2024

The examples like example/fibonacci.rs can be run like cargo run --example fibonacci.


The examples like examples/rust_blank can be run like:

cd examples/rust_blank
rake test

For an example of a complete gem, see https://github.com/matsadler/halton-rb

The tests can be run with rake test.

That can be built into a .gem file with gem build halton.gemspec and then installed with gem install halton-0.3.0.gem (or whatever version was built). Once installed you could use it like:

> irb
irb(main):001:0> require "halton"
=> true
irb(main):002:0> Halton.number(2, 1)
=> 0.5

That will build a gem that contains the Rust source, and then compiles the Rust code when it is installed. To instead compile the Rust code when the gem is built run rake native gem, and you will find the .gem file is named something like halton-0.3.0-arm64-darwin-22.gem. In this example the gem would only work on ARM (Apple Silicon, i.e. M1, M2, etc) Macs, because that's where I compiled it.

It's possible to cross-compile a gem to contain pre-compiled code for multiple operating systems / CPU architectures, but that's time consuming to get working (or in my case remember how it works), I'd recommend using the oxidize-rb/actions/cross-gem GitHub action in that case.

from magnus.

topofocus avatar topofocus commented on August 27, 2024

Hi,
thanks for the examples.
I followed your advise and cloned the halton-repository, executed bundle install and bundle exec rake compile. Everything worked well.
Except an annoying warning.

Every time I start a console and require 'halton' this is displayed

Ignoring halton-0.3.0 because its extensions are not build.

The rust extension is loaded correctly. Whats the reason and how to get rid of that message?

from magnus.

Related Issues (20)

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.