Ruby macOS Big Sur 11.4 系统 env: ruby.exe: No such file or directory 问题

zhg · July 09, 2021 · Last by PaulChan1995 replied at July 12, 2021 · 509 hits

各位大神 MAC 系统执行 rails s 时直接返回 env: ruby.exe: No such file or directory 错误,ruby.exe 不应该是 windows 系统的应用程序嘛?在 mac 系统为什么会出现这个报错; 我同事的 macOS 是 10.14.3 版本的 bundle 完成之后可以正常执行。

gemfile 文件内容

gem 'rails', '= 5.1.4'
gem 'mysql2', '>= 0.3.18', '< 0.5'
gem 'puma', '~> 3.7'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'therubyracer', platforms: :ruby

gem 'coffee-rails', '~> 4.2'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
gem 'redis', '~> 3.0'
gem 'bcrypt', '~> 3.1.7'

gem 'rest-client', '~> 2.0.2'
gem 'sinatra', github: 'sinatra/sinatra', branch: 'master'
gem "refile", require: "refile/rails", github: "refile/refile"
gem "refile-mini_magick"

group :development, :test do
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  gem 'capybara', '~> 2.13'
  gem 'selenium-webdriver'
end

group :development do
  gem 'web-console', '>= 3.3.0'
end

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'savon'
gem 'ruby-pinyin'
gem 'ipparse'
gem 'paperclip'
gem 'spreadsheet'
gem 'excel_rails'
gem 'hpricot'
gem 'httpclient'

错误信息

肯定是带了什么 Gem,里面里面调用 Ruby 的方式是给 Windows 设计的

Reply to huacnlee
gem install therubyracer -v '0.12.3' -- --with-v8-dir=/usr/local/opt/[email protected]

会不会是安装的这个导致的 gemfile 文件 里面 gem 'therubyracer', platforms: :ruby

错误栈的作用就是让人查问题出处的,贴错误信息要贴全。

4 Floor has deleted
Reply to Rei

就这一个返回错误

难道有 gem 被攻击了?

攻击者只考虑了 windows?

可以 grep 一下看下是哪个文件存在问题:

bundle show rails
grep -rn "ruby\.exe" /Users/rocky/.rvm/gems/ruby-2.5.5/gems # 路径替换为上面bundle查看的路径
grep -rn "ruby\.exe" .
Reply to ThxFly

谢谢您!根据您方法解决了。项目以前的开发是使用 Windows 开发的。

我这边也有个大哥用 Windows 开发,我自己是 mac,每次拉他的代码下来了之后都得帮他改这个,还有 CRLF/LF 的问题,服务器上老是报,他们是看不见吗😏

You need to Sign in before reply, if you don't have an account, please Sign up first.