wasmerio / wasmer-ruby Goto Github PK
View Code? Open in Web Editor NEWππΈ WebAssembly runtime for Ruby
Home Page: https://wasmer.io
License: MIT License
ππΈ WebAssembly runtime for Ruby
Home Page: https://wasmer.io
License: MIT License
Ruby 2.7 has been released, https://www.ruby-lang.org/en/news/2019/12/25/ruby-2-7-0-released/. We should ensure the extension runs under this version.
See danielpclark/rutie#145 for the context.
The idea is to migrate rutie-derive
and rutie-derive-macros
inside rutie
itself. The crates must be polished first I reckon. The question is: Where do we polish it? Here, or inside rutie
?
In Ruby 3.2 all the wasmer classes when creating an instance now show a warning similar to:
warning: undefining the allocator of T_DATA class Wasmer::Store
It's not just Wasmer::Store that does this but I also see it on Wasmer::Module
, Wasmer::Wasi::StateBuilder
, Wasmer::Wasi::Environment
and Wasmer::ImportObject
.
% irb
irb(main):001:0> require "wasmer"
=> true
irb(main):002:0> Wasmer::Store.new
(irb):2: warning: undefining the allocator of T_DATA class Wasmer::Store
The instance should be created without a warning.
I get a warning. It can be suppressed via $VERBOSE
(or Rails' silence_warnings
which is a wrapper for $VERBSOSE
). The actual functionality seems to all work just fine.
I was previously using Ruby 3.0.4 and did not get a warning with that version.
Hi there,
It is unclear to me whether one can access exported Wasm globals with ruby-ext-wasm. I tried and I got some kind of weird errors when instatiating a wasm module with exported globals like "global must be a const" (although the wasm code was perfectly valid)
Thanks!
I am not able to install the gem, should I upgrade anything?
Tell me if you need additional information. Thanks
OS: macOS Mojave 10.14.16
$ rustc -V
rustc 1.30.0 (da5f414c2 2018-10-24)
$ cargo -V
cargo 1.30.0 (36d96825d 2018-10-24)
$ ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin18]
$ gem install wasmer
Fetching wasmer-0.3.0.gem
Fetching rutie-0.0.4.gem
Successfully installed rutie-0.0.4
Building native extensions. This could take a while...
ERROR: Error installing wasmer:
ERROR: Failed to build gem native extension.
current directory: /Users/jose.galisteo/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/wasmer-0.3.0
/Users/jose.galisteo/.rbenv/versions/2.6.5/bin/ruby -rrubygems /Users/jose.galisteo/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/rake-13.0.0/exe/rake RUBYARCHDIR\=/Users/jose.galisteo/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-18/2.6.0-static/wasmer-0.3.0 RUBYLIBDIR\=/Users/jose.galisteo/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-18/2.6.0-static/wasmer-0.3.0
fatal: not a git repository (or any of the parent directories): .git
bundle install
fatal: not a git repository (or any of the parent directories): .git
Fetching gem metadata from https://rubygems.org/.............
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Fetching rake 10.5.0
Installing rake 10.5.0
Fetching ansi 1.5.0
Installing ansi 1.5.0
Using builder 3.2.3
Using bundler 2.0.1
Fetching minitest 5.13.0
Installing minitest 5.13.0
Using ruby-progressbar 1.10.1
Fetching minitest-reporters 1.4.2
Installing minitest-reporters 1.4.2
Fetching color_pound_spec_reporter 0.0.9
Installing color_pound_spec_reporter 0.0.9
Using rutie 0.0.4
Using wasmer 0.3.0 from source at `.`
Bundle complete! 6 Gemfile dependencies, 10 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
cargo build --release
error: unable to get packages from source
Caused by:
failed to parse manifest at `/Users/jose.galisteo/.cargo/registry/src/github.com-1ecc6299db9ec823/wasmer-clif-backend-0.5.5/Cargo.toml`
Caused by:
feature `rename-dependency` is required
this Cargo does not support nightly features, but if you
switch to nightly channel you can add
`cargo-features = ["rename-dependency"]` to enable this feature
rake aborted!
Command failed with status (101): [cargo build --release...]
Tasks: TOP => default => test => build_lib
(See full trace by running task with --trace)
rake failed, exit code 1
Gem files will remain installed in /Users/jose.galisteo/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/wasmer-0.3.0 for inspection.
Results logged to /Users/jose.galisteo/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-18/2.6.0-static/wasmer-0.3.0/gem_make.out
When trying to call an exported WASM function from Ruby with a negative integer parameter an exception is raised.
The function call is:
@exports.i32_to_s.call(-1)
the parameter signature of the WASM func is i32
and the exception raised is
TypeError: out of range integral type conversion attempted
I have no trouble passing a positive value.
Is this the expected behavior ? How can I pass a negative value ? Do i Have to pass the 2-complement positive value (meaning 65535 here) ?
Thank you for your help.
Thanks for the bug report!
I'm trying to install wasmer with Ruby 2.6.3 and Rust 1.46.0, but install fails with a bunch of errors like error:
externfn uses type
instance::RubyInstance, which is not FFI-safe
(rutie issue #128. I have a number of other rutie projects and those are fine (I started getting the same issue when Rust 1.46 came out).
gem install wasmer
Successful install.
current directory: /Users/sloveless/.gem/ruby/2.6.3/gems/wasmer-0.4.0
/Users/sloveless/.rubies/ruby-2.6.3/bin/ruby -I/Users/sloveless/.rubies/ruby-2.6.3/lib/ruby/site_ruby/2.6.0/rubygems -rrubygems /Users/sloveless/.gem/ruby/2.6.3/gems/rake-13.0.1/exe/rake RUBYARCHDIR\=/Users/sloveless/.gem/ruby/2.6.3/extensions/x86_64-darwin-19/2.6.0/wasmer-0.4.0 RUBYLIBDIR\=/Users/sloveless/.gem/ruby/2.6.3/extensions/x86_64-darwin-19/2.6.0/wasmer-0.4.0
fatal: not a git repository (or any of the parent directories): .git
bundle install
fatal: not a git repository (or any of the parent directories): .git
Fetching gem metadata from https://rubygems.org/...
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Using rake 13.0.1
Using builder 3.2.4
Using bundler 2.1.4
Using minitest 5.14.2
Using ruby-progressbar 1.10.1
Using rutie 0.0.4
Fetching ansi 1.5.0
Using wasmer 0.4.0 from source at `.`
ctags: Warning: -f option specified more than once, last value used
ctags: Warning: cannot open source file "../extensions/x86_64-darwin-19/2.6.0/wasmer-0.4.0" : No such file or directory
Installing ansi 1.5.0
ctags: Warning: -f option specified more than once, last value used
Fetching minitest-reporters 1.4.2
Installing minitest-reporters 1.4.2
ctags: Warning: -f option specified more than once, last value used
Fetching color_pound_spec_reporter 0.0.9
Installing color_pound_spec_reporter 0.0.9
ctags: Warning: -f option specified more than once, last value used
Bundle complete! 6 Gemfile dependencies, 10 gems now installed.
Gems in the group production were not installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
cargo build --release
Downloading crates ...
Downloaded cranelift-codegen-shared v0.52.0
Downloaded wasmer-clif-fork-frontend v0.52.0
Downloaded wasmparser v0.45.2
Downloaded cranelift-codegen v0.52.0
Downloaded wasmer-runtime-core v0.14.1
Downloaded wasmer-clif-backend v0.14.1
Downloaded serde-bench v0.0.7
Downloaded page_size v0.4.2
Downloaded wasmer-runtime v0.14.1
Downloaded cranelift-codegen-meta v0.52.0
Downloaded cranelift-entity v0.52.0
Downloaded cranelift-native v0.52.0
Downloaded cranelift-bforest v0.52.0
Downloaded blake3 v0.1.5
Downloaded wasmer-clif-fork-wasm v0.52.0
Compiling semver-parser v0.7.0
Compiling cfg-if v0.1.10
Compiling typenum v1.11.2
Compiling autocfg v1.0.0
Compiling libc v0.2.67
Compiling cc v1.0.50
Compiling proc-macro2 v1.0.9
Compiling unicode-xid v0.2.0
Compiling syn v1.0.16
Compiling byteorder v1.3.4
Compiling lazy_static v1.4.0
Compiling maybe-uninit v2.0.0
Compiling smallvec v1.2.0
Compiling serde v1.0.104
Compiling cranelift-codegen-shared v0.52.0
Compiling cranelift-entity v0.52.0
Compiling scopeguard v1.1.0
Compiling target-lexicon v0.9.0
Compiling log v0.4.8
Compiling bitflags v1.2.1
Compiling subtle v1.0.0
Compiling constant_time_eq v0.1.5
Compiling arrayref v0.3.6
Compiling arrayvec v0.5.1
Compiling nix v0.15.0
Compiling rayon-core v1.7.0
Compiling wasmparser v0.45.2
Compiling void v1.0.2
Compiling either v1.5.3
Compiling hex v0.4.2
Compiling rutie v0.7.0
Compiling semver v0.9.0
Compiling crossbeam-utils v0.7.2
Compiling crossbeam-epoch v0.8.2
Compiling indexmap v1.3.2
Compiling lock_api v0.3.3
Compiling cranelift-codegen-meta v0.52.0
Compiling cranelift-bforest v0.52.0
Compiling rustc_version v0.2.3
Compiling blake3 v0.1.5
Compiling memoffset v0.5.3
Compiling raw-cpuid v7.0.3
Compiling quote v1.0.2
Compiling smallvec v0.6.13
Compiling generic-array v0.12.3
Compiling num_cpus v1.12.0
Compiling parking_lot_core v0.7.0
Compiling errno v0.2.4
Compiling page_size v0.4.2
Compiling memmap v0.7.0
Compiling crossbeam-queue v0.2.1
Compiling digest v0.8.1
Compiling crypto-mac v0.7.0
Compiling parking_lot v0.10.0
Compiling crossbeam-deque v0.7.3
Compiling wasmer-runtime-core v0.14.1
Compiling rayon v1.3.0
Compiling thiserror-impl v1.0.11
Compiling serde_derive v1.0.104
Compiling bincode v1.2.1
Compiling serde-bench v0.0.7
Compiling serde_bytes v0.11.3
Compiling thiserror v1.0.11
Compiling cranelift-codegen v0.52.0
Compiling wasmer-clif-fork-frontend v0.52.0
Compiling cranelift-native v0.52.0
Compiling wasmer-clif-fork-wasm v0.52.0
Compiling wasmer-clif-backend v0.14.1
Compiling wasmer-runtime v0.14.1
Compiling ruby-ext-wasm v0.4.0 (/Users/sloveless/.gem/ruby/2.6.3/gems/wasmer-0.4.0)
error: `extern` fn uses type `instance::RubyInstance`, which is not FFI-safe
--> src/instance/mod.rs:51:5
|
51 | RubyInstance,
| ^^^^^^^^^^^^ not FFI-safe
|
note: the lint level is defined here
--> src/lib.rs:1:9
|
1 | #![deny(warnings)]
| ^^^^^^^^
= note: `#[deny(improper_ctypes_definitions)]` implied by `#[deny(warnings)]`
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/instance/mod.rs:47:1
|
47 | class!(RubyInstance);
| ^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `extern` fn uses type `instance::RubyInstance`, which is not FFI-safe
--> src/instance/mod.rs:51:5
|
51 | RubyInstance,
| ^^^^^^^^^^^^ not FFI-safe
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/instance/mod.rs:47:1
|
47 | class!(RubyInstance);
| ^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `extern` fn uses type `instance::exports::RubyExportedFunctions`, which is not FFI-safe
--> src/instance/exports.rs:178:5
|
178 | RubyExportedFunctions,
| ^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/instance/exports.rs:174:1
|
174 | class!(RubyExportedFunctions);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `extern` fn uses type `instance::exports::RubyExportedFunctions`, which is not FFI-safe
--> src/instance/exports.rs:196:13
|
196 | itself: RubyExportedFunctions,
| ^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/instance/exports.rs:174:1
|
174 | class!(RubyExportedFunctions);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `extern` fn uses type `rutie::AnyObject`, which is not FFI-safe
--> src/instance/exports.rs:197:6
|
197 | ) -> AnyObject {
| ^^^^^^^^^ not FFI-safe
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
error: `extern` fn uses type `instance::globals::RubyExportedGlobals`, which is not FFI-safe
--> src/instance/globals.rs:77:5
|
77 | RubyExportedGlobals,
| ^^^^^^^^^^^^^^^^^^^ not FFI-safe
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/instance/globals.rs:73:1
|
73 | class!(RubyExportedGlobals);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `extern` fn uses type `instance::globals::RubyExportedGlobals`, which is not FFI-safe
--> src/instance/globals.rs:95:13
|
95 | itself: RubyExportedGlobals,
| ^^^^^^^^^^^^^^^^^^^ not FFI-safe
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/instance/globals.rs:73:1
|
73 | class!(RubyExportedGlobals);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `extern` fn uses type `instance::globals::RubyExportedGlobal`, which is not FFI-safe
--> src/instance/globals.rs:96:6
|
96 | ) -> RubyExportedGlobal {
| ^^^^^^^^^^^^^^^^^^ not FFI-safe
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/instance/globals.rs:155:1
|
155 | class!(RubyExportedGlobal);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `extern` fn uses type `instance::globals::RubyExportedGlobal`, which is not FFI-safe
--> src/instance/globals.rs:159:5
|
159 | RubyExportedGlobal,
| ^^^^^^^^^^^^^^^^^^ not FFI-safe
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/instance/globals.rs:155:1
|
155 | class!(RubyExportedGlobal);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `extern` fn uses type `memory::RubyMemory`, which is not FFI-safe
--> src/memory/mod.rs:77:5
|
77 | RubyMemory,
| ^^^^^^^^^^ not FFI-safe
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/memory/mod.rs:73:1
|
73 | class!(RubyMemory);
| ^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `extern` fn uses type `module::Module`, which is not FFI-safe
--> src/module.rs:7:5
|
7 | Module,
| ^^^^^^ not FFI-safe
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/module.rs:4:1
|
4 | class!(Module);
| ^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `extern` fn uses type `memory::view::uint8array::RubyMemoryView`, which is not FFI-safe
--> src/memory/view.rs:90:17
|
90 | RubyMemoryView,
| ^^^^^^^^^^^^^^ not FFI-safe
...
140 | memory_view!(uint8array over u8|1);
| ----------------------------------- in this macro invocation
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/memory/view.rs:140:1
|
140 | memory_view!(uint8array over u8|1);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `extern` fn uses type `memory::view::int8array::RubyMemoryView`, which is not FFI-safe
--> src/memory/view.rs:90:17
|
90 | RubyMemoryView,
| ^^^^^^^^^^^^^^ not FFI-safe
...
141 | memory_view!(int8array over i8|1);
| ---------------------------------- in this macro invocation
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/memory/view.rs:141:1
|
141 | memory_view!(int8array over i8|1);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `extern` fn uses type `memory::view::uint16array::RubyMemoryView`, which is not FFI-safe
--> src/memory/view.rs:90:17
|
90 | RubyMemoryView,
| ^^^^^^^^^^^^^^ not FFI-safe
...
142 | memory_view!(uint16array over u16|2);
| ------------------------------------- in this macro invocation
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/memory/view.rs:142:1
|
142 | memory_view!(uint16array over u16|2);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `extern` fn uses type `memory::view::int16array::RubyMemoryView`, which is not FFI-safe
--> src/memory/view.rs:90:17
|
90 | RubyMemoryView,
| ^^^^^^^^^^^^^^ not FFI-safe
...
143 | memory_view!(int16array over i16|2);
| ------------------------------------ in this macro invocation
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/memory/view.rs:143:1
|
143 | memory_view!(int16array over i16|2);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `extern` fn uses type `memory::view::uint32array::RubyMemoryView`, which is not FFI-safe
--> src/memory/view.rs:90:17
|
90 | RubyMemoryView,
| ^^^^^^^^^^^^^^ not FFI-safe
...
144 | memory_view!(uint32array over u32|4);
| ------------------------------------- in this macro invocation
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/memory/view.rs:144:1
|
144 | memory_view!(uint32array over u32|4);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `extern` fn uses type `memory::view::int32array::RubyMemoryView`, which is not FFI-safe
--> src/memory/view.rs:90:17
|
90 | RubyMemoryView,
| ^^^^^^^^^^^^^^ not FFI-safe
...
145 | memory_view!(int32array over i32|4);
| ------------------------------------ in this macro invocation
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/memory/view.rs:145:1
|
145 | memory_view!(int32array over i32|4);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 17 previous errors
error: could not compile `ruby-ext-wasm`.
To learn more, run the command again with --verbose.
rake aborted!
Command failed with status (101): [cargo build --release...]
/Users/sloveless/.gem/ruby/2.6.3/gems/wasmer-0.4.0/Rakefile:7:in `block in <top (required)>'
/Users/sloveless/.gem/ruby/2.6.3/gems/rake-13.0.1/exe/rake:27:in `<main>'
Tasks: TOP => default => test => build_lib
(See full trace by running task with --trace)
rake failed, exit code 1
At the current version of WebAssembly, an instance has at most one memory instance, but it may not be true in the future.
If there are more than one memory, the interface of instance.memory
will not be the best interface.
http://webassembly.github.io/spec/core/syntax/modules.html#syntax-mem
In the current version of WebAssembly, at most one memory may be defined or imported in a single module, and all constructs implicitly reference this memory 0. This restriction may be lifted in future versions.
Just for your information, the memory is exposed to the JavaScript API through exportsObject
, ie. instance.exports.mem1
.
https://webassembly.github.io/spec/js-api/#dom-module-exports
I cannot call an exported WASM function from a wasmer instance. There seems to be some kind of runtime function and/opr static data wasmer is expecting from a WASM module but which ones ?
Any help is much appreciated
I wrote the following minimal webassembly module in WAT text file
(module $simple
(export "memory" (memory $0))
(export "set_freep" (func $set_freep))
(memory $0 1)
(func $set_freep (param $value i32)
(i32.store (i32.const 20) (local.get $value))
)
(func $main)
)
then compiled it to WASM code with wat2wasm (from the wabt toolkit). It is a straight compilation from WASM text format to wasm binary format with no additional runtime code if any kind
FInally I'm trying to instantiate this WASM module with wasmer
require 'wasmer'
bytes = File.read('/tmp/simple.wasm')
instance = Instance.new(bytes)
instance.exports.set_freep(1)
This code keeps generating the following error:
hread '<unnamed>' panicked at 'index out of bounds: the len is 0 but the index is 0', /rustc/3c235d5600393dfe6c36eeed34042efad8d4f26e/src/libcore/slice/mod.rs:2686:10
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
fatal runtime error: failed to initiate panic, error 5
Aborted
And with stack trace
<ExportedFunctions:0x000057fb04b3e500>
thread '<unnamed>' panicked at 'index out of bounds: the len is 0 but the index is 0', /rustc/3c235d5600393dfe6c36eeed34042efad8d4f26e/src/libcore/slice/mod.rs:2686:10
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
1: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:71
2: std::panicking::default_hook::{{closure}}
at src/libstd/sys_common/backtrace.rs:59
at src/libstd/panicking.rs:197
3: std::panicking::default_hook
at src/libstd/panicking.rs:211
4: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:474
5: std::panicking::continue_panic_fmt
at src/libstd/panicking.rs:381
6: rust_begin_unwind
at src/libstd/panicking.rs:308
7: core::panicking::panic_fmt
at src/libcore/panicking.rs:85
8: core::panicking::panic_bounds_check
at src/libcore/panicking.rs:61
9: wasmer::instance::ExportedFunctions::method_missing
10: wasmer::instance::ruby_exported_functions_method_missing
....
....
Because it's cool!
Example applications do not work
install rust, install wasmer gem, clone repo and run example applications
Examples should work
$ ruby simple.rb
simple.rb:7:in `<main>': uninitialized constant Wasmer::Instance (NameError)
Did you mean? Instance
$ ruby memory.rb
memory.rb:7:in `<main>': uninitialized constant Wasmer::Instance (NameError)
Did you mean? Instance
$ ruby greet.rb
greet.rb:9:in `<main>': uninitialized constant Wasmer::Instance (NameError)
Rutie
is able to open library
Rutie.new(:wasmer).init('Init_wasmer', "$HOME/wasmerio/ruby-ext-wasm/target/")
=> #<Fiddle::Pointer:0x00007f927603caa0 ptr=0x00007ffeea97d4f0 size=0 free=0x0000000000000000>
$ rustc --version
rustc 1.36.0 (a53f9df32 2019-07-03)
$ wasmer --version
wasmer 0.6.0
$ ruby --version
ruby 2.3.8p459 (2018-10-18 revision 65136) [x86_64-darwin18]
OS: MacOS 10.14.6
Could more examples be added?
Ideally something like a slow build-up step that showcases what can be done with it.
I'd also love some example where we could add functionality to a simple sinatra
application or something like that.
Right now I am a bit clueless what we can do with wasmer. Even opal makes this
more clear than wasmer.
I'm using a statically linked version of Ruby 2.7.2 on macOS. I can build the gem (it links against libruby.2.7-static.a
) but when I require the gem, I get a seg fault at lib/wasmer.rb:31
. If I use a dynamically linked version of Ruby 2.7.2 (where the gem links against libruby.2.7.dylib
) everything works fine.
RUBY_CONFIGURE_OPTS="--disable-shared" ruby-build 2.7.2 /path/to/install
)/path/to/install/lib
contains libruby.2.7-static.a
require 'wasmer'
No seg fault occurs.
Seg fault occurs.
Repeating the same steps with RUBY_CONFIGURE_OPTS="--enabled-shared"
works just fine.
I have a number of import statement in my WASM code to declare WASI functions and wahen I instantiate Wasmer and try to execute, I get the following error
RuntimeError: Failed to instantiate the module:
5 link errors:
(1 of 5) Import not found, namespace: wasi_unstable, name: args_sizes_get
(2 of 5) Import not found, namespace: wasi_unstable, name: args_get
(3 of 5) Import not found, namespace: wasi_unstable, name: fd_write
(4 of 5) Import not found, namespace: wasi_unstable, name: fd_read
(5 of 5) Import not found, namespace: wasi_unstable, name: proc_exit
Wasmer is supposed to support WASI so I was wondering if this could be something to modify in ruby-ext-wasm to "make the connection" with imported functions ? (Not specifically WASI functions by the way....)
Thanks!
Hello! Would it be possible to bump this gem to use the latest version of wasmer
which is 2.3.0 as of this writing or possibly 3.0 when it's released soon?
Thanks for all your work on this!
Could support for WCGI also be added?
Not sure if this fits into wasmer's scope. It would be great if one could use
this from a .cgi file though.
It seems like the ruby sdk/client is still a bit behind the other languages. Would be awesome if more functionality was supported, for example terminate in host call, serialization and exposing host (imported) functions.
Source:
https://docs.wasmer.io/ecosystem/wasmer/wasmer-features#language-embeddings
For our use case, we'd like to pass in a bunch of data from the host (e.g. JSON like data), pass in a bunch of functions, accessible to the WASM-code, and then call the function exposed by WASM (with ability to abort/terminate from host).
I see that a lot of the code for this project is written in Rust. I'm just curious if you've written this as a C extension, with Rust instead of C via Helix. I'm also curious if it is thus bound to MRI only or if it can run on other Ruby implementations, such as the up-and-coming speed demon TruffleRuby.
RubyGems install of wasmer 0.4.0 fails on Ruby 3.0.1.
(NOTE: Ruby 3 has been released as stable in December.)
gem install wasmer
(on Ruby 3.0.1).Install the package and not to fail.
gem install wasmer
Building native extensions. This could take a while...
ERROR: Error installing wasmer:
ERROR: Failed to build gem native extension.
current directory: /opt/rubies/ruby-3.0.1/lib/ruby/gems/3.0.0/gems/wasmer-0.4.0/opt/rubies/ruby-3.0.1/bin/ruby -I/opt/rubies/ruby-3.0.1/lib/ruby/3.0.0 -rrubygems /opt/rubies/ruby-3.0.1/lib/ruby/gems/3.0.0/gems/r
ake-13.0.3/exe/rake RUBYARCHDIR\=/opt/rubies/ruby-3.0.1/lib/ruby/gems/3.0.0/extensions/x86_64-linux/3.0.0-static/wasmer-0.4.0 RUBYLI
BDIR\=/opt/rubies/ruby-3.0.1/lib/ruby/gems/3.0.0/extensions/x86_64-linux/3.0.0-static/wasmer-0.4.0
fatal: not a git repository (or any of the parent directories): .git
bundle install
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application
for all non-root users on this machine.
fatal: not a git repository (or any of the parent directories): .git
Fetching gem metadata from https://rubygems.org/...
Resolving dependencies...
Using rake 13.0.3
Using ansi 1.5.0
Using builder 3.2.4
Using bundler 2.2.15
Using minitest 5.14.4
Using ruby-progressbar 1.11.0
Using minitest-reporters 1.4.3
Using color_pound_spec_reporter 0.0.9
Using rutie 0.0.4
Using wasmer 0.4.0 from source at `.`
Bundle complete! 6 Gemfile dependencies, 10 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
cargo build --release
rake aborted!
Command failed with status (127): [cargo build --release...]
Tasks: TOP => default => test => build_lib
(See full trace by running task with --trace)
rake failed, exit code 1
Gem files will remain installed in /opt/rubies/ruby-3.0.1/lib/ruby/gems/3.0.0/gems/wasmer-0.4.0 for inspection.
Results logged to /opt/rubies/ruby-3.0.1/lib/ruby/gems/3.0.0/extensions/x86_64-linux/3.0.0-static/wasmer-0.4.0/gem_make.out
We had some team members report issues when installing wasmer on MacOS with rustc 1.75.0 and Ruby 3.2.2. I was able to reproduce when I upgraded my rustc to 1.75.0, but when returning to 1.73.0 (which is what I was on prior), installation worked.
I'd expect the gem to compile and install successfully.
When attempting to install with rustc 1.75.0, we get the following:
Compiling wasmer v1.0.0 (/Users/{user}/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/wasmer-1.0.0/crates/wasmer)
error: unused import: `ClassInfo`
--> crates/wasmer/src/prelude.rs:3:62
|
3 | pub use rutie_derive::{rubyclass, rubyfunction, rubymethods, ClassInfo, UpcastRubyClass};
| ^^^^^^^^^
|
note: the lint level is defined here
--> crates/wasmer/src/lib.rs:1:9
|
1 | #![deny(warnings)]
| ^^^^^^^^
= note: `#[deny(unused_imports)]` implied by `#[deny(warnings)]`
error: could not compile `wasmer` (lib) due to previous error
rake aborted!
Hi!
Thank you for creating very useful library.
I am building a tool as a hobby to call WebAssembly functions generated by Crystal language from Ruby to speed up. When I tried to pass a Ruby array to Wasm, I noticed that int64_view
, uint64_view
, float32_view
, and float64_view
were not yet provided.
new methods: uint64_view
, int64_view
, float32_view
, and float64_view
new classes Uint64View
, Int64View
, Float32View
, and Float64View
The use of binary strings is a possible alternative. In that case, Ruby methods such as pack
and unpack
could be used.
You can find similar functionality in Python bindings.
wasmerio/wasmer-python@b484654
Hi guys, when I install this gem, it said 'could not compile ruby-ext-wasm
' with 17 errors. It's all about "not FFI-safe". Could you give me some advice here?
(I'm using Ubuntu 20.04, and rbenv)
rustc -V
rustc 1.46.0 (04488afe3 2020-08-24)
rustup -V
rustup 1.22.1 (b01adbbc3 2020-07-08)
cargo -V
cargo 1.46.0 (149022b1d 2020-07-17)
ruby -v
ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-linux]
Error log
$ gem install wasmer --verbose ⬑ 12.18.3 [Β±signing ββ]
HEAD https://rubygems.org/api/v1/dependencies
200 OK
GET https://rubygems.org/api/v1/dependencies?gems=wasmer
200 OK
GET https://rubygems.org/api/v1/dependencies?gems=rutie
200 OK
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/.cargo/config
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/.github/ISSUE_TEMPLATE/---bug-report.md
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/.github/ISSUE_TEMPLATE/---feature-request.md
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/.github/ISSUE_TEMPLATE/--question.md
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/.github/workflows/test.yml
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/.gitignore
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/CHANGELOG.md
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/Cargo.lock
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/Cargo.toml
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/Gemfile
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/LICENSE
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/README.md
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/Rakefile
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/bors.toml
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/justfile
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/lib/wasmer.rb
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/lib/wasmer/version.rb
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/src/error.rs
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/src/instance/exports.rs
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/src/instance/globals.rs
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/src/instance/mod.rs
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/src/lib.rs
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/src/memory/mod.rs
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/src/memory/view.rs
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/src/module.rs
/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0/wasmer.gemspec
Building native extensions. This could take a while...
current directory: /home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0
["/home/nam/.rbenv/versions/2.6.6/bin/ruby", "-rrubygems", "/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/exe/rake", "RUBYARCHDIR=/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0/wasmer-0.4.0", "RUBYLIBDIR=/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0/wasmer-0.4.0"]
bundle install
Fetching gem metadata from https://rubygems.org/...
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Using rake 13.0.1
Using ansi 1.5.0
Using builder 3.2.4
Using bundler 2.1.4
Using minitest 5.14.2
Using ruby-progressbar 1.10.1
Using minitest-reporters 1.4.2
Using color_pound_spec_reporter 0.0.9
Using rutie 0.0.4
Using wasmer 0.4.0 from source at `.`
Bundle complete! 6 Gemfile dependencies, 10 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
cargo build --release
Compiling cfg-if v0.1.10
Compiling semver-parser v0.7.0
Compiling autocfg v1.0.0
Compiling libc v0.2.67
Compiling proc-macro2 v1.0.9
Compiling unicode-xid v0.2.0
Compiling cc v1.0.50
Compiling syn v1.0.16
Compiling typenum v1.11.2
Compiling byteorder v1.3.4
Compiling lazy_static v1.4.0
Compiling maybe-uninit v2.0.0
Compiling cranelift-entity v0.52.0
Compiling smallvec v1.2.0
Compiling cranelift-codegen-shared v0.52.0
Compiling serde v1.0.104
Compiling scopeguard v1.1.0
Compiling target-lexicon v0.9.0
Compiling bitflags v1.2.1
Compiling log v0.4.8
Compiling subtle v1.0.0
Compiling arrayref v0.3.6
Compiling constant_time_eq v0.1.5
Compiling arrayvec v0.5.1
Compiling rayon-core v1.7.0
Compiling nix v0.15.0
Compiling void v1.0.2
Compiling wasmparser v0.45.2
Compiling hex v0.4.2
Compiling either v1.5.3
Compiling rutie v0.7.0
Compiling semver v0.9.0
Compiling cranelift-bforest v0.52.0
Compiling lock_api v0.3.3
Compiling cranelift-codegen-meta v0.52.0
Compiling crossbeam-utils v0.7.2
Compiling crossbeam-epoch v0.8.2
Compiling indexmap v1.3.2
Compiling rustc_version v0.2.3
Compiling quote v1.0.2
Compiling memoffset v0.5.3
Compiling generic-array v0.12.3
Compiling smallvec v0.6.13
Compiling num_cpus v1.12.0
Compiling parking_lot_core v0.7.0
Compiling page_size v0.4.2
Compiling errno v0.2.4
Compiling memmap v0.7.0
Compiling crypto-mac v0.7.0
Compiling digest v0.8.1
Compiling blake3 v0.1.5
Compiling raw-cpuid v7.0.3
Compiling parking_lot v0.10.0
Compiling crossbeam-queue v0.2.1
Compiling serde-bench v0.0.7
Compiling bincode v1.2.1
Compiling serde_bytes v0.11.3
Compiling crossbeam-deque v0.7.3
Compiling rayon v1.3.0
Compiling wasmer-runtime-core v0.14.1
Compiling thiserror-impl v1.0.11
Compiling serde_derive v1.0.104
Compiling thiserror v1.0.11
Building [================================================> ] 100/112: cranelift-codegen-meta, serde_derive
Compiling cranelift-codegen v0.52.0
Compiling wasmer-clif-fork-frontend v0.52.0
Compiling cranelift-native v0.52.0
Compiling wasmer-clif-fork-wasm v0.52.0
Compiling wasmer-clif-backend v0.14.1
Compiling wasmer-runtime v0.14.1
Compiling ruby-ext-wasm v0.4.0 (/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0)
error: `extern` fn uses type `instance::RubyInstance`, which is not FFI-safe
--> src/instance/mod.rs:51:5
|
51 | RubyInstance,
| ^^^^^^^^^^^^ not FFI-safe
|
note: the lint level is defined here
--> src/lib.rs:1:9
|
1 | #![deny(warnings)]
| ^^^^^^^^
= note: `#[deny(improper_ctypes_definitions)]` implied by `#[deny(warnings)]`
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/instance/mod.rs:47:1
|
47 | class!(RubyInstance);
| ^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `extern` fn uses type `instance::RubyInstance`, which is not FFI-safe
--> src/instance/mod.rs:51:5
|
51 | RubyInstance,
| ^^^^^^^^^^^^ not FFI-safe
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/instance/mod.rs:47:1
|
47 | class!(RubyInstance);
| ^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `extern` fn uses type `instance::exports::RubyExportedFunctions`, which is not FFI-safe
--> src/instance/exports.rs:178:5
|
178 | RubyExportedFunctions,
| ^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/instance/exports.rs:174:1
|
174 | class!(RubyExportedFunctions);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `extern` fn uses type `instance::exports::RubyExportedFunctions`, which is not FFI-safe
--> src/instance/exports.rs:196:13
|
196 | itself: RubyExportedFunctions,
| ^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/instance/exports.rs:174:1
|
174 | class!(RubyExportedFunctions);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `extern` fn uses type `rutie::AnyObject`, which is not FFI-safe
--> src/instance/exports.rs:197:6
|
197 | ) -> AnyObject {
| ^^^^^^^^^ not FFI-safe
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
error: `extern` fn uses type `instance::globals::RubyExportedGlobals`, which is not FFI-safe
--> src/instance/globals.rs:77:5
|
77 | RubyExportedGlobals,
| ^^^^^^^^^^^^^^^^^^^ not FFI-safe
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/instance/globals.rs:73:1
|
73 | class!(RubyExportedGlobals);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `extern` fn uses type `instance::globals::RubyExportedGlobals`, which is not FFI-safe
--> src/instance/globals.rs:95:13
|
95 | itself: RubyExportedGlobals,
| ^^^^^^^^^^^^^^^^^^^ not FFI-safe
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/instance/globals.rs:73:1
|
73 | class!(RubyExportedGlobals);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `extern` fn uses type `instance::globals::RubyExportedGlobal`, which is not FFI-safe
--> src/instance/globals.rs:96:6
|
96 | ) -> RubyExportedGlobal {
| ^^^^^^^^^^^^^^^^^^ not FFI-safe
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/instance/globals.rs:155:1
|
155 | class!(RubyExportedGlobal);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `extern` fn uses type `instance::globals::RubyExportedGlobal`, which is not FFI-safe
--> src/instance/globals.rs:159:5
|
159 | RubyExportedGlobal,
| ^^^^^^^^^^^^^^^^^^ not FFI-safe
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/instance/globals.rs:155:1
|
155 | class!(RubyExportedGlobal);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `extern` fn uses type `memory::RubyMemory`, which is not FFI-safe
--> src/memory/mod.rs:77:5
|
77 | RubyMemory,
| ^^^^^^^^^^ not FFI-safe
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/memory/mod.rs:73:1
|
73 | class!(RubyMemory);
| ^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `extern` fn uses type `module::Module`, which is not FFI-safe
--> src/module.rs:7:5
|
7 | Module,
| ^^^^^^ not FFI-safe
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/module.rs:4:1
|
4 | class!(Module);
| ^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `extern` fn uses type `memory::view::uint8array::RubyMemoryView`, which is not FFI-safe
--> src/memory/view.rs:90:17
|
90 | RubyMemoryView,
| ^^^^^^^^^^^^^^ not FFI-safe
...
140 | memory_view!(uint8array over u8|1);
| ----------------------------------- in this macro invocation
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/memory/view.rs:140:1
|
140 | memory_view!(uint8array over u8|1);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `extern` fn uses type `memory::view::int8array::RubyMemoryView`, which is not FFI-safe
--> src/memory/view.rs:90:17
|
90 | RubyMemoryView,
| ^^^^^^^^^^^^^^ not FFI-safe
...
141 | memory_view!(int8array over i8|1);
| ---------------------------------- in this macro invocation
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/memory/view.rs:141:1
|
141 | memory_view!(int8array over i8|1);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `extern` fn uses type `memory::view::uint16array::RubyMemoryView`, which is not FFI-safe
--> src/memory/view.rs:90:17
|
90 | RubyMemoryView,
| ^^^^^^^^^^^^^^ not FFI-safe
...
142 | memory_view!(uint16array over u16|2);
| ------------------------------------- in this macro invocation
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/memory/view.rs:142:1
|
142 | memory_view!(uint16array over u16|2);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `extern` fn uses type `memory::view::int16array::RubyMemoryView`, which is not FFI-safe
--> src/memory/view.rs:90:17
|
90 | RubyMemoryView,
| ^^^^^^^^^^^^^^ not FFI-safe
...
143 | memory_view!(int16array over i16|2);
| ------------------------------------ in this macro invocation
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/memory/view.rs:143:1
|
143 | memory_view!(int16array over i16|2);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `extern` fn uses type `memory::view::uint32array::RubyMemoryView`, which is not FFI-safe
--> src/memory/view.rs:90:17
|
90 | RubyMemoryView,
| ^^^^^^^^^^^^^^ not FFI-safe
...
144 | memory_view!(uint32array over u32|4);
| ------------------------------------- in this macro invocation
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/memory/view.rs:144:1
|
144 | memory_view!(uint32array over u32|4);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: `extern` fn uses type `memory::view::int32array::RubyMemoryView`, which is not FFI-safe
--> src/memory/view.rs:90:17
|
90 | RubyMemoryView,
| ^^^^^^^^^^^^^^ not FFI-safe
...
145 | memory_view!(int32array over i32|4);
| ------------------------------------ in this macro invocation
|
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
--> src/memory/view.rs:145:1
|
145 | memory_view!(int32array over i32|4);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 17 previous errors
error: could not compile `ruby-ext-wasm`.
To learn more, run the command again with --verbose.
rake aborted!
Command failed with status (101): [cargo build --release...]
Tasks: TOP => default => test => build_lib
(See full trace by running task with --trace)
ERROR: Error installing wasmer:
ERROR: Failed to build gem native extension.
current directory: /home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0
/home/nam/.rbenv/versions/2.6.6/bin/ruby -rrubygems /home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/exe/rake RUBYARCHDIR\=/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0/wasmer-0.4.0 RUBYLIBDIR\=/home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0/wasmer-0.4.0
Building has failed. See above output for more information on the failure.
rake failed, exit code 1
Gem files will remain installed in /home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.4.0 for inspection.
Results logged to /home/nam/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0/wasmer-0.4.0/gem_make.out
Tried to install on macOS 11.4 (Big Sur) and got this error:
No such file or directory - getcwd
# context
which ruby
/Users/my-user/.rubies/ruby-2.6.6/bin/ruby
ruby --version
ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-darwin20]
gem install wasmer -v '0.5.0' --verbose
HEAD https://rubygems.org/api/v1/dependencies
200 OK
GET https://rubygems.org/api/v1/dependencies?gems=wasmer
200 OK
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/.cargo/config
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/.github/ISSUE_TEMPLATE/---bug-report.md
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/.github/ISSUE_TEMPLATE/---feature-request.md
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/.github/ISSUE_TEMPLATE/--question.md
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/.github/workflows/documentation.yml
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/.github/workflows/test.yml
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/.gitignore
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/CHANGELOG.md
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/Cargo.lock
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/Cargo.toml
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/Gemfile
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/LICENSE
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/README.md
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/Rakefile
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/bors.toml
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/rutie-derive-macros/Cargo.toml
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/rutie-derive-macros/README.md
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/rutie-derive-macros/src/class.rs
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/rutie-derive-macros/src/function.rs
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/rutie-derive-macros/src/lib.rs
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/rutie-derive-macros/src/methods.rs
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/rutie-derive/Cargo.toml
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/rutie-derive/README.md
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/rutie-derive/src/lib.rs
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/rutie-derive/src/upcast.rs
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/rutie-test/Cargo.toml
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/rutie-test/src/lib.rs
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/wasmer/Cargo.toml
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/wasmer/README.md
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/wasmer/src/doc.rs
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/wasmer/src/error.rs
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/wasmer/src/exports.rs
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/wasmer/src/externals/function.rs
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/wasmer/src/externals/global.rs
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/wasmer/src/externals/memory.rs
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/wasmer/src/externals/mod.rs
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/wasmer/src/externals/table.rs
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/wasmer/src/import_object.rs
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/wasmer/src/instance.rs
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/wasmer/src/lib.rs
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/wasmer/src/memory/mod.rs
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/wasmer/src/memory/views.rs
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/wasmer/src/module.rs
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/wasmer/src/prelude.rs
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/wasmer/src/store.rs
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/wasmer/src/types.rs
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/wasmer/src/values.rs
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/wasmer/src/wasi.rs
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/crates/wasmer/src/wat.rs
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/justfile
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/lib/wasmer.rb
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/wasmer.gemspec
Building native extensions. This could take a while...
current directory: /Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0
["/Users/my-user/.rubies/ruby-2.6.6/bin/ruby", "-rrubygems", "/Users/my-user/repos/proj1/application/.direnv/ruby/gems/rake-13.0.3/exe/rake", "RUBYARCHDIR=/Users/my-user/repos/proj1/application/.direnv/ruby/extensions/x86_64-darwin-20/2.6.0-static/wasmer-0.5.0", "RUBYLIBDIR=/Users/my-user/repos/proj1/application/.direnv/ruby/extensions/x86_64-darwin-20/2.6.0-static/wasmer-0.5.0"]
bundle config set --local path "vendor/bundle"
bundle install
Fetching gem metadata from https://rubygems.org/.........
Fetching source index from https://rubygems.org/
Resolving dependencies...
Using rake 13.0.3
Using concurrent-ruby 1.1.8
Using i18n 1.8.9
Using minitest 5.10.3
[β¦ redacted for brevity]
Using therubyracer 0.12.3
Using tzinfo-data 1.2021.1
Using user_agent_parser 2.7.0
Fetching wasmer 0.5.0
Installing wasmer 0.5.0 with native extensions
Traceback (most recent call last):
25: from /Users/my-user/repos/proj1/application/.direnv/bin/bundle:104:in `<main>'
24: from /Users/my-user/repos/proj1/application/.direnv/bin/bundle:104:in `load'
23: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/bundler-1.17.2/exe/bundle:22:in `<top (required)>'
22: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/friendly_errors.rb:124:in `with_friendly_errors'
21: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/bundler-1.17.2/exe/bundle:30:in `block in <top (required)>'
20: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/cli.rb:18:in `start'
19: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
18: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/cli.rb:27:in `dispatch'
17: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
16: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
15: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
14: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/cli.rb:234:in `install'
13: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/settings.rb:143:in `temporary'
12: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/cli.rb:235:in `block in install'
11: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/cli/install.rb:65:in `run'
10: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/installer.rb:25:in `install'
9: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/installer.rb:73:in `run'
8: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/process_lock.rb:9:in `lock'
7: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/process_lock.rb:9:in `open'
6: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/process_lock.rb:12:in `block in lock'
5: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/installer.rb:92:in `block in run'
4: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/installer.rb:197:in `install'
3: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/installer.rb:289:in `install_in_parallel'
2: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/installer/parallel_installer.rb:78:in `call'
1: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/installer/parallel_installer.rb:106:in `call'
/Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/installer/parallel_installer.rb:201:in `handle_error': Gem::Ext::BuildError: ERROR: Failed to build gem native extension. (Bundler::InstallError)
No such file or directory - getcwd
Gem files will remain installed in /Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0 for inspection.
Results logged to /Users/my-user/repos/proj1/application/.direnv/ruby/extensions/x86_64-darwin-20/2.6.0-static/wasmer-0.5.0/gem_make.out
An error occurred while installing wasmer (0.5.0), and Bundler cannot continue.
Make sure that `gem install wasmer -v '0.5.0'` succeeds before bundling.
In Gemfile:
wasmer
13: from /Users/my-user/repos/proj1/application/.direnv/bin/bundle:104:in `<main>'
12: from /Users/my-user/repos/proj1/application/.direnv/bin/bundle:104:in `load'
11: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/bundler-1.17.2/exe/bundle:22:in `<top (required)>'
10: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/friendly_errors.rb:124:in `with_friendly_errors'
9: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/bundler-1.17.2/exe/bundle:30:in `block in <top (required)>'
8: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/cli.rb:23:in `start'
7: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/cli.rb:23:in `ensure in start'
6: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/shared_helpers.rb:155:in `print_major_deprecations!'
5: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/shared_helpers.rb:272:in `search_up'
4: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/shared_helpers.rb:70:in `pwd'
3: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/monitor.rb:235:in `mon_synchronize'
2: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/shared_helpers.rb:71:in `block in pwd'
1: from /Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/shared_helpers.rb:71:in `pwd'
/Users/my-user/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/shared_helpers.rb:71:in `getwd': No such file or directory - getcwd (Errno::ENOENT)
rake aborted!
Command failed with status (1): [bundle install...]
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0/Rakefile:12:in `block in <top (required)>'
/Users/my-user/repos/proj1/application/.direnv/ruby/gems/rake-13.0.3/exe/rake:27:in `<main>'
Tasks: TOP => default => test => bundle_install
(See full trace by running task with --trace)
ERROR: Error installing wasmer:
ERROR: Failed to build gem native extension.
current directory: /Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0
/Users/my-user/.rubies/ruby-2.6.6/bin/ruby -rrubygems /Users/my-user/repos/proj1/application/.direnv/ruby/gems/rake-13.0.3/exe/rake RUBYARCHDIR\=/Users/my-user/repos/proj1/application/.direnv/ruby/extensions/x86_64-darwin-20/2.6.0-static/wasmer-0.5.0 RUBYLIBDIR\=/Users/my-user/repos/proj1/application/.direnv/ruby/extensions/x86_64-darwin-20/2.6.0-static/wasmer-0.5.0
Building has failed. See above output for more information on the failure.
rake failed, exit code 1
Gem files will remain installed in /Users/my-user/repos/proj1/application/.direnv/ruby/gems/wasmer-0.5.0 for inspection.
Results logged to /Users/my-user/repos/proj1/application/.direnv/ruby/extensions/x86_64-darwin-20/2.6.0-static/wasmer-0.5.0/gem_make.out
cat /Users/cta/repos/skovik/application/.direnv/ruby/extensions/x86_64-darwin-20/2.6.0-static/wasmer-0.5.0/gem_make.out
current directory: /Users/cta/repos/skovik/application/.direnv/ruby/gems/wasmer-0.5.0
/Users/cta/.rubies/ruby-2.6.6/bin/ruby -rrubygems /Users/cta/repos/skovik/application/.direnv/ruby/gems/rake-13.0.3/exe/rake RUBYARCHDIR\=/Users/cta/repos/skovik/application/.direnv/ruby/extensions/x86_64-darwin-20/2.6.0-static/wasmer-0.5.0 RUBYLIBDIR\=/Users/cta/repos/skovik/application/.direnv/ruby/extensions/x86_64-darwin-20/2.6.0-static/wasmer-0.5.0
Building has failed. See above output for more information on the failure.
rake failed, exit code 1
When I run a wasi binary with this library the stdout and stderr are directed towards the application's stdout and stderr. I would rather capture that information to present it in my own way. Is there an option for that which I am missing.
Right now I'm working around this issue by futzing with the file descriptors for the program but this seems less than ideal.
def capturing_output
old_stdout = $stdout.dup
old_stderr = $stderr.dup
Tempfile.create '' do |stdout|
$stdout.reopen stdout.path, 'w+'
Tempfile.create '' do |stderr|
$stderr.reopen stderr.path, 'w+'
yield
stdout.read
rescue RuntimeError
raise ScriptError.new stdout.read, stderr.read, $!.message
end
ensure
$stdout.reopen old_stdout
$stderr.reopen old_stderr
end
end
capturing_output do
Wasmer::Instance.new(module_, import).exports._start.()
end
It's both overly complicated and requires the use of files which is IO I would prefer to avoid. I expect my output to be very small so it would be ideal if I could provide a StringIO object to avoid that disk access.
I believe #58 fixes an issue for https://github.com/brave-intl/wasm-thumbnail , as it seems like the Rakefile line 12 in v1.0.0 seems to be causing issues as seen below:
#18 324.8 Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
#18 324.8
#18 324.8 current directory: /var/www/vendor/bundle/ruby/2.7.0/gems/wasmer-1.0.0
#18 324.8 /usr/local/bin/ruby -I/usr/local/lib/ruby/2.7.0/rubygems -rrubygems
#18 324.8 /var/www/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/exe/rake
#18 324.8 RUBYARCHDIR\=/var/www/vendor/bundle/ruby/2.7.0/extensions/x86_64-linux-musl/2.7.0/wasmer-1.0.0
#18 324.8 RUBYLIBDIR\=/var/www/vendor/bundle/ruby/2.7.0/extensions/x86_64-linux-musl/2.7.0/wasmer-1.0.0
#18 324.8 fatal: not a git repository (or any of the parent directories): .git
#18 324.8 bundle config set --local path "vendor/bundle"
#18 324.8 bundle install
#18 324.8 The deployment setting requires a Gemfile.lock. Please make sure you have
#18 324.8 checked your Gemfile.lock into version control before deploying.
#18 324.8 rake aborted!
#18 324.8 Command failed with status (16): [bundle install...]
#18 324.8 /var/www/vendor/bundle/ruby/2.7.0/gems/wasmer-1.0.0/Rakefile:12:in `block in
#18 324.8 <top (required)>'
#18 324.8 /var/www/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/exe/rake:27:in `<main>'
#18 324.8 Tasks: TOP => default => test => bundle_install
#18 324.8 (See full trace by running task with --trace)
Given it's a low risk change, would you be able to release 1.0.1?
The README seems tailored to rust programmers not Ruby yet the project name is wasmer-ruby.
Could you please abstract low-level (unimportant) details away and hide them from us Ruby programmers (perhaps in a wiki page or other file) and just give us Ruby programmer tailored instructions instead? I thought that would be obvious on any Ruby project. I just want to run this Opal Ruby project in wasm instead:
https://github.com/AndyObtiva/glimmer-dsl-opal
Donβt you have any automated or fast track Ruby-inside-the-browser instructions? I just want to hack on some Ruby in the browser within seconds and be happy (just like I did with Opal). I donβt want to muck with rust.
Thanks and Godspeed!
Andy Maleh
My end goal is to be able to execute JavaScript code, server-side in a sandbox from Ruby.
I'm thinking that wasi is a good approach as that offers the sandbox. There is also multiple Javascript engines that have been compiled to wasi modules on wapm such as Spidermonkey (Firefox's JS engine), QuickJS, and duktape.
When I try to load any of these wasi modules I get an error it seems related to the FS API.
(irb):4:in `new': Error while importing "wasi_snapshot_preview1"."fd_read": unknown import. Expected Function(FunctionType { params: [I32, I32, I32, I32], results: [I32] }) (RuntimeError)
from (irb):4:in `<main>'
from /Users/eric/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/irb-1.3.5/exe/irb:11:in `<top (required)>'
from /Users/eric/.rbenv/versions/3.0.4/bin/irb:23:in `load'
from /Users/eric/.rbenv/versions/3.0.4/bin/irb:23:in `<main>'
(irb):5:in `new': Error while importing "wasi_unstable"."fd_prestat_get": unknown import. Expected Function(FunctionType { params: [I32, I32], results: [I32] }) (RuntimeError)
from (irb):5:in `<main>'
from /Users/eric/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/irb-1.3.5/exe/irb:11:in `<top (required)>'
from /Users/eric/.rbenv/versions/3.0.4/bin/irb:23:in `load'
from /Users/eric/.rbenv/versions/3.0.4/bin/irb:23:in `<main>'
(irb):13:in `new': Error while importing "wasi_unstable"."fd_prestat_get": unknown import. Expected Function(FunctionType { params: [I32, I32], results: [I32] }) (RuntimeError)
from (irb):13:in `<main>'
from /Users/eric/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/irb-1.3.5/exe/irb:11:in `<top (required)>'
from /Users/eric/.rbenv/versions/3.0.4/bin/irb:23:in `load'
from /Users/eric/.rbenv/versions/3.0.4/bin/irb:23:in `<main>'
Am I just doing it wrong?
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.