Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot install on macOS with statically distributed Ruby version #56

Closed
sandstrom opened this issue Jun 9, 2021 · 12 comments
Closed

Cannot install on macOS with statically distributed Ruby version #56

sandstrom opened this issue Jun 9, 2021 · 12 comments
Assignees
Labels
🐞 bug Something isn't working

Comments

@sandstrom
Copy link

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
@sandstrom sandstrom added the 🐞 bug Something isn't working label Jun 9, 2021
@Hywan Hywan self-assigned this Jun 10, 2021
@Hywan
Copy link
Contributor

Hywan commented Jun 10, 2021

Hello,

Thanks for the bug report. I see in your logs:

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

where those dependencies are coming from? We aren't using them as far as I know.

I just tried on macOS Big Sur with Ruby 3.0.0 and it succeeded with no issue.
I've then installed Ruby 2.6.6 with rbenv and retried. It succeeded with no issue.

[…]
current directory: /Users/hwhost/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/wasmer-0.5.0
/Users/hwhost/.rbenv/versions/2.6.6/bin/ruby -rrubygems /Users/hwhost/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.3/exe/rake RUBYARCHDIR\=/Users/hwhost/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/-darwin-20/2.6.0/wasmer-0.5.0 RUBYLIBDIR\=/Users/hwhost/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/-darwin-20/2.6.0/wasmer-0.5.0
Successfully installed wasmer-0.5.0
Parsing documentation for wasmer-0.5.0
Parsing sources...
100% [ 2/ 2]  lib/wasmer.rb
Installing ri documentation for wasmer-0.5.0
Done installing documentation for wasmer after 0 seconds
1 gem installed

How did you install Ruby 2.6.6?

@sandstrom
Copy link
Author

sandstrom commented Jun 10, 2021

I installed it via https://github.com/postmodern/ruby-install,
something likebrew install ruby-install && ruby-install 2.6

@sandstrom
Copy link
Author

Here is a repo with what I need to reproduce on my machine

https://github.com/sandstrom/wasmer-install-repro

@sandstrom
Copy link
Author

Checked the install script (Rakefile), could it be that I don't have cargo installed? (not found…)

@sandstrom
Copy link
Author

Tried adding cargo, but doesn't seem to help.

Looking closer at the error message, I think this is the failing line:

https://github.com/wasmerio/wasmer-ruby/blob/master/Rakefile#L12

Don't know why though, but maybe there are assumptions there, about the host environment, that one shouldn't do in a general install script?

Maybe you could check similar install scripts in other gems, and see what they've done?

@Hywan
Copy link
Contributor

Hywan commented Jun 11, 2021

Thank you for the investigation. I'll try to find time to address that. I'll keep you updated.

@sandstrom
Copy link
Author

@Hywan Check out this script from Skylight. They also have a rust-agent, so should be fairly similar to your case.

It's also a very well-written gem (one of its authors is a former Rails core team member and (I think) also a former Rust core team member).

https://github.com/skylightio/skylight-ruby/blob/master/ext/extconf.rb
https://github.com/skylightio/skylight-ruby/blob/master/skylight.gemspec#L49

@Hywan
Copy link
Contributor

Hywan commented Jun 15, 2021

I've failed to reproduce your error even with the given repository.
What version of gem do you have?

To simplify our debugging session, can you please try to clone this repository, and run:

$ rake test

I suspect that you have a static version of Ruby, which isn't compatible with how rutie works (rutie is the underlying library we use to integrate seamlessly with Ruby). Check the Dynamic vs Static Builds Section to learn more. Can you please give me the result of:

$ ruby -e "pp RbConfig::CONFIG['ENABLE_SHARED']"

We should see a "yes".

@sandstrom
Copy link
Author

sandstrom commented Jun 15, 2021

Yes, you are correct, I have a static version of ruby.

I left a comment in rutie (danielpclark/rutie#45 (comment)), about maybe checking if helix has found a solution to this problem. Other than that, I don't have much I can contribute.

Still looking forward to trying out wasmer! I'll see if we can change our environment setup to use dynamic ruby. If that isn't easily, we'll have to wait and see if rutie gets support for static builds. Thanks for taking time looking into this!

Maybe you could add that check to the rake file, raise "Expected dynamic ruby, see http://www….com" unless pp(RbConfig::CONFIG['ENABLE_SHARED']) == 'yes'

@Hywan
Copy link
Contributor

Hywan commented Jun 15, 2021

Yeah, raising such error is indeed a good idea.

For what project would you like to use wasmer-ruby? I'm curious :-).

(Closing the issue as the problem is “solved”).

@Hywan Hywan closed this as completed Jun 15, 2021
@sandstrom
Copy link
Author

sandstrom commented Jun 15, 2021

Evaluate untrusted code (probably AssemblyScript) in a Rails application.

Yeah, feel free to close, agree initial issue is "solved"!

Two things that one could do though:

  • Add the suggested warning above (for others that trip on this)
  • Check in with the rutie folks and see how much work it would be to support static builds (and if it's possible to help out).

It's up to you and the Wasmer team though to decide, obviously! 😄

Either way I'll keep my eyes on this and hopefully we'll be able to give it a try in 3-6 months, if we're lucky 💯

@Hywan
Copy link
Contributor

Hywan commented Jun 15, 2021

If you're willing to open a PR to raise an error/warning when the Ruby version has been statically distributed, I would be very happy to merge it!

I can try to take a look at Rutie itself also, as soon as I've time :-).

@Hywan Hywan changed the title Cannot install on macOS Cannot install on macOS with statically distributed Ruby version Jun 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants