ERROR: Error installing racc: ERROR: Failed to build gem native extension - ruby-on-rails

Ubuntu 20.04.2 LTS
Installing Rails 6.1.3.1
Ruby: 2.6.5
Installing rails:
gem install rails -v 6.1.3.1 --no-doc
Fails to install racc-1.5.2
Trying to manually install racc-1.5.2:
gem install racc -v '1.5.2' --source 'https://rubygems.org/' --no-doc
produces the same error.
The following is an 'edited' output of the error:
$ 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

The main problem here is that the command mkdir is being called at a specific location, and it's just not there:
make: /usr/bin/mkdir: Command not found
To fix this, you need to add a symbolic link to that location:
$ sudo ln -s /bin/mkdir /usr/bin/mkdir
Run gem install again on rails and all should be good!
Thanks to user dem1tris from brining up a related topic, and providing the answer: make: /usr/bin/mkdir: Command not found during `gem install nokogiri` in Ubuntu 20.04

Related

Installing json -v '1.8.6' gem, throws gcc error

some one in my team just updated some gem in the gemfile because of which gem json is resolved to version '1.8.6'. Which is not being installed. The error it throws is following:
anas:~$ sudo gem install json -v '1.8.6'
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.3.0/gems/json-
1.8.6/ext/json/ext/generator
/usr/bin/ruby2.3 -r ./siteconf20171017-7274-1ea5ank.rb extconf.rb
creating Makefile
current directory: /var/lib/gems/2.3.0/gems/json-
1.8.6/ext/json/ext/generator
make "DESTDIR=" clean
current directory: /var/lib/gems/2.3.0/gems/json-
1.8.86/ext/json/ext/generator
make "DESTDIR="
compiling generator.c
gcc: error: unrecognized command line option ‘-Wdate-time’
gcc: error: unrecognized command line option ‘-fstack-protector-
strong’
Makefile:239: recipe for target 'generator.o' failed
make: *** [generator.o] Error 1
make failed, exit code 2
Gem files will remain installed in /var/lib/gems/2.3.0/gems/json-1.8.6
for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-
linux/2.3.0/json-1.8.6/gem_make.out
My ruby is 2.3.1p112 and gcc version is 4.7.4. I have tried to find out which gcc version json -v 1.8.6 use but I did not find anything.
Thanks in advance
As pr my undarstanding the solution is to install libgmp3-dev.
sudo apt-get install libgmp3-dev

Rails: Error installing Bcrypt using Capistrano

I'm running Ruby 2.3.0 and wish to deploy my Rails app to Ubuntu 14 using Capistrano 3.
When executing cap production deploy I get the following error message:
SSHKit::Runner::ExecuteError: Exception while executing as
developer#[myVPS]: bundle exit status: 5 bundle stdout: An
error occurred while installing bcrypt (3.1.10), and Bundler cannot
continue. Make sure that gem install bcrypt -v '3.1.10' succeeds
before bundling. bundle stderr: Nothing written
On my local machine (same Ruby version) bcrypt 3.1.10 installs just fine.
When I login using ssh developer#myvps and directly run
sudo gem install bcrypt -v '3.1.10' I get:
Fetching: bcrypt-3.1.10.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing bcrypt:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.3.0/gems/bcrypt-3.1.10/ext/mri /usr/bin/ruby2.3 -r ./siteconf20160305-7301-vt7ls4.rb extconf.rb
creating Makefile
current directory: /var/lib/gems/2.3.0/gems/bcrypt-3.1.10/ext/mri make
"DESTDIR=" clean sh: 1: make: not found
current directory: /var/lib/gems/2.3.0/gems/bcrypt-3.1.10/ext/mri make
"DESTDIR=" sh: 1: make: not found
make failed, exit code 127
Gem files will remain installed in
/var/lib/gems/2.3.0/gems/bcrypt-3.1.10 for inspection. Results logged
to
/var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/bcrypt-3.1.10/gem_make.out
I'm new to all this, so not sure how to approach this. What should I do in this case?

Error installing json on windows 8.1

I have installed rails 4.2.3 and ruby 2.2.2p95 on windows 8.1 x64 . When I try to run "bundle install" the installation fails because of json -v 1.8.3. I already have json version 1.8.1 installed. When I run rubygems update command it does not get updated. If I try to individually run gem install json -v 1.8.3 or gem install json --platform=ruby --version=1.8.3 I get the following error.
ERROR: While executing gem ... (OptionParser::InvalidArgument)
invalid argument: -platform=ruby
C:\>gem install json --platform=ruby --version=1.8.3
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
C:/Ruby22-x64/bin/ruby.exe -r ./siteconf20150719-4308-1m86usl.rb extconf.rb
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
generating generator-x64-mingw32.def
compiling generator.c
make: x86_64-w64-mingw32-gcc: Command not found
make: *** [generator.o] Error 127
make failed, exit code 2
Gem files will remain installed in C:/Ruby22- x64/lib/ruby/gems/2.2.0/gems/json-1
.8.3 for inspection.
Results logged to C:/Ruby22-x64/lib/ruby/gems/2.2.0/extensions/x64-mingw32/2.2.0
/json-1.8.3/gem_make.out
Looks like you might have the 32-bit DevKit installed instead. Try uninstalling the DevKit you have and downloading and re-installing the latest 64-bit one. For more detail check out this similar answer:
https://stackoverflow.com/a/16579088/4034665
Try this gem install --verbose json -v 1.8.3. This should install the gem.

Ruby - gem install escape_utils fails with errors?

When I tried to install the
gem install escape_utils -v '0.3.2'
it gives me following errors which I don't know how to fix
I am using
ruby --version
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
rails -v
Could not find escape_utils-0.3.2 in any of the sources
Run `bundle install` to install missing gems.
The error I get when trying to install is
gem install escape_utils -v '0.3.2'
Building native extensions. This could take a while...
ERROR: Error installing escape_utils:
ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-2.2.2/bin/ruby -r ./siteconf20150613-4082-zkyiyc.rb extconf.rb
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling houdini_xml_e.c
compiling buffer.c
compiling escape_utils.c
escape_utils.c: In function ‘rb_eu_escape_html_as_html_safe’:
escape_utils.c:126: error: assignment of read-only member ‘klass’
make: *** [escape_utils.o] Error 1
make failed, exit code 2
Gem files will remain installed in /usr/local/rvm/gems/ruby-2.2.2/gems/escape_utils-0.3.2 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.2.2/extensions/x86_64-linux/2.2.0/escape_utils-0.3.2/gem_make.out
This is issue with escape_utils itself. You should edit Gemfile.lock file and change escape_utils (0.3.2) to escape_utils (1.1.0).

I've been despaired about "Failed to build gem native extension"

I installed rvm and ruby 2.0.0 on my ubuntu 13.04 and everything was fine, but the last step went wrong when I install rails 4.0.0
The following is what happened after I run: " gem install rails -v 4.0.0 ":
**Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/home/adolph/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb
creating Makefile
make
compiling atomic_reference.c
linking shared-object atomic_reference.so
make install
/usr/bin/install -c -m 0755 atomic_reference.so /home/adolph/.rvm/gems/ruby-2.0.0-p247/gems/atomic-1.1.14/lib/home/adolph/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/x86_64-linux
/usr/bin/install: cannot create regular file ‘/home/adolph/.rvm/gems/ruby-2.0.0-p247/gems/atomic-1.1.14/lib/home/adolph/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/x86_64-linux’: No such file or directory
make: *** [install-so] Error 1
Gem files will remain installed in /home/adolph/.rvm/gems/ruby-2.0.0-p247/gems/atomic-1.1.14 for inspection.
Results logged to /home/adolph/.rvm/gems/ruby-2.0.0-p247/gems/atomic-1.1.14/ext/gem_make.out**
It looks like the *‘/home/adolph/.rvm/gems/ruby-2.0.0-p247/gems/atomic-1.1.14/lib/home/adolph/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/x86_64-linux’* doesn't exist.
Please help me!
You can try with this
sudo apt-get install build-essential
and after it
sudo gem install rails

Resources