ruby install rails with Error ---Failed to build gem native extension.(Windows 平台)
ruby install rails with Error ---Failed to build gem native extension.(Windows platform)
Ruby 的新手,刚刚开始 rails 旅程。
已经搜索了 Whosebug,但这些问题很多都是很久以前的问题了。我的英文不好,请容忍我的描述。这是我的情况,希望我说清楚。
我在 windows。
当我在线学习 ruby 课程时,我安装了一个 较旧的环境 -- ruby2.7.4 和 rails 7.0.1.
昨天我想用更新的 ruby 环境完成一个新项目 -- 所以我安装了 ruby3.1.0,但是当我尝试 安装 rails 对于这个新的 Ruby verison,发生错误。
这是我的环境:
C:\Users\Administrator>uru ls
274p191 : ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x64-mingw32]
310p0 : ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x64-mingw-ucrt]
C:\Users\Administrator>ruby -v
ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x64-mingw-ucrt]
C:\Users\Administrator>gem -v
3.3.6
C:\Users\Administrator>d:
D:\>cd RubyDevkit
D:\RubyDevkit>ruby dk.rb install
[INFO] Skipping existing gem override for 'D:/Ruby27-x64'
[WARN] Skipping existing DevKit helper library for 'D:/Ruby27-x64'
[INFO] Skipping existing gem override for 'D:/Ruby31-x64'
[WARN] Skipping existing DevKit helper library for 'D:/Ruby31-x64'
D:\RubyDevkit>
如您所见,我当前的 ruby 版本是 3.1.0,我想我已经为我的两个 Rubies 成功安装了 Devkit。
我也安装了 MSYS2(虽然我不知道为什么 ruby 需要它,但我遇到了另一个错误提醒我安装 MSYS 并添加它到路径)
我想在遇到这个错误之前我已经做对了所有事情:
C:\Users\Administrator>gem install rails
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
current directory: D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5/ext/websocket-driver
D:/Ruby31-x64/bin/ruby.exe -I D:/Ruby31-x64/lib/ruby/site_ruby/3.1.0 -r ./siteconf20220128-11340-9w9ez5.rb extconf.rb
creating Makefile
current directory: D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5/ext/websocket-driver
make DESTDIR\= clean
current directory: D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5/ext/websocket-driver
make DESTDIR\=
make failedNo such file or directory - make
Gem files will remain installed in D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5 for inspection.
Results logged to D:/Ruby31-x64/lib/ruby/gems/3.1.0/extensions/x64-mingw-ucrt/3.1.0/websocket-driver-0.7.5/gem_make.out
当我为 ruby2.7.4 安装 rails 时没有异常(相同的命令刚刚完成,没有错误或警告)。
我在网上找不到类似的情况。有人可以帮忙吗?
--------------------01/29----------------划分----- ----------------------
感谢评论,发人深省。遵循一些计划(虽然失败了)
我尝试单独安装 gem websocket-driver
,得到了同样的错误:
C:\Users\Administrator>gem install websocket-driver:0.7.5
Building native extensions. This could take a while...
ERROR: Error installing websocket-driver:
ERROR: Failed to build gem native extension.
current directory: D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5/ext/websocket-driver
D:/Ruby31-x64/bin/ruby.exe -I D:/Ruby31-x64/lib/ruby/site_ruby/3.1.0 -r ./siteconf20220129-3864-wqfhn2.rb extconf.rb
creating Makefile
current directory: D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5/ext/websocket-driver
make DESTDIR\= clean
current directory: D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5/ext/websocket-driver
make DESTDIR\=
make failedNo such file or directory - make
Gem files will remain installed in D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5 for inspection.
Results logged to D:/Ruby31-x64/lib/ruby/gems/3.1.0/extensions/x64-mingw-ucrt/3.1.0/websocket-driver-0.7.5/gem_make.out
(从根目录删除这个gem并且重新安装也得到相同的结果)
然后我厌倦了这个 gem 形式 bundler.rubygems.org,然后 在本地安装它 。得到同样的错误:
C:\Users\Administrator>d:
D:\>cd rubyDownloads
D:\rubyDownloads>gem install websocket-driver-0.7.5.gem --local
Building native extensions. This could take a while...
ERROR: Error installing websocket-driver-0.7.5.gem:
ERROR: Failed to build gem native extension.
current directory: D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5/ext/websocket-driver
D:/Ruby31-x64/bin/ruby.exe -I D:/Ruby31-x64/lib/ruby/site_ruby/3.1.0 -r ./siteconf20220129-5896-885p1m.rb extconf.rb
creating Makefile
current directory: D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5/ext/websocket-driver
make DESTDIR\= clean
current directory: D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5/ext/websocket-driver
make DESTDIR\=
make failedNo such file or directory - make
Gem files will remain installed in D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5 for inspection.
Results logged to D:/Ruby31-x64/lib/ruby/gems/3.1.0/extensions/x64-mingw-ucrt/3.1.0/websocket-driver-0.7.5/gem_make.out
现在问题变成了:gemwebsocket-driver
和任何其他依赖它的gem不能' t安装成功,ERROR如上图
刚放假回来,这个问题已经在假期解决了。原谅我直到now.XD
才记得关闭这个issue
在 Josien 的评论的帮助下,问题已缩小为 gem install websocket-driver
失败。这个问题在Whosebug上比较容易找到-
最后,我通过输入ridk install
解决了这个问题(让MSYS2适用于ruby3.0.1)——我已经安装了MSYS2并让它在 ruby2.7.4 下工作,但是如果你想让它同样在 ruby3.0.1 下工作,你需要在 ruby3.0.1.
下执行这个命令
为ruby3.0.1安装MSYS2后,rails安装成功
C:\Users\Administrator>Uru ls
274p191 : ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x64-mingw32]
310p0 : ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x64-mingw-ucrt]
C:\Users\Administrator>ruby -v
ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x64-mingw-ucrt]
C:\Users\Administrator>ridk install
_____ _ _____ _ _ _ ___
| __ \ | | |_ _| | | | | | |__ \
| |__) | _| |__ _ _ | | _ __ ___| |_ __ _| | | ___ _ __ ) |
| _ / | | | '_ \| | | | | | | '_ \/ __| __/ _` | | |/ _ \ '__/ /
| | \ \ |_| | |_) | |_| |_| |_| | | \__ \ || (_| | | | __/ | / /_
|_| \_\__,_|_.__/ \__, |_____|_| |_|___/\__\__,_|_|_|\___|_||____|
__/ | _
|___/ _|_ _ __ | | o __ _| _ _
| (_) | |^| | | |(_|(_)\^/_>
1 - MSYS2 base installation
2 - MSYS2 system update (optional)
3 - MSYS2 and MINGW development toolchain
Which components shall be installed? If unsure press ENTER [1,3] 1,3
> sh -lc true
MSYS2 seems to be properly installed
Install MSYS2 and MINGW development toolchain ...
> pacman -S --needed --noconfirm autoconf autogen automake-wrapper diffutils file
...
...
...
Install MSYS2 and MINGW development toolchain succeeded
1 - MSYS2 base installation
2 - MSYS2 system update (optional)
3 - MSYS2 and MINGW development toolchain
Which components shall be installed? If unsure press ENTER []
C:\Users\Administrator>gem install rails
Building native extensions. This could take a while...
Successfully installed websocket-driver-0.7.5
Building native extensions. This could take a while...
Successfully installed nio4r-2.5.8
Successfully installed actioncable-7.0.2
Successfully installed rails-7.0.2
Parsing documentation for websocket-driver-0.7.5
Installing ri documentation for websocket-driver-0.7.5
Parsing documentation for nio4r-2.5.8
Installing ri documentation for nio4r-2.5.8
Parsing documentation for actioncable-7.0.2
Installing ri documentation for actioncable-7.0.2
Parsing documentation for rails-7.0.2
Installing ri documentation for rails-7.0.2
Done installing documentation for websocket-driver, nio4r, actioncable, rails after 2 seconds
4 gems installed
C:\Users\Administrator>rails -v
Rails 7.0.2
Ruby 的新手,刚刚开始 rails 旅程。
已经搜索了 Whosebug,但这些问题很多都是很久以前的问题了。我的英文不好,请容忍我的描述。这是我的情况,希望我说清楚。
我在 windows。 当我在线学习 ruby 课程时,我安装了一个 较旧的环境 -- ruby2.7.4 和 rails 7.0.1.
昨天我想用更新的 ruby 环境完成一个新项目 -- 所以我安装了 ruby3.1.0,但是当我尝试 安装 rails 对于这个新的 Ruby verison,发生错误。
这是我的环境:
C:\Users\Administrator>uru ls
274p191 : ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x64-mingw32]
310p0 : ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x64-mingw-ucrt]
C:\Users\Administrator>ruby -v
ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x64-mingw-ucrt]
C:\Users\Administrator>gem -v
3.3.6
C:\Users\Administrator>d:
D:\>cd RubyDevkit
D:\RubyDevkit>ruby dk.rb install
[INFO] Skipping existing gem override for 'D:/Ruby27-x64'
[WARN] Skipping existing DevKit helper library for 'D:/Ruby27-x64'
[INFO] Skipping existing gem override for 'D:/Ruby31-x64'
[WARN] Skipping existing DevKit helper library for 'D:/Ruby31-x64'
D:\RubyDevkit>
如您所见,我当前的 ruby 版本是 3.1.0,我想我已经为我的两个 Rubies 成功安装了 Devkit。
我也安装了 MSYS2(虽然我不知道为什么 ruby 需要它,但我遇到了另一个错误提醒我安装 MSYS 并添加它到路径)
我想在遇到这个错误之前我已经做对了所有事情:
C:\Users\Administrator>gem install rails
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
current directory: D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5/ext/websocket-driver
D:/Ruby31-x64/bin/ruby.exe -I D:/Ruby31-x64/lib/ruby/site_ruby/3.1.0 -r ./siteconf20220128-11340-9w9ez5.rb extconf.rb
creating Makefile
current directory: D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5/ext/websocket-driver
make DESTDIR\= clean
current directory: D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5/ext/websocket-driver
make DESTDIR\=
make failedNo such file or directory - make
Gem files will remain installed in D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5 for inspection.
Results logged to D:/Ruby31-x64/lib/ruby/gems/3.1.0/extensions/x64-mingw-ucrt/3.1.0/websocket-driver-0.7.5/gem_make.out
当我为 ruby2.7.4 安装 rails 时没有异常(相同的命令刚刚完成,没有错误或警告)。
我在网上找不到类似的情况。有人可以帮忙吗?
--------------------01/29----------------划分----- ----------------------
感谢评论,发人深省。遵循一些计划(虽然失败了)
我尝试单独安装 gem websocket-driver
,得到了同样的错误:
C:\Users\Administrator>gem install websocket-driver:0.7.5
Building native extensions. This could take a while...
ERROR: Error installing websocket-driver:
ERROR: Failed to build gem native extension.
current directory: D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5/ext/websocket-driver
D:/Ruby31-x64/bin/ruby.exe -I D:/Ruby31-x64/lib/ruby/site_ruby/3.1.0 -r ./siteconf20220129-3864-wqfhn2.rb extconf.rb
creating Makefile
current directory: D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5/ext/websocket-driver
make DESTDIR\= clean
current directory: D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5/ext/websocket-driver
make DESTDIR\=
make failedNo such file or directory - make
Gem files will remain installed in D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5 for inspection.
Results logged to D:/Ruby31-x64/lib/ruby/gems/3.1.0/extensions/x64-mingw-ucrt/3.1.0/websocket-driver-0.7.5/gem_make.out
(从根目录删除这个gem并且重新安装也得到相同的结果)
然后我厌倦了这个 gem 形式 bundler.rubygems.org,然后 在本地安装它 。得到同样的错误:
C:\Users\Administrator>d:
D:\>cd rubyDownloads
D:\rubyDownloads>gem install websocket-driver-0.7.5.gem --local
Building native extensions. This could take a while...
ERROR: Error installing websocket-driver-0.7.5.gem:
ERROR: Failed to build gem native extension.
current directory: D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5/ext/websocket-driver
D:/Ruby31-x64/bin/ruby.exe -I D:/Ruby31-x64/lib/ruby/site_ruby/3.1.0 -r ./siteconf20220129-5896-885p1m.rb extconf.rb
creating Makefile
current directory: D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5/ext/websocket-driver
make DESTDIR\= clean
current directory: D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5/ext/websocket-driver
make DESTDIR\=
make failedNo such file or directory - make
Gem files will remain installed in D:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5 for inspection.
Results logged to D:/Ruby31-x64/lib/ruby/gems/3.1.0/extensions/x64-mingw-ucrt/3.1.0/websocket-driver-0.7.5/gem_make.out
现在问题变成了:gemwebsocket-driver
和任何其他依赖它的gem不能' t安装成功,ERROR如上图
刚放假回来,这个问题已经在假期解决了。原谅我直到now.XD
才记得关闭这个issue在 Josien 的评论的帮助下,问题已缩小为 gem install websocket-driver
失败。这个问题在Whosebug上比较容易找到-
最后,我通过输入ridk install
解决了这个问题(让MSYS2适用于ruby3.0.1)——我已经安装了MSYS2并让它在 ruby2.7.4 下工作,但是如果你想让它同样在 ruby3.0.1 下工作,你需要在 ruby3.0.1.
为ruby3.0.1安装MSYS2后,rails安装成功
C:\Users\Administrator>Uru ls
274p191 : ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x64-mingw32]
310p0 : ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x64-mingw-ucrt]
C:\Users\Administrator>ruby -v
ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x64-mingw-ucrt]
C:\Users\Administrator>ridk install
_____ _ _____ _ _ _ ___
| __ \ | | |_ _| | | | | | |__ \
| |__) | _| |__ _ _ | | _ __ ___| |_ __ _| | | ___ _ __ ) |
| _ / | | | '_ \| | | | | | | '_ \/ __| __/ _` | | |/ _ \ '__/ /
| | \ \ |_| | |_) | |_| |_| |_| | | \__ \ || (_| | | | __/ | / /_
|_| \_\__,_|_.__/ \__, |_____|_| |_|___/\__\__,_|_|_|\___|_||____|
__/ | _
|___/ _|_ _ __ | | o __ _| _ _
| (_) | |^| | | |(_|(_)\^/_>
1 - MSYS2 base installation
2 - MSYS2 system update (optional)
3 - MSYS2 and MINGW development toolchain
Which components shall be installed? If unsure press ENTER [1,3] 1,3
> sh -lc true
MSYS2 seems to be properly installed
Install MSYS2 and MINGW development toolchain ...
> pacman -S --needed --noconfirm autoconf autogen automake-wrapper diffutils file
...
...
...
Install MSYS2 and MINGW development toolchain succeeded
1 - MSYS2 base installation
2 - MSYS2 system update (optional)
3 - MSYS2 and MINGW development toolchain
Which components shall be installed? If unsure press ENTER []
C:\Users\Administrator>gem install rails
Building native extensions. This could take a while...
Successfully installed websocket-driver-0.7.5
Building native extensions. This could take a while...
Successfully installed nio4r-2.5.8
Successfully installed actioncable-7.0.2
Successfully installed rails-7.0.2
Parsing documentation for websocket-driver-0.7.5
Installing ri documentation for websocket-driver-0.7.5
Parsing documentation for nio4r-2.5.8
Installing ri documentation for nio4r-2.5.8
Parsing documentation for actioncable-7.0.2
Installing ri documentation for actioncable-7.0.2
Parsing documentation for rails-7.0.2
Installing ri documentation for rails-7.0.2
Done installing documentation for websocket-driver, nio4r, actioncable, rails after 2 seconds
4 gems installed
C:\Users\Administrator>rails -v
Rails 7.0.2