rbenv failing to install Ruby [duplicate] - ruby-on-rails

I want to install gitlab, which don't recommend to use any ruby version manager.
But
This is my OS Linux dqa-dev 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:08:14 UTC 2014 i686 i686 i686 GNU/Linux
linking shared-object psych.so
installing default psych libraries
make[2]: Leaving directory `/home/poc/ruby-2.0.0-p451/ext/psych'
make[2]: Entering directory `/home/poc/ruby-2.0.0-p451/ext/pty'
compiling pty.c
pty.c: In function 'chfunc':
pty.c:143:12: warning: ignoring return value of 'seteuid', declared with attribute warn_unused_result [-Wunused-result]
seteuid(getuid());
^
linking shared-object pty.so
installing default pty libraries
make[2]: Leaving directory `/home/poc/ruby-2.0.0-p451/ext/pty'
make[2]: Entering directory `/home/poc/ruby-2.0.0-p451/ext/racc/cparse'
compiling cparse.c
linking shared-object racc/cparse.so
installing default cparse libraries
make[2]: Leaving directory `/home/poc/ruby-2.0.0-p451/ext/racc/cparse'
make[2]: Entering directory `/home/poc/ruby-2.0.0-p451/ext/readline'
compiling readline.c
readline.c: In function 'Init_readline':
readline.c:1886:26: error: 'Function' undeclared (first use in this function)
rl_pre_input_hook = (Function *)readline_pre_input_hook;
^
readline.c:1886:26: note: each undeclared identifier is reported only once for each function it appears in
readline.c:1886:36: error: expected expression before ')' token
rl_pre_input_hook = (Function *)readline_pre_input_hook;
^
readline.c: At top level:
readline.c:530:1: warning: 'readline_pre_input_hook' defined but not used [-Wunused-function]
readline_pre_input_hook(void)
^
make[2]: *** [readline.o] Error 1
make[2]: Leaving directory `/home/poc/ruby-2.0.0-p451/ext/readline'
make[1]: *** [ext/readline/all] Error 2
make[1]: Leaving directory `/home/poc/ruby-2.0.0-p451'
make: *** [build-ext] Error 2

I also have Ubuntu 14.04 and I got to make it work. Sharing what I did just in case it works for you.
I patched the file ext/readline/readline.c replacing line 1886:
rl_pre_input_hook = (Function *)readline_pre_input_hook;
With
rl_pre_input_hook = (rl_hook_func_t *)readline_pre_input_hook;
Then I tried to make it again and it worked.
Source: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=741825

I also ran into this issue trying to install ruby-2.0.0-p247 with rbenv. Save some time by using this patch.
You can run it like this:
curl -fsSL https://gist.github.com/ference/d3d4cbbe18309a91ad9b/raw/267ea89fa145c536967831e1af4dea030297b53e/ruby-2.0.0-p247.patch | rbenv install --patch 2.0.0-p247

This is my solution on Ubuntu 14.04 Server edition.
I need to install underline
sudo apt-get install libreadline6 libreadline6-dev
Then, the problem was fixed.

Found a solution from https://github.com/sstephenson/ruby-build/issues/690. What actually missing is libffi-dev. I tried on Ubuntu 12.04 and it is successful.
sudo apt-get install libffi-dev

Related

BUILD FAILED (Ubuntu 20.04 using ruby-build 20210119)

I'm using rbenv and in Ec2 instance I'm trying to install a ruby different version but when I execute
rbenv install 2.7.2
following errors occur.
Downloading ruby-2.7.2.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.2.tar.bz2
Installing ruby-2.7.2...
BUILD FAILED (Ubuntu 20.04 using ruby-build 20210119)
Inspect or clean up the working tree at /tmp/ruby-build.20210217075101.162094.zs1iDJ
Results logged to /tmp/ruby-build.20210217075101.162094.log
Last 10 log lines:
compiling mjit.c
compiling mjit_compile.c
compiling node.c
compiling numeric.c
compiling object.c
compiling pack.c
compiling parse.c
gcc: fatal error: Killed signal terminated program cc1
compilation terminated.
make: *** [Makefile:421: parse.o] Error 1
meanwhile, my system is using the default ruby version
ubuntu#ip-112-34-9-342:~$ rbenv versions
* system (set by /home/ubuntu/.rbenv/version)
I don't confirm it is a space issue or something else, space information is listed below.
ubuntu#ip-112-34-9-342:~$ free
total used free shared buff/cache available
Mem: 486776 177636 89396 800 219744 287744
Swap: 0 0 0
Run the following -
$ sudo apt install gcc make curl libssl-dev zlib1g-dev
You are welcome.

BUILD FAILED (OS X 10.15.1 using ruby-build 20191124) when installing ruby-2.4.0 with rbenv in OSX catalina(10.15.1)

I tried a lot of things from online forums. But never worked. Installed Xcode to see if it works. But it doesn't.
At first, there was an issue with the C executables at the time of the OpenSSL installation. But later, I found from here, the error occurred because of Anaconda installation. So I uninstalled anaconda and tried to install again.
But now it is throwing a different error.
➜ ~ rbenv install 2.4.0 Downloading openssl-1.1.0j.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/31bec6c203ce1a8e93d5994f4ed304c63ccf07676118b6634edded12ad1b3246
Installing openssl-1.1.0j... Installed openssl-1.1.0j to
/Users/akashpinnaka/.rbenv/versions/2.4.0
Downloading ruby-2.4.0.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.0.tar.bz2 Installing ruby-2.4.0... ruby-build: using readline from homebrew
BUILD FAILED (OS X 10.15.1 using ruby-build 20191124)
Inspect or clean up the working tree at
/var/folders/xs/gy8wglwj22g9lbhqfv9mwp7m0000gn/T/ruby-build.20191205014031.81437.0Fmlfl
Results logged to
/var/folders/xs/gy8wglwj22g9lbhqfv9mwp7m0000gn/T/ruby-build.20191205014031.81437.log
Last 10 log lines: num2int.c:64:5: note: to match this '('
sprintf(buf, "%"PRI_LL_PREFIX"u", NUM2ULL(num));
^ /usr/local/include/secure/_stdio.h:47:27: note: expanded from macro 'sprintf' builtin___sprintf_chk (str, 0, __darwin_obsz(str),
__VA_ARGS)
^ 190 warnings and 2 errors generated. make[2]: * [num2int.o] Error 1 make1: * [ext/-test-/num2int/all]
Error 2 make: *** [build-ext] Error 2
Did anyone face this problem before? Any help would be greatly appreciated.
UPDATE
Adding the last few lines in the logfile. Most of them look like errors in C lang
/usr/local/include/stdlib.h:354:36: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
strtouq(const char *__str, char **__endptr, int __base);
^
/usr/local/include/stdlib.h:354:36: note: insert '_Nullable' if the pointer may be null
strtouq(const char *__str, char **__endptr, int __base);
^
_Nullable
/usr/local/include/stdlib.h:354:36: note: insert '_Nonnull' if the pointer should never be null
strtouq(const char *__str, char **__endptr, int __base);
^
_Nonnull
/usr/local/include/stdlib.h:356:13: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
extern char *suboptarg; /* getsubopt(3) external variable */
^
/usr/local/include/stdlib.h:356:13: note: insert '_Nullable' if the pointer may be null
extern char *suboptarg; /* getsubopt(3) external variable */
^
_Nullable
/usr/local/include/stdlib.h:356:13: note: insert '_Nonnull' if the pointer should never be null
extern char *suboptarg; /* getsubopt(3) external variable */
^
_Nonnull
num2int.c:56:21: error: expected ')'
sprintf(buf, "%"PRI_LL_PREFIX"d", NUM2LL(num));
^
num2int.c:56:5: note: to match this '('
sprintf(buf, "%"PRI_LL_PREFIX"d", NUM2LL(num));
^
/usr/local/include/secure/_stdio.h:47:27: note: expanded from macro 'sprintf'
__builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
^
num2int.c:64:21: error: expected ')'
sprintf(buf, "%"PRI_LL_PREFIX"u", NUM2ULL(num));
^
num2int.c:64:5: note: to match this '('
sprintf(buf, "%"PRI_LL_PREFIX"u", NUM2ULL(num));
^
/usr/local/include/secure/_stdio.h:47:27: note: expanded from macro 'sprintf'
__builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
^
190 warnings and 2 errors generated.
make[2]: *** [num2int.o] Error 1
make[1]: *** [ext/-test-/num2int/all] Error 2
make: *** [build-ext] Error 2
Here is the pate bin for the detailed errors:
https://pastebin.com/wzLGzvC5
EDIT:
$ which clang
/usr/bin/clang
$ brew ls
adns gnutls libksba openssl ruby
autoconf icu4c libtasn1 openssl#1.1 ruby-build
automake libassuan libtool p11-kit sqlite
awk libevent libunistring pinentry unbound
coreutils libffi libusb pkg-config zlib
gettext libgcrypt libyaml postgresql
gmp libgpg-error nettle rbenv
gnupg libidn2 npth readline
$ brew doctor
Your system is ready to brew.
After I deleted the files suggested by brew doctor
Few lines from
$ ls -la /usr/local/include
total 0
drwxrwxr-x 270 akashpinnaka admin 8640 Dec 24 11:30 .
drwxr-xr-x 18 root wheel 576 Dec 5 11:15 ..
-rw-r--r-- 1 akashpinnaka admin 0 Dec 5 10:11 .keepme
lrwxr-xr-x 1 root admin 85 Dec 5 11:21 AppleTextureEncoder.h -> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/AppleTextureEncoder.h
lrwxr-xr-x 1 root admin 78 Dec 5 11:21 AssertMacros.h -> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/AssertMacros.h
lrwxr-xr-x 1 root admin 78 Dec 5 11:21 Availability.h -> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/Availability.h
lrwxr-xr-x 1 root admin 86 Dec 5 11:21 AvailabilityInternal.h -> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/AvailabilityInternal.h
lrwxr-xr-x 1 root admin 84 Dec 5 11:21 AvailabilityMacros.h -> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/AvailabilityMacros.h
lrwxr-xr-x 1 root admin 86 Dec 5 11:21 AvailabilityVersions.h -> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/AvailabilityVersions.h
First, let trim your log to the significant part:
num2int.c:56:21: error: expected ')'
sprintf(buf, "%"PRI_LL_PREFIX"d", NUM2LL(num));
^
num2int.c:56:5: note: to match this '('
sprintf(buf, "%"PRI_LL_PREFIX"d", NUM2LL(num));
^
/usr/local/include/secure/_stdio.h:47:27: note: expanded from macro 'sprintf'
__builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
Basically, this says that there was an error while expanding a macro to some line in file num2int.c. So, where is does that macro come from? The log says that the macro was defined in file /usr/local/include/secure/_stdio.h.
This file correspond to a locally installed package, most probably added through brew (it could also have been installed by some application installed with a package installer, but this appears less probable). I have not found yet to which package that file belongs (don't have it on my computer and havn't found any reference to it on Google), but _stdio.h files are rather exceptionnal, so I believe that it might be related to brew's private GCC. Yet, ruby-build (when executed though rb-env install) prefer to use XCode's clang compiler, which might not support some syntax extension supported by brew's GCC.
In short, you end up loading in Apple's clang some local include file that use some syntax thaat is not compatible with that compiler.
What to do now?
You must determine if the /usr/local/include/secure/ directory is actually useful. Maybe, this is related to a program that you no longer use… I can't tell you exactly what to do about this, but here are some ideas:
Check if either secure or secure/_stdio.h is a symlink (i.e.: ls -l /usr/local/include/secure/). If they have been installed by brew, they should point to somewhere under ../Cellar/<package-name>. If there are, maybe you could consider uninstalling that package…
Run brew doctor and check for "Unexpected header files".
Ideally, you want to end up deleting that directory… If you are not certain either it is a good idea, then you may consider moving it temporarilly out of the include directory, for example by doing the following:
mkdir /usr/local/include.disabled
mv /usr/local/include/secure /usr/local/include.disabled/secure
# Compile ruby
mv /usr/local/include.disabled/secure /usr/local/include/secure
rm -rf /usr/local/include.disabled
If none of this works, please post the output of the following commands to a pastebin:
which clang
brew doctor
brew ls
ls -la /usr/local/include
How to move all OSX SDK include files out of local/include
I think the following command should be enough to move all include files pointing to the OSX SDK out of the /usr/local/include directory (my uncertainty here is related to either sub-directories were themselves symlinked, or if it is the content of these subdirectories that is symlinke… I assumed the first, and this oneliner script will miss directories if they are of the second type).
mkdir -p /usr/local/include.disabled/
find /usr/local/include/ -depth 1 -lname '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/*' -exec mv '{}' /usr/local/include.disabled/ ';'
Run these commands, then execute ls -la /usr/local/include again… There should be much less content in it. Do you still have a secure directory there?
And most importanly, can you now get through your original build?
I was facing a similar issue and can recommend the approach below that's related to binutils needing to be uninstalled first. What worked for me:
brew uninstall binutils
# Uninstalling /usr/local/Cellar/binutils/2.33.1... (134 files, 167.6MB)
rbenv install 2.6.5 && rbenv local 2.6.5 ;
# Downloading openssl-1.1.1d.tar.gz...
# -> https://dqw8nmjcqpjn7.cloudfront.net/1e3a91bc1f9dfce01af26026f856e064eab4c8ee0a8f457b5ae30b40b8b711f2
# Installing openssl-1.1.1d...
# Installed openssl-1.1.1d to /Users/auser/.rbenv/versions/2.6.5
# Downloading ruby-2.6.5.tar.bz2...
# -> https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.5.tar.bz2
# Installing ruby-2.6.5...
# ruby-build: using readline from homebrew
# Installed ruby-2.6.5 to /Users/auser/.rbenv/versions/2.6.5
Prior to this the I was also getting a number of varying messages in ruby-build.log - with the last being:
# ld: symbol(s) not found for architecture x86_64
A number of other steps that I took as part of my homebrew stepup (prior to uninstall) included:
brew install perl ruby rbenv
# // UPDATE PATHs with suggestions made by brew during install
which awk perl
# /usr/local/bin/awk
# /usr/local/bin/perl
# ^^^ IN SHORT ALL PATHs should be with /usr/local/opt OR /usr/local/bin
You can re-install binutils again after as needed and remember to repeat the uninstallation with any future rbenv install version(s) that you're likely to re-execute (note to self).
PS - tested on macOS Catalina 10.15.3 (19D76) successfully installing both 2.4.0 & 2.6.5
Can you try to run these commands:
brew unlink gawk
brew reinstall awk
awk
before running rbenv install 2.4.0

Can't activate Lua-support in freeswitch

If activating Lua-Support in modules.conf, ./configure, make , install yields the following error:
*
making install mod_lua
make[4]: Entering directory '/home/jklou/jkl/fs/freeswitch-1.8.2/src/mod/languages/mod_lua'
CXX mod_lua_la-mod_lua.lo
mod_lua.cpp:37:17: fatal error: lua.h: 没有那个文件或目录
compilation terminated.
Makefile:687: recipe for target 'mod_lua_la-mod_lua.lo' failed
make[4]: *** [mod_lua_la-mod_lua.lo] Error 1
make[4]: Leaving directory '/home/jklou/jkl/fs/freeswitch-1.8.2/src/mod/languages/mod_lua'
Makefile:679: recipe for target 'mod_lua-install' failed
make[3]: *** [mod_lua-install] Error 1
make[3]: Leaving directory '/home/jklou/jkl/fs/freeswitch-1.8.2/src/mod'
Makefile:587: recipe for target 'install-recursive' failed
make[2]: *** [install-recursive] Error 1
make[2]: Leaving directory '/home/jklou/jkl/fs/freeswitch-1.8.2/src'
Makefile:3257: recipe for target 'install-recursive' failed
make[1]: *** [install-recursive] Error 1
make[1]: Leaving directory '/home/jklou/jkl/fs/freeswitch-1.8.2'
Makefile:3729: recipe for target 'install' failed
make: *** [install] Error 2
*
so Lua cannot be used.
Google: Several Forums advise to refresh the GIT-repository, but this cannot be used because I need an older Version of freeswitch
I've found a solution:
apt-get install libreadline-dev apt-get install lua5.2 lua5.2-doc liblua5.2-dev
then copy LUA-sh-files to LUA-mod-directory of Freeswitch:
cp /usr/include/lua5.2/*.h [Installationsverzeichnis Freeswitch]]/src/mod/languages/mod_lua/
then link it:
sudo ln -s /usr/lib/x86_64-linux-gnu/liblua5.2.so /usr/lib/x86_64-linux-gnu/liblua.so
then repeat make install (don't repeat ./configure and make)
sudo make install
this worked perfectly for me (Freeswitch 1.8.2. and Ubuntu 18.04 LTS running in Virtual Box)

Mqtt: How to install mosquitto old version

I have installed mosquitto using the command apt-get install mosquitto. It is installed successfully on my system, but I got version "1.4.5". I want to downgrade to version 1.4.4, so I was trying using the source tar file. Under folder, I am running the command make and it is throwing an error:
set -e; for d in lib client src; do make -C ${d}; done
make[1]: Entering directory `/home/ubuntu/org.eclipse.mosquitto-1.4.4/lib'
cc -Wall -ggdb -O2 -I. -I.. -I../lib -fPIC -DWITH_TLS -DWITH_TLS_PSK -DWITH_THREADING -DWITH_SOCKS -DWITH_SRV -c mosquitto.c -o mosquitto.o
In file included from mosquitto.c:33:0:
./mosquitto_internal.h:27:27: fatal error: openssl/ssl.h: No such file or directory
# include <openssl/ssl.h>
^
compilation terminated.
make[1]: *** [mosquitto.o] Error 1
make[1]: Leaving directory `/home/ubuntu/org.eclipse.mosquitto-1.4.4/lib'
make: *** [mosquitto] Error 2
What is going wrong here?. Is there any another way to install 1.4.4 version of mosquitto?
Thanks
You're missing dependencies needed for compilation.
Try:
apt-get install libc-ares-dev libssl-dev libwrap0-dev uthash-dev uuid-dev
If you want libwebsockets support you can either install libwebsockets-dev, or better install it manually from source - that will get you version 1.5 instead of the old 1.2 that is in Debian/Ubuntu.
If you install the manually compiled version with
make prefix=/usr install
then it will overwrite the existing binary and you can use it with the existing system services.

asm/socket.h: No such file or directory cross compiling Dart for Raspberry pi

I'm cross-compiling the Dart runtime using the instruction here.
I've installed all the dependencies as specified. I've also cloned the git repository with the necessary tool chain.
I'm running the runtime compilation with this command:
./tools/build.py -m release -a arm --toolchain=../tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf runtime
The compilation starts with no problem then it stops with this error:
LINK(target) out/ReleaseXARM/libdart_dependency_helper.target
CXX(host) out/ReleaseXARM/obj.host/libdart_lib_withcore/runtime/vm/bootstrap.o
In file included from /usr/include/sys/socket.h:38:0,
from /usr/include/netinet/in.h:23,
from /usr/include/arpa/inet.h:22,
from runtime/platform/globals.h:56,
from runtime/platform/assert.h:16,
from runtime/vm/allocation.h:8,
from runtime/vm/bootstrap.h:9,
from runtime/vm/bootstrap.cc:5:
/usr/include/bits/socket.h:345:24: fatal error: asm/socket.h: No such file or directory
#include <asm/socket.h>
^
compilation terminated.
CXX(host) out/ReleaseXARM/obj.host/libdart_lib_withcore/gen/async_gen.o
In file included from /usr/include/sys/socket.h:38:0,
from /usr/include/netinet/in.h:23,
from /usr/include/arpa/inet.h:22,
from runtime/platform/globals.h:56,
from runtime/platform/assert.h:16,
from runtime/vm/allocation.h:8,
from runtime/vm/bootstrap.h:9,
from out/ReleaseXARM/obj/gen/async_gen.cc:5:
/usr/include/bits/socket.h:345:24: fatal error: asm/socket.h: No such file or directory
#include <asm/socket.h>
^
compilation terminated.
runtime/libdart_lib_withcore.host.mk:978: recipe for target 'out/ReleaseXARM/obj.host/libdart_lib_withcore/runtime/vm/bootstrap.o' failed
make: *** [out/ReleaseXARM/obj.host/libdart_lib_withcore/runtime/vm/bootstrap.o] Error 1
make: *** Waiting for unfinished jobs....
runtime/libdart_lib_withcore.host.mk:986: recipe for target 'out/ReleaseXARM/obj.host/libdart_lib_withcore/gen/async_gen.o' failed
make: *** [out/ReleaseXARM/obj.host/libdart_lib_withcore/gen/async_gen.o] Error 1
BUILD FAILED
Am I missing any dependency or package?
I hit the same problem. On my ubuntu 14.04 system /usr/include/asm didn't exist. It was called asm-generic instead. I sym-linked it and the build was able to continue.
cd /usr/include
sudo ln -s asm-generic/ asm
The build was able to continue after that.
This is probably because you're trying to build an application without some of the include paths correctly set, for example using a 32-bit gcc on a 64-bit platform.
To resolve:
sudo apt-get install gcc-multilib
I'm not sure why this happens, but sometimes /usr/include/asm gets deleted. My teammates who looked at their Ubuntu x86-64 workstations found that the asm symlink was:
0 lrwxrwxrwx 1 root root 20 May 22 2013 /usr/include/asm -> x86_64-linux-gnu/asm
And the command to recreate it is:
$ cd /usr/include
$ sudo ln -s x86_64-linux-gnu/asm asm
The files in /usr/include/asm-generic are sometimes, but not always, equivalent to the files in the x86-64 specific directory; so it's difficult to recommend symlinking it as a workaround.

Resources