wasmerio / wasmer-ruby

💎🕸 WebAssembly runtime for Ruby
https://wasmer.io
MIT License
473 stars 18 forks source link

cannot instantiate `Wasmer::Instance` #21

Closed notmaxx closed 5 years ago

notmaxx commented 5 years ago

Describe the bug

Example applications do not work

Steps to reproduce

install rust, install wasmer gem, clone repo and run example applications

Expected behavior

Examples should work

Actual behavior

$ 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>

Additional context

$ 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
tikh commented 5 years ago

I have the same issue with a strange "workaround". In IRB:

2.3.3 :001 > require "wasmer"
 => true
2.3.3 :002 > Wasmer::Instance
NameError: uninitialized constant Wasmer::Instance
Did you mean?  Instance
...
2.3.3 :003 > Instance
 => Instance

Might be an issue with Rutie with Ruby 2.3.3.

tikh commented 5 years ago

The same issue with MRI 2.6.1

2.6.1 :004 > require "wasmer"
 => true
2.6.1 :005 > Wasmer::Instance
Traceback (most recent call last):
       16: from /Users/tikh/.rvm/gems/ruby-2.6.1/gems/bundler-2.0.2/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'
       15: from /Users/tikh/.rvm/gems/ruby-2.6.1/gems/bundler-2.0.2/exe/bundle:30:in `block in <top (required)>'
       14: from /Users/tikh/.rvm/gems/ruby-2.6.1/gems/bundler-2.0.2/lib/bundler/cli.rb:18:in `start'
       13: from /Users/tikh/.rvm/gems/ruby-2.6.1/gems/bundler-2.0.2/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
       12: from /Users/tikh/.rvm/gems/ruby-2.6.1/gems/bundler-2.0.2/lib/bundler/cli.rb:27:in `dispatch'
       11: from /Users/tikh/.rvm/gems/ruby-2.6.1/gems/bundler-2.0.2/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
       10: from /Users/tikh/.rvm/gems/ruby-2.6.1/gems/bundler-2.0.2/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
        9: from /Users/tikh/.rvm/gems/ruby-2.6.1/gems/bundler-2.0.2/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
        8: from /Users/tikh/.rvm/gems/ruby-2.6.1/gems/bundler-2.0.2/lib/bundler/cli.rb:465:in `exec'
        7: from /Users/tikh/.rvm/gems/ruby-2.6.1/gems/bundler-2.0.2/lib/bundler/cli/exec.rb:28:in `run'
        6: from /Users/tikh/.rvm/gems/ruby-2.6.1/gems/bundler-2.0.2/lib/bundler/cli/exec.rb:74:in `kernel_load'
        5: from /Users/tikh/.rvm/gems/ruby-2.6.1/gems/bundler-2.0.2/lib/bundler/cli/exec.rb:74:in `load'
        4: from /Users/tikh/.rvm/rubies/ruby-2.6.1/bin/irb:23:in `<top (required)>'
        3: from /Users/tikh/.rvm/rubies/ruby-2.6.1/bin/irb:23:in `load'
        2: from /Users/tikh/.rvm/rubies/ruby-2.6.1/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>'
        1: from (irb):5
NameError (uninitialized constant Wasmer::Instance)
2.6.1 :006 > Instance
 => Instance
ljulliar commented 5 years ago

Same thing here: ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux] rustc 1.35.0 (3c235d560 2019-05-20)

I did install the gem with the --verbose option and the only thing I noticed was the following fatal error messages below that most likely comes from a git command being executed from the gem file. It doesn't stop the installation though.

Building native extensions. This could take a while...
current directory: /home/ljulliard/.rvm/gems/ruby-2.6.3/gems/wasmer-0.2.0
["/home/ljulliard/.rvm/rubies/ruby-2.6.3/bin/ruby", "-rrubygems", "/home/ljulliard/.rvm/rubies/ruby-2.6.3/lib/ruby/gems/2.6.0/gems/rake-12.3.2/exe/rake", "RUBYARCHDIR=/home/ljulliard/.rvm/gems/ruby-2.6.3/extensions/x86_64-linux/2.6.0/wasmer-0.2.0", "RUBYLIBDIR=/home/ljulliard/.rvm/gems/ruby-2.6.3/extensions/x86_64-linux/2.6.0/wasmer-0.2.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 10.5.0
....

Does this ring a bell for anyone ?

Hywan commented 5 years ago

Did you try with Ruby 2.6? This is the version I use and the version that is tested on the CI.

$ ruby examples/simple.rb
3

$ ruby --version
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]

I'm surprised @ljulliar experiences a similar issue with the same version than I have :-/.

Hywan commented 5 years ago

I use Rutie 0.6.1 on Rust, and 0.0.3 on Ruby.

ljulliar commented 5 years ago

I do confirm I see the exact same problem on 2.6.3. I am too using rutie 0.6.1 on rust side BUT rust 0.0.4 on Ruby side and not 0.0.3 as you. Have you tried with 0.0.4 ?

Hywan commented 5 years ago

I didn't. Can you try with Rutie 0.0.3 on Ruby side please?

ljulliar commented 5 years ago

I downgraded to rust 0.0.3 on the Ruby side and still the same problem. @tikh @notmaxx are you also running Linux ? (I am on Debian 10)

ljulliar commented 5 years ago

Well actually while running gem install --verbose wasmer

I noticed that the rutie crane installed is actually version 0.5.4, not 0.6.1 and I'm not quite sure how to force the installation of 0.6.1

cargo build --release
   Compiling proc-macro2 v0.4.27
   Compiling unicode-xid v0.1.0
   Compiling ryu v0.2.7
   Compiling syn v0.15.31
   Compiling serde v1.0.90
   Compiling libc v0.2.51
   Compiling cc v1.0.35
   Compiling autocfg v0.1.2
   Compiling failure_derive v0.1.5
   Compiling semver-parser v0.7.0
   Compiling itoa v0.4.3
   Compiling rand_core v0.4.0
   Compiling byteorder v1.3.1
   Compiling arrayvec v0.4.10
....
   Compiling rutie v0.5.4
....
Hywan commented 5 years ago

Weird. Try running cargo update.

ljulliar commented 5 years ago

So I cd into the gem build directory and did a cargo update. A number of crates were updated included rutie BUT it went from 0.5.4 to 0.5.6

log messages: $ cargo update .....snip, snip Updating rutie v0.5.4 -> v0.5.6 .....snip, snip

So then I looked into the cargo.toml file and noticed that on line 20 it says:

rutie = "0.5.4"

where as the latest version on github says

rutie = "0.6.0"

So what I suspect is that the wasmer gem on rubygem.org ( https://rubygems.org/gems/wasmer - version 0.2.0 from May 1, 2019) is either outdated or wasn't generated with the proper Cargo.toml.

May be the best thing to do would be to publish an updated version on rubygems.org as this is the one source of truth for rubygems. @Hywan : what do you think?

On Mon, Aug 19, 2019 at 11:07 AM Ivan Enderlin notifications@github.com wrote:

Weird. Try running cargo update.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/wasmerio/ruby-ext-wasm/issues/21?email_source=notifications&email_token=AAAED4JSN5DHOT77XFSSM5TQFJPETA5CNFSM4IJGNTN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4SHAOI#issuecomment-522481721, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAED4JX5WZ3QFFDEPYW3ADQFJPETANCNFSM4IJGNTNQ .

Hywan commented 5 years ago

I think I've to update the gems, yes.

Hywan commented 5 years ago

I just forgot to publish the gems… Sorry for that, it may be the issue!

Hywan commented 5 years ago

Done, https://rubygems.org/gems/wasmer. Does it help?

ljulliar commented 5 years ago

@Hywan : It works just fine now. Thank you!

Hywan commented 5 years ago

Glad to hear that! I'm closing the issue. If someone else still experiences an installation issue, please ping me, I'll reopen.

Thanks everyone, and sorry for the rubygem oversight!