0

I'm trying to create an Ruby on Rails "Hello World" application on our managed server where no root or sudo is possible.

Ruby is version 2.3.3p222, Rails is v5.2.4.1.

I used rails new testproject to create my "Hello World" test. This fails in bundle install because I can't install in the system gems getting

Error "Your user account isn't allowed to install to the system RubyGems"

Going to the testproject folder and entering:

bundle install --path ~/.gem

returns:

This failed with *"An error occurred while installing sqlite3 (1.4.2),
and Bundler cannot continue."*

The reason is an compiler error: *"conftest.c:13:57: error:
‘pthread_create’ undeclared (first use in this function)"* Problem:
The compiler can't find pthread because the *pthread.h* not included.
The only include in the conftest.c is *#include "ruby.h"* and this is
included from the system includes.

I extracted the gcc command from the logfile, changed the order of the include folders so my local include folder is now first. I placed a dummy "ruby.h" in my local include, that includes the "pthread.h" and the "ruby.h" from the system include folder.

The new gcc command is:

gcc -o conftest -I/usr/home/admin/include -I/usr/include/x86_64-linux-gnu/ruby-2.3.0 -I/usr/include/ruby-2.3.0/ruby/backward -I/usr/include/ruby-2.3.0 -I. -I/usr/include -Wdate-time -D_FORTIFY_SOURCE=2   -g -O2 -fdebug-prefix-map=/build/ruby2.3-LPgLkQ/ruby2.3-2.3.3=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DTAINTING_SUPPORT conftest.c  -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic     -lruby-2.3 -lfalse  -lpthread -lgmp -ldl -lcrypt -lm   -lc

New error now:

cannot find -lfalse 

When I remove the -lfalse from the gcc command I get no more errors.

So now I know that the missing include for "pthread.h" is my first problem. And the -lfalse is the second one. But how can I solve this? How can I tell bundle install to include the pthread.h? Why is there an -lfalse?

I took me some hours to get to this point but I've no idea how to continue now.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Klaus Friese
  • 109
  • 1
  • 10
  • Have you seen this thread? Maybe it will help: https://stackoverflow.com/questions/9168089/pthreads-compile-not-working – Yorkshireman Feb 28 '20 at 10:44
  • 4
    If you are struggling with setting up SQLite just bypass it and go straight to Postgres/MySql/MariaDB or whatever your poison is. You're most likely not going to be deploying to SQLite and you should be deploying, developing and testing on the same RDBMS as there are many small incompatibilities that can ruin your day and you don't want to discover them when you deploy. The only reason SQLite is the default is that its usually easy to setup so that you can quickly get to a "Hello World" app or for rapid prototyping. – max Feb 28 '20 at 15:25
  • 1
    @KlausFriese, maybe this helps for PostgreSQL: https://www.digitalocean.com/community/tutorials/how-to-use-postgresql-with-your-ruby-on-rails-application-on-ubuntu-18-04 – iGian Feb 28 '20 at 20:28
  • Install RVM with `\curl -sSL https://get.rvm.io | bash -s stable`; restart your shell; install Ruby with `rvm install 2.3.3`. [Don't](https://robots.thoughtbot.com/psa-do-not-use-system-ruby) [use](https://chrisherring.co/posts/why-you-shouldn-t-use-the-system-ruby) [system Ruby](http://billpatrianakos.me/blog/2014/05/15/never-use-system-ruby-ever/). Then install Rails, then retry your operation. – anothermh Feb 29 '20 at 01:16
  • RVM might help, but follow the installation directions on https://rvm.io _AFTER_ reading what it does and how it works. – the Tin Man Feb 29 '20 at 05:16
  • @iGian - thanks, that helped. I created the app for mysql and I can start it now :) – Klaus Friese Mar 02 '20 at 15:58

0 Answers0