Issue with Puma when installing Rails on a Mac - ruby-on-rails

I'm trying to install Rails on my new machine, and I keep getting this error when bundling.
An error occurred while installing puma (4.3.5), and Bundler cannot
continue.
Make sure that `gem install puma -v '4.3.5' --source 'https://rubygems.org/'`
succeeds before bundling.
In Gemfile:
puma
When I run gem install puma -v '4.3.5' --source 'https://rubygems.org/, I get this error:
Building native extensions. This could take a while...
ERROR: Error installing puma:
ERROR: Failed to build gem native extension.
current directory: /Users/christopherdavis/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/puma-4.3.5/ext/puma_http11
/Users/christopherdavis/.rbenv/versions/2.7.1/bin/ruby -I /Users/christopherdavis/.rbenv/versions/2.7.1/lib/ruby/site_ruby/2.7.0 -r ./siteconf20200829-23175-2h0q0u.rb extconf.rb
checking for BIO_read() in -lcrypto... yes
checking for SSL_CTX_new() in -lssl... yes
checking for openssl/bio.h... yes
checking for DTLS_method() in openssl/ssl.h... yes
checking for TLS_server_method() in openssl/ssl.h... yes
checking for SSL_CTX_set_min_proto_version in openssl/ssl.h... yes
creating Makefile
current directory: /Users/christopherdavis/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/puma-4.3.5/ext/puma_http11
make "DESTDIR=" clean
current directory: /Users/christopherdavis/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/puma-4.3.5/ext/puma_http11
make "DESTDIR="
compiling http11_parser.c
ext/puma_http11/http11_parser.c:44:18: warning: unused variable 'puma_parser_en_main' [-Wunused-const-variable]
static const int puma_parser_en_main = 1;
^
1 warning generated.
compiling io_buffer.c
compiling mini_ssl.c
mini_ssl.c:145:7: warning: unused variable 'min' [-Wunused-variable]
int min, ssl_options;
^
mini_ssl.c:299:40: warning: function 'raise_error' could be declared with attribute 'noreturn' [-Wmissing-noreturn]
void raise_error(SSL* ssl, int result) {
^
2 warnings generated.
compiling puma_http11.c
puma_http11.c:203:22: error: implicitly declaring library function 'isspace' with type 'int (int)' [-Werror,-Wimplicit-function-declaration]
while (vlen > 0 && isspace(value[vlen - 1])) vlen--;
^
puma_http11.c:203:22: note: include the header <ctype.h> or explicitly provide a declaration for 'isspace'
1 error generated.
make: *** [puma_http11.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/christopherdavis/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/puma-4.3.5 for inspection.
Results logged to /Users/christopherdavis/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/extensions/x86_64-darwin-20/2.7.0/puma-4.3.5/gem_make.out
Has anyone seen this before? How might I fix the issue? I'm new to Rails and unsure of what's going on. I followed the tutorial on GoRails and found myself here.
Thanks!

See https://github.com/puma/puma/pull/2314
Run this line...
bundle config build.puma --with-cflags="-Wno-error=implicit-function-declaration"

Related

Error installing gem bson_ext version 1.5.1

I am trying to set up a ruby 2.3.0 project in my system . Upon running bundle install , I am getting the following error :-
Fetching bson_ext 1.5.1
Installing bson_ext 1.5.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/admin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bson_ext-1.5.1/ext/cbson
/Users/admin/.rbenv/versions/2.3.0/bin/ruby -I /Users/admin/.rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0 -r ./siteconf20201009-77301-z7iyto.rb
extconf.rb
checking for asprintf()... yes
checking for ruby/st.h... yes
checking for ruby/regex.h... yes
checking for ruby/encoding.h... yes
creating Makefile
current directory: /Users/admin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bson_ext-1.5.1/ext/cbson
make "DESTDIR=" clean
current directory: /Users/admin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bson_ext-1.5.1/ext/cbson
make "DESTDIR="
compiling encoding_helpers.c
compiling cbson.c
cbson.c:118:36: warning: passing 'char *' to parameter of type 'const unsigned char *' converts between pointers to integer types with different sign [-Wpointer-sign]
result_t status = check_string(RSTRING_PTR(string), RSTRING_LEN(string),
^~~~~~~~~~~~~~~~~~~
/Users/admin/.rbenv/versions/2.3.0/include/ruby-2.3.0/ruby/ruby.h:994:5: note: expanded from macro 'RSTRING_PTR'
(!(RBASIC(str)->flags & RSTRING_NOEMBED) ? \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./encoding_helpers.h:26:44: note: passing argument to parameter 'string' here
result_t check_string(const unsigned char* string, const int length,
^
cbson.c:602:18: error: implicit declaration of function 'bson_buffer_get_max_size' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
if (length > bson_buffer_get_max_size(buffer)) {
^
cbson.c:602:18: note: did you mean 'bson_buffer_set_max_size'?
./bson_buffer.h:34:6: note: 'bson_buffer_set_max_size' declared here
void bson_buffer_set_max_size(bson_buffer_t buffer, int max_size);
^
1 warning and 1 error generated.
make: *** [cbson.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/admin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bson_ext-1.5.1 for inspection.
Results logged to /Users/admin/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-18/2.3.0-static/bson_ext-1.5.1/gem_make.out
An error occurred while installing bson_ext (1.5.1), and Bundler cannot continue.
Make sure that `gem install bson_ext -v '1.5.1'` succeeds before bundling.
In Gemfile:
bson_ext
Changing the bson_ext version does not work . I specifically need version 1.5.1 for the project.
Please help !!!

Semian gem Gem::Ext::BuildError: ERROR on Ubuntu 20.04

Fresh Ubuntu 20.04 install, when I try to bundle my project, I get this error which I'm not sure what's producing it.
Installing semian 0.10.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /home/fran/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/semian-0.10.0/ext/semian
/home/fran/.rbenv/versions/2.4.3/bin/ruby -r ./siteconf20200922-5726-1n8pgk.rb extconf.rb --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include
checking for openssl/sha.h... yes
checking for SHA1() in -lcrypto... yes
checking for sys/ipc.h... yes
checking for sys/sem.h... yes
checking for sys/types.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_thread_call_without_gvl()... yes
creating Makefile
current directory: /home/fran/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/semian-0.10.0/ext/semian
make "DESTDIR=" clean
current directory: /home/fran/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/semian-0.10.0/ext/semian
make "DESTDIR="
compiling resource.c
In file included from /home/fran/.rbenv/versions/2.4.3/include/ruby-2.4.0/ruby.h:33,
from sysv_semaphores.h:15,
from resource.h:10,
from resource.c:1:
/home/fran/.rbenv/versions/2.4.3/include/ruby-2.4.0/ruby/ruby.h:631:1: error: ‘const’ attribute on function returning ‘void’ [-Werror=attributes]
631 | CONSTFUNC(void rb_secure_update(VALUE));
| ^~~~~~~~~
In file included from /home/fran/.rbenv/versions/2.4.3/include/ruby-2.4.0/ruby/ruby.h:2008,
from /home/fran/.rbenv/versions/2.4.3/include/ruby-2.4.0/ruby.h:33,
from sysv_semaphores.h:15,
from resource.h:10,
from resource.c:1:
/home/fran/.rbenv/versions/2.4.3/include/ruby-2.4.0/ruby/intern.h:257:1: error: ‘const’ attribute on function returning ‘void’ [-Werror=attributes]
257 | CONSTFUNC(void rb_error_untrusted(VALUE));
| ^~~~~~~~~
/home/fran/.rbenv/versions/2.4.3/include/ruby-2.4.0/ruby/intern.h:259:1: error: ‘const’ attribute on function returning ‘void’ [-Werror=attributes]
259 | CONSTFUNC(void rb_check_trusted(VALUE));
| ^~~~~~~~~
cc1: all warnings being treated as errors
make: *** [Makefile:242: resource.o] Error 1
make failed, exit code 2
Gem files will remain installed in /home/fran/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/semian-0.10.0 for inspection.
Results logged to /home/fran/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/extensions/x86_64-linux/2.4.0/semian-0.10.0/gem_make.out
An error occurred while installing semian (0.10.0), and Bundler cannot continue.
Make sure that `gem install semian -v '0.10.0' --source 'https://rubygems.org/'` succeeds before bundling.
Did not have this problem bundling other projects that require native extensions, just this one where we make use of the semian gem.

Puma doesn't installed

I'm new in Ruby and Rails. I've already installed node=v12.18.2, nvm=0.32.1, yarn=1.22.4, rbenv=1.1.2, ruby=2.7.1, rails=6.0.3.2, sqlite3=3.28.0, openssl via homebrew.
I'm using mac.
When I'm trying to start new project with command
rails new .
I have this stacktrace:
...
Fetching puma 4.3.5
Installing puma 4.3.5 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/kir/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/puma-4.3.5/ext/puma_http11
/Users/kir/.rbenv/versions/2.7.1/bin/ruby -I /Users/kir/.rbenv/versions/2.7.1/lib/ruby/2.7.0 -r ./siteconf20200822-18390-17806vx.rb extconf.rb --with-opt-dir\=/usr/local/opt/openssl
checking for BIO_read() in -lcrypto... yes
checking for SSL_CTX_new() in -lssl... yes
checking for openssl/bio.h... yes
checking for DTLS_method() in openssl/ssl.h... yes
checking for TLS_server_method() in openssl/ssl.h... yes
checking for SSL_CTX_set_min_proto_version in openssl/ssl.h... yes
creating Makefile
current directory: /Users/kir/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/puma-4.3.5/ext/puma_http11
make "DESTDIR=" clean
current directory: /Users/kir/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/puma-4.3.5/ext/puma_http11
make "DESTDIR="
compiling http11_parser.c
ext/puma_http11/http11_parser.c:44:18: warning: unused variable 'puma_parser_en_main' [-Wunused-const-variable]
static const int puma_parser_en_main = 1;
^
1 warning generated.
compiling io_buffer.c
compiling mini_ssl.c
mini_ssl.c:145:7: warning: unused variable 'min' [-Wunused-variable]
int min, ssl_options;
^
mini_ssl.c:299:40: warning: function 'raise_error' could be declared with attribute 'noreturn' [-Wmissing-noreturn]
void raise_error(SSL* ssl, int result) {
^
2 warnings generated.
compiling puma_http11.c
puma_http11.c:203:22: error: implicitly declaring library function 'isspace' with type 'int (int)' [-Werror,-Wimplicit-function-declaration]
while (vlen > 0 && isspace(value[vlen - 1])) vlen--;
^
puma_http11.c:203:22: note: include the header <ctype.h> or explicitly provide a declaration for 'isspace'
1 error generated.
make: *** [puma_http11.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/kir/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/puma-4.3.5 for inspection.
Results logged to /Users/kir/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/extensions/x86_64-darwin-19/2.7.0/puma-4.3.5/gem_make.out
An error occurred while installing puma (4.3.5), and Bundler cannot continue.
Make sure that `gem install puma -v '4.3.5' --source 'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
puma
run bundle binstubs bundler
Could not find gem 'sqlite3 (~> 1.4)' in any of the gem sources listed in your Gemfile.
run bundle exec spring binstub --all
bundler: command not found: spring
Install missing gem executables with `bundle install`
rails webpacker:install
Could not find gem 'sqlite3 (~> 1.4)' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems.
What's wrong and what should I do?

Failure to install old mysql2 gem

I am using Mac High Sierra. I am using Ruby 2.2.1 with RVM. I need to use mysql2 with this Ruby on Rails app. I do have mysql 5.7 installed. I do have xcode installed along with the command-line tools.
I am simply trying to get this company app working on my local machine. I know that I am very close but I have one final error when I do bundle install I receive the following error when I get to the mysql2 gem:
Fetching mysql2 0.3.18
Installing mysql2 0.3.18 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/ahayden/.rvm/gems/ruby-2.2.1/gems/mysql2-0.3.18/ext/mysql2
/Users/ahayden/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20180710-52515-2hjll8.rb extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Using mysql_config at /usr/local/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
-----
Don't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load
-----
-----
Setting libpath to /usr/local/Cellar/mysql-connector-c/6.1.11/lib
-----
creating Makefile
current directory: /Users/ahayden/.rvm/gems/ruby-2.2.1/gems/mysql2-0.3.18/ext/mysql2
make "DESTDIR=" clean
current directory: /Users/ahayden/.rvm/gems/ruby-2.2.1/gems/mysql2-0.3.18/ext/mysql2
make "DESTDIR="
compiling infile.c
compiling client.c
client.c:359:33: warning: implicit conversion loses integer precision: 'long' to 'unsigned int' [-Wshorten-64-to-32]
elapsed_time = end_time - start_time;
~ ~~~~~~~~~^~~~~~~~~~~~
client.c:1163:56: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'unsigned int' [-Wshorten-64-to-32]
mysql2rb = mysql2_mysql_enc_name_to_rb(charset_name, charset_name_len);
~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~
2 warnings generated.
compiling mysql2_ext.c
compiling result.c
result.c:186:17: warning: comparison of integers of different signs: 'int' and 'unsigned long' [-Wsign-compare]
for (i = 0; i < (len - 1); i++) {
~ ^ ~~~~~~~
1 warning generated.
linking shared-object mysql2/mysql2.bundle
ld: library not found for -l-lpthread
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql2.bundle] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/ahayden/.rvm/gems/ruby-2.2.1/gems/mysql2-0.3.18 for inspection.
Results logged to /Users/ahayden/.rvm/gems/ruby-2.2.1/extensions/x86_64-darwin-17/2.2.0/mysql2-0.3.18/gem_make.out
An error occurred while installing mysql2 (0.3.18), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.18'` succeeds before bundling.
In Gemfile:
mysql2
I've tried just installing mysql2 without the specific gem version and it works, but it did not fix my problem. It seems to boil down to the bottom of the traceback where it cannot find library -l-lpthread. Please help, I've been trying to do this all day.
This fixed it for me
gem install mysql2 -v '0.3.21' -- --with-cflags=\"-I/usr/local/opt/openssl/include\" --with-ldflags=\"-L/usr/local/opt/openssl/lib\"
after installing openssl
brew install openssl
As per the description shared it seems like the mysql dependencies are unable to install.
First we need to ‘locate mysql_config’ and then replace the path in the following command with where that file is.
gem install mysql2 -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

Cannot install sqlite3 gem

I am trying to run the bundle command to install all the gems for a todo application. All gems have downloaded without a problem but the sqlite3 gem has not. I have no idea what the following means could somebody please explain what is going on and how to fix?
Installing sqlite3 1.3.8 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/tomfinet/.rbenv/versions/2.2.3/bin/ruby -r ./siteconf20151208-
2023-1esrcfp.rb extconf.rb
checking for sqlite3.h... yes
checking for sqlite3_libversion_number() in -lsqlite3... yes
checking for rb_proc_arity()... yes
checking for sqlite3_initialize()... yes
checking for sqlite3_backup_init()... yes
checking for sqlite3_column_database_name()... no
checking for sqlite3_enable_load_extension()... no
checking for sqlite3_load_extension()... no
checking for sqlite3_open_v2()... yes
checking for sqlite3_prepare_v2()... yes
checking for sqlite3_int64 in sqlite3.h... yes
checking for sqlite3_uint64 in sqlite3.h... yes
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling backup.c
compiling database.c
compiling exception.c
compiling sqlite3.c
compiling statement.c
statement.c:261:11: warning: implicit declaration of function 'RBIGNUM' is invalid in C99 [-Wimplicit-function-declaration]
if (RBIGNUM_LEN(value) * SIZEOF_BDIGITS <= 8) {
^
./sqlite3_ruby.h:16:24: note: expanded from macro 'RBIGNUM_LEN'
#define RBIGNUM_LEN(x) RBIGNUM(x)->len
^
statement.c:261:11: error: member reference type 'int' is not a pointer
if (RBIGNUM_LEN(value) * SIZEOF_BDIGITS <= 8) {
^~~~~~~~~~~~~~~~~~
./sqlite3_ruby.h:16:36: note: expanded from macro 'RBIGNUM_LEN'
#define RBIGNUM_LEN(x) RBIGNUM(x)->len
~~~~~~~~~~ ^
statement.c:261:32: error: use of undeclared identifier 'SIZEOF_BDIGITS'
if (RBIGNUM_LEN(value) * SIZEOF_BDIGITS <= 8) {
^
1 warning and 2 errors generated.
make: *** [statement.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/tomfinet/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sqlite3-1.3.8 for inspection.
Results logged to /Users/tomfinet/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0-static/sqlite3-1.3.8/gem_make.out
An error occurred while installing sqlite3 (1.3.8), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.8'` succeeds before bundling.
What is the problem and how do I fix it?
Thanks.
bundle update sqlite3
Have a look at this gist
Ah, looks like it’s an issue with the sqlite3 v1.4.0 gem which was released on February 4.
Mention the following sqlite3 version in your gem file:
gem "sqlite3", "~> 1.3.6”
Then make sure to “bundle install”.
You need the SQLite3 development headers for the gem’s native extension to compile against. You can install them by running (possibly with sudo):
apt-get install libsqlite3-dev
After which, be sure to run
bundle update sqlite3

Resources