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

Error when using mac M1 running native arm #539

Closed
uxxman opened this issue May 5, 2021 · 11 comments
Closed

Error when using mac M1 running native arm #539

uxxman opened this issue May 5, 2021 · 11 comments

Comments

@uxxman
Copy link

uxxman commented May 5, 2021

Error Log

E, [2021-05-06T01:05:45.848957 #20864] ERROR -- : Exception rescued in listen-worker_thread:
Errno::EBADARCH: Bad CPU type in executable - /opt/homebrew/Cellar/rbenv/1.1.2/versions/3.0.1/lib/ruby/gems/3.0.0/gems/rb-fsevent-0.10.4/bin/fsevent_watch
/opt/homebrew/Cellar/rbenv/1.1.2/versions/3.0.1/lib/ruby/gems/3.0.0/gems/rb-fsevent-0.10.4/lib/rb-fsevent/fsevent.rb:140:in `popen'
/opt/homebrew/Cellar/rbenv/1.1.2/versions/3.0.1/lib/ruby/gems/3.0.0/gems/rb-fsevent-0.10.4/lib/rb-fsevent/fsevent.rb:140:in `open_pipe'
/opt/homebrew/Cellar/rbenv/1.1.2/versions/3.0.1/lib/ruby/gems/3.0.0/gems/rb-fsevent-0.10.4/lib/rb-fsevent/fsevent.rb:39:in `run'
/opt/homebrew/Cellar/rbenv/1.1.2/versions/3.0.1/lib/ruby/gems/3.0.0/gems/listen-3.5.1/lib/listen/adapter/darwin.rb:49:in `block in _run'
/opt/homebrew/Cellar/rbenv/1.1.2/versions/3.0.1/lib/ruby/gems/3.0.0/gems/listen-3.5.1/lib/listen/thread.rb:26:in `rescue_and_log'
/opt/homebrew/Cellar/rbenv/1.1.2/versions/3.0.1/lib/ruby/gems/3.0.0/gems/listen-3.5.1/lib/listen/thread.rb:18:in `block in new'
--- Thread.new ---
/opt/homebrew/Cellar/rbenv/1.1.2/versions/3.0.1/lib/ruby/gems/3.0.0/gems/listen-3.5.1/lib/listen/adapter/darwin.rb:49:in `_run'
/opt/homebrew/Cellar/rbenv/1.1.2/versions/3.0.1/lib/ruby/gems/3.0.0/gems/listen-3.5.1/lib/listen/adapter/base.rb:79:in `block in start'
/opt/homebrew/Cellar/rbenv/1.1.2/versions/3.0.1/lib/ruby/gems/3.0.0/gems/listen-3.5.1/lib/listen/thread.rb:26:in `rescue_and_log'
/opt/homebrew/Cellar/rbenv/1.1.2/versions/3.0.1/lib/ruby/gems/3.0.0/gems/listen-3.5.1/lib/listen/thread.rb:18:in `block in new'
E, [2021-05-06T01:05:46.133285 #20864] ERROR -- : Exception rescued in listen-worker_thread:
Errno::EBADARCH: Bad CPU type in executable - /opt/homebrew/Cellar/rbenv/1.1.2/versions/3.0.1/lib/ruby/gems/3.0.0/gems/rb-fsevent-0.10.4/bin/fsevent_watch
/opt/homebrew/Cellar/rbenv/1.1.2/versions/3.0.1/lib/ruby/gems/3.0.0/gems/rb-fsevent-0.10.4/lib/rb-fsevent/fsevent.rb:140:in `popen'
/opt/homebrew/Cellar/rbenv/1.1.2/versions/3.0.1/lib/ruby/gems/3.0.0/gems/rb-fsevent-0.10.4/lib/rb-fsevent/fsevent.rb:140:in `open_pipe'
/opt/homebrew/Cellar/rbenv/1.1.2/versions/3.0.1/lib/ruby/gems/3.0.0/gems/rb-fsevent-0.10.4/lib/rb-fsevent/fsevent.rb:39:in `run'
/opt/homebrew/Cellar/rbenv/1.1.2/versions/3.0.1/lib/ruby/gems/3.0.0/gems/listen-3.5.1/lib/listen/adapter/darwin.rb:49:in `block in _run'
/opt/homebrew/Cellar/rbenv/1.1.2/versions/3.0.1/lib/ruby/gems/3.0.0/gems/listen-3.5.1/lib/listen/thread.rb:26:in `rescue_and_log'
/opt/homebrew/Cellar/rbenv/1.1.2/versions/3.0.1/lib/ruby/gems/3.0.0/gems/listen-3.5.1/lib/listen/thread.rb:18:in `block in new'
--- Thread.new ---
/opt/homebrew/Cellar/rbenv/1.1.2/versions/3.0.1/lib/ruby/gems/3.0.0/gems/listen-3.5.1/lib/listen/adapter/darwin.rb:49:in `_run'
/opt/homebrew/Cellar/rbenv/1.1.2/versions/3.0.1/lib/ruby/gems/3.0.0/gems/listen-3.5.1/lib/listen/adapter/base.rb:79:in `block in start'
/opt/homebrew/Cellar/rbenv/1.1.2/versions/3.0.1/lib/ruby/gems/3.0.0/gems/listen-3.5.1/lib/listen/thread.rb:26:in `rescue_and_log'
/opt/homebrew/Cellar/rbenv/1.1.2/versions/3.0.1/lib/ruby/gems/3.0.0/gems/listen-3.5.1/lib/listen/thread.rb:18:in `block in new'
@ColinDKelley
Copy link
Collaborator

@uxxman I haven't seen this exact error before, but it feels a lot like the rb-fsevent gem was installed and natively built for a previous CPU (probably Intel on your old Mac) and then was migrated over. Does that sound possible? I've had similar problems when I upgraded OSX.

The fix in such cases is to uninstall the gem and reinstall it. As in:

gem uninstall rb-fsevent:0.10.4
gem install rb-fsevent:0.10.4
bundle install

but in this case you might just want to uninstall the entire version of Ruby from rbenv and then reinstall it. That will force all its gems to be reinstalled and rebuilt.

@uxxman
Copy link
Author

uxxman commented May 6, 2021

@ColinDKelley thank you for the prompt response. I have tried uninstalling and reinstalling rb-fsevent but the issue remains. Even uninstalling the ruby and reinstalling it doesn't solve it

While researching I found this link https://qiita.com/kazutosato/items/6dea35e97f39d8d13e83#rails%E3%81%AE%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB

From google translate the gist is to change this

# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
  config.file_watcher = ActiveSupport::FileUpdateChecker

This indeed resolves the issue but are there any side-effects for this? Does this completely disables listen gem?

@ColinDKelley
Copy link
Collaborator

Oh, I see. The problem is in rb-fsevent. It contains a Mac binary executable inside the gem(!):

https://github.com/thibaudgg/rb-fsevent/blob/master/bin/fsevent_watch

I'm very surprised that's not a native build step. Can you please file a ticket over there? It's easy to spot that it doesn't support the ARM:

$ file fsevent_watch
fsevent_watch Mach-O 64-bit executable x86_64

Re: this change:

  config.file_watcher = ActiveSupport::FileUpdateChecker

I believe that setting tells Rails to not use listen to watch for file changes. If so, that would be a work-around rather than a fix for listen.

@ColinDKelley
Copy link
Collaborator

BTW the fsevent_watch gem does have instructions here for rebuilding:

https://github.com/thibaudgg/rb-fsevent#re-compilation

@ColinDKelley
Copy link
Collaborator

And it looks like there's already an issue there:

guard/rb-fsevent#87

as well as a PR:

guard/rb-fsevent#88

@uxxman
Copy link
Author

uxxman commented May 6, 2021

Thank you @ColinDKelley. I will follow the issue there 👍🏻

@uxxman uxxman closed this as completed May 6, 2021
@thibaudgg
Copy link
Member

rb-fsevent version 0.11.0 has been released with mac M1 support, please give it a try!

@ColinDKelley
Copy link
Collaborator

@thibaudgg Excellent! Thank you for letting us know here.

@shailscript
Copy link

@ColinDKelley I ran into the same issue and I am using the latest version of listen gem, any plans on updating the gem so it can use rb-fsevent version 0.11.0?

@ColinDKelley
Copy link
Collaborator

@shailscript The listen gemspec is already compatible with that version. From the gemspec:

  gem.add_dependency 'rb-fsevent', '~> 0.10', '>= 0.10.3'

So you can add version 0.11.0 to your Gemfile. Likely you can just do

bundle update rb-fsevent

Please respond back here to let us know how that works for you.

@shailscript
Copy link

Yeah updating just rb-fsevent works well, as you suggested 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants