Rails: Error installing Bcrypt using Capistrano - ruby-on-rails

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?

Related

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

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

How to fix ' Failed to build gem native extension' error with bootsnap with Windows

I am using Windows, and I just installed Ruby on Rails, ruby is version 2.6.3p62 (2019-04-16 revision 67580) [x64-mingw32], rails is version 6.0.0.
When running rails new blog (following this tutorial) bundle install runs.
I have tried reinstalling Ruby, changing its version, and even removing bootsnap and running something else, but even when trying to install the puma gem I get the same error.
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5/ext/bootsnap
C:/Ruby26-x64/bin/ruby.exe -I C:/Ruby26-x64/lib/ruby/2.6.0 -r
./siteconf20191028-6188-1rw29js.rb extconf.rb
creating Makefile
current directory:
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5/ext/bootsnap
make "DESTDIR=" clean
current directory:
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5/ext/bootsnap
make "DESTDIR="
generating bootsnap-x64-mingw32.def
compiling bootsnap.c
linking shared-object bootsnap/bootsnap.so
C:/Ruby26-x64/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
bootsnap.o:bootsnap.c:(.text+0x557): undefined reference to `__strcat_chk'
C:/Ruby26-x64/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
bootsnap.o:bootsnap.c:(.text+0xa07): undefined reference to `__chk_fail'
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile:261: bootsnap.so] Error 1
make failed, exit code 2
Gem files will remain installed in
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.5 for inspection.
Results logged to
C:/Ruby26-x64/lib/ruby/gems/2.6.0/extensions/x64-mingw32/2.6.0/bootsnap-1.4.5/gem_make.out
An error occurred while installing bootsnap (1.4.5), and Bundler cannot
continue.
Make sure that `gem install bootsnap -v '1.4.5' --source
'https://rubygems.org/'` succeeds before bundling.
Actually, Bootsnap won't work on Windows anyway, so I'd recommend just removing it from Gemfile. If you want to leave it for production environment, perhaps you should include it conditionally with something like:
gem 'bootsnap' unless (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)

Mina deploy a rails project failed"Gem::Ext::BuildError: ERROR: Failed to build gem native extension."

I use the mina to deploy a rails web app,but always have many error.
This is part of my mina's logs
Using mini_magick (4.5.1)
Installing pg (0.18.4)
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /var/www/sample_app/shared/bundle/ruby/2.3.0/gems/pg-0.18.4/ext
/usr/bin/ruby2.3 -r ./siteconf20160917-1997-acaacj.rb extconf.rb
Cannot allocate memory - /usr/bin/ruby2.3 -r ./siteconf20160917-1997-acaacj.rb extconf.rb 2>&1
Gem files will remain installed in /var/www/sample_app/tmp/build-14740431655892/vendor/bundle/ruby/2.3.0/gems/pg-0.18.4 for inspection.
Results logged to /var/www/sample_app/tmp/build-14740431655892/vendor/bundle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/pg-0.18.4/gem_make.out
An error occurred while installing pg (0.18.4), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.4'` succeeds before bundling.
! ERROR: Deploy failed.
-----> Cleaning up build
Unlinking current
OK
Connection to IP closed.
! Command failed.
Failed with status 1 (4864)
I noticed Cannot allocate memory but I use top keep watch on the memory,only use about 50%(total 1G),and I am already run gem install pg -v '0.18.4',install pg succeed. I can use gem listfind it.
How to fix it?Thanks

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).

Rails Install fcgi on my mac

I'm using Rails 3.2 and ruby 1.9.2. I've added gem 'fcgi' (fastcgi) to my Gemfile, but when I run bundle install it fails on the fcgi.
output:
Installing fcgi (0.9.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/johndcowan/.rvm/rubies/ruby-1.9.2-p318/bin/ruby extconf.rb
checking for fcgiapp.h... no
checking for fastcgi/fcgiapp.h... no
make
make: *** No targets. Stop.
Gem files will remain installed in /Users/johndcowan/.rvm/gems/ruby-1.9.2-p318/gems/fcgi- 0.9.1 for inspection.
Results logged to /Users/johndcowan/.rvm/gems/ruby-1.9.2-p318/gems/fcgi-0.9.1/ext/fcgi/gem_make.out
An error occured while installing fcgi (0.9.1), and Bundler cannot continue.
Make sure that `gem install fcgi -v '0.9.1'` succeeds before bundling.
Installing fcgi (0.9.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/johndcowan/.rvm/rubies/ruby-1.9.2-p318/bin/ruby extconf.rb
checking for fcgiapp.h... no
checking for fastcgi/fcgiapp.h... no
make
make: *** No targets. Stop.
Gem files will remain installed in /Users/johndcowan/.rvm/gems/ruby-1.9.2-p318/gems/fcgi-0.9.1 for inspection.
Results logged to /Users/johndcowan/.rvm/gems/ruby-1.9.2-p318/gems/fcgi-0.9.1/ext/fcgi/gem_make.out
An error occured while installing fcgi (0.9.1), and Bundler cannot continue.
Make sure that `gem install fcgi -v '0.9.1'` succeeds before bundling.
Then, I ran the gem install as suggested:
johns-MacBook-Pro:drywall johndcowan$ sudo gem install fcgi -v '0.9.1'
Fetching: fcgi-0.9.1.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing fcgi:
ERROR: Failed to build gem native extension.
/Users/johndcowan/.rvm/rubies/ruby-1.9.2-p318/bin/ruby extconf.rb
checking for fcgiapp.h... no
checking for fastcgi/fcgiapp.h... no
make
make: *** No targets. Stop.
Gem files will remain installed in /Users/johndcowan/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/gems/1.9.1/gems/fcgi-0.9.1 for inspection.
Results logged to /Users/johndcowan/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/gems/1.9.1/gems/fcgi-0.9.1/ext/fcgi/gem_make.out
johns-MacBook-Pro:drywall johndcowan$
I found a user with the same problem and he/she installed fcgi_devel using yum which solved his/her problem with fcgi. I tried instaling using port but it won't work. The same site said I do not need yum.
sudo port install fcgi-devel
Error: Port fcgi-devel not found
Any ideas?
If using Homebrew, try brew install fastcgi first.

Resources