ERROR: Error installing racc: ERROR: Failed to build gem native extension

ERROR: Error installing racc: ERROR: Failed to build gem native extension

正在安装 rails:

gem install rails -v 6.1.3.1 --no-doc

无法安装 racc-1.5.2

正在尝试手动安装 racc-1.5.2:

gem install racc -v '1.5.2' --source 'https://rubygems.org/' --no-doc

产生同样的错误。

以下是错误的 'edited' 输出:

$ gem install rails -v 6.1.3.1 --no-doc

Fetching racc-1.5.2.gem
Fetching zeitwerk-2.4.2.gem
...
Successfully installed rack-2.2.3
Successfully installed rack-test-1.1.0
Building native extensions. This could take a while...
ERROR:  Error installing rails:
    ERROR: Failed to build gem native extension.

    current directory: /home/user/.rvm/gems/ruby-2.6.5@gemset/gems/racc-1.5.2/ext/racc/cparse
/home/user/.rvm/rubies/ruby-2.6.5/bin/ruby -I /home/user/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0 -r ./siteconf20210503-658786-pkp97m.rb extconf.rb
checking for rb_ary_subseq()... yes
creating Makefile

current directory: /home/user/.rvm/gems/ruby-2.6.5@gemset/gems/racc-1.5.2/ext/racc/cparse
make "DESTDIR=" clean

current directory: /home/user/.rvm/gems/ruby-2.6.5@gemset/gems/racc-1.5.2/ext/racc/cparse
make "DESTDIR="
compiling cparse.c
linking shared-object racc/cparse.so

current directory: /home/user/.rvm/gems/ruby-2.6.5@gemset/gems/racc-1.5.2/ext/racc/cparse
make "DESTDIR=" install
make: /usr/bin/mkdir: Command not found
make: *** [Makefile:202: .sitearchdir.-.racc.time] Error 127

make install failed, exit code 2

Gem files will remain installed in /home/user/.rvm/gems/ruby-2.6.5@gemset/gems/racc-1.5.2 for inspection.
Results logged to /home/user/.rvm/gems/ruby-2.6.5@gemset/extensions/x86_64-linux/2.6.0/racc-1.5.2/gem_make.out


这里的主要问题是命令 mkdir 在特定位置被调用,但它不在那里:

make: /usr/bin/mkdir: Command not found

要解决此问题,您需要向该位置添加符号 link:

$ sudo ln -s /bin/mkdir /usr/bin/mkdir

运行 gem install 再次 rails 一切都应该很好!

感谢用户 dem1tris 提出相关主题并提供答案: