For some reason I can't get ruby 2.3.0 installed via RBENV. I got it to work with RVM though. Let me know if I need to provide further information.
Here's the error I get:
Downloading ruby-2.3.0.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.0.tar.bz2
Installing ruby-2.3.0...
BUILD FAILED (OS X 10.10.5 using ruby-build 20160426)
Inspect or clean up the working tree at /tmp/ruby-build.20160426211028.6622
Results logged to /tmp/ruby-build.20160426211028.6622.log
Last 10 log lines:
config.guess already exists
config.sub already exists
checking build system type... x86_64-apple-darwin14.5.0
checking host system type... x86_64-apple-darwin14.5.0
checking target system type... x86_64-apple-darwin14.5.0
checking whether the C compiler works... no
configure: error: in `/tmp/ruby-build.20160426211028.6622/ruby-2.3.0':
configure: error: C compiler cannot create executables
See `config.log' for more details
make: *** No targets specified and no makefile found. Stop.
your system has too strict security policy, so add sudo for the rbenv to give the ability to add executions. So you will like something like:
sudo rbenv install 2.3.0
Related
I'm installing the pg gem on mac osx 12.5 on an M1 macbook pro. Ruby bundler can't find libpq when running gem install pg:
current directory: /Users/me/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/pg-1.4.4/ext
/Users/me/.rbenv/versions/3.1.2/bin/ruby -I /Users/me/.rbenv/versions/3.1.2/lib/ruby/site_ruby/3.1.0 extconf.rb
Calling libpq with GVL unlocked
checking for pg_config... yes
Using config values from /opt/homebrew/opt/libpq/bin/pg_config
checking for whether -Wl,-rpath,/opt/homebrew/opt/libpq/lib is accepted as LDFLAGS... yes
Using libpq from /opt/homebrew/opt/libpq/lib
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*****************************************************************************
Unable to find PostgreSQL client library.
Please install libpq or postgresql client package like so:
brew install libpq
or try again with:
gem install pg -- --with-pg-config=/path/to/pg_config
or set library paths manually with:
gem install pg -- --with-pg-include=/path/to/libpq-fe.h/ --with-pg-lib=/path/to/libpq.so/
...
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/me/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/extensions/x86_64-darwin-21/3.1.0/pg-1.4.4/mkmf.log
Here's what the mkmf.log shows:
conftest.c:16:13: error: conflicting types for 'PQconnectdb'
extern void PQconnectdb();
^
/opt/homebrew/include/postgresql#14/libpq-fe.h:285:16: note: previous declaration is here
extern PGconn *PQconnectdb(const char *conninfo);
^
conftest.c:17:27: error: too few arguments to function call, single argument 'conninfo' was not specified
int t(void) { PQconnectdb(); return 0; }
~~~~~~~~~~~ ^
/opt/homebrew/include/postgresql#14/libpq-fe.h:285:16: note: 'PQconnectdb' declared here
extern PGconn *PQconnectdb(const char *conninfo);
I've installed libpq using homebrew as suggested:
Warning: libpq 15.1 is already installed and up-to-date.
Interestingly, I also tried gem install pg -- --with-pg-include=/opt/homebrew/opt/libpq/include/libpq-fe.h/ but I couldn't find libpq.so poking around the homebrew install.
Any suggestions? Is it possible homebrew's installation of libpq leaves off a needed .so file? Is it suspect that the log file is under a x86_64-darwin-21 directory when I'm running on an M1 mac? Is error: conflicting types for 'PQconnectdb' a hint that I have an incompatible version of libpq with the pg gem?
The pg gem uses pg_config to configure itself. If the gem finds the wrong version of pg_config, it will misconfigure, resulting in the error you mentioned.
On ARM Macs, Homebrew installs itself to a different location (/opt/homebrew) than it did on Intel Macs (/usr/local). However, if you used Apple's Migration Assistant, it's possible to end up with both Homebrew instances, which can confuse things when compiling gems.
First, make sure your Ruby is arm64:
$ ruby -v
ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [arm64-darwin22]
It should show arm64 there near the end.
Next, see where pg_config is coming from:
$ which pg_config
/usr/local/bin/pg_config <- Intel version
/opt/homebrew/bin/pg_config <- ARM version
It'll show one of these two (or nothing). We're looking for the second line (ARM).
If nothing, then postgresql is probably not installed (or not found).
If it shows the first, then compilation is finding an Intel copy of pg_config. This was my case, after migrating from an Intel to ARM Mac.
This confusion is partly made possible because pg_config comes from the postgresql package, not libpq. So, you'll need the arm64 version of postgresql installed too.
If you install the unversioned (ie: latest) postgresql, this is hopefully all you need:
$ brew install postgresql
If you always install a specific version (as I do), then you'll also need to 'link' so that pg_config is properly made available.
$ brew install postgresql#15
$ brew link postgresql#15
Using the link command is usually safe as long as this is the only version of postgresql you have installed (within the ARM copy of Homebrew).
Hint 1: When upgrading versions of Postgres in the future, you may need to unlink the old before linking the new.
Hint 2: If you have an Intel version of Postgres still running from the old copy of Homebrew, there is a possibility you'll have to migrate your data between the two or sort out some other conflict. That's out of scope here, so just a heads up.
At this point you will hopefully see the proper pg_config:
$ which pg_config
/opt/homebrew/bin/pg_config <- ARM version
If not, also check your PATH as set by your shell. It's important that /opt/homebrew/bin is before /usr/local/bin.
$ echo $PATH
Fixing it depends on your choice of shell, so I'll skip that here.
That should hopefully do it.
Note that I didn't use --with-pg-config. While using that might allow skipping a step or two above, getting pg_config detecting properly also helps improve odds that other gems will compile properly in the future and not need ongoing workarounds.
I'm trying to update ma ruby version.
I'm with ruby 1.8.7 and I would like to install 2.1.0.
I just installed rvm, rbenv, brew and gem.
But when I try to do
$ rbenv install 2.1.0.
I get an error about clang. I don't get the point between clang and ruby
Could you please help me?
Error:
$ rbenv install 2.1.0
Downloading ruby-2.1.0.tar.gz...
Installing ruby-2.1.0...
BUILD FAILED
...
Last 10 log lines:
...
checking build system type... x86_64-apple-darwin12.3.0
checking host system type... x86_64-apple-darwin12.3.0
checking target system type... x86_64-apple-darwin12.3.0
checking for gcc-4.2... no
checking for clang... no
checking for gcc... no
checking for cc... no
./configure: line 3390: -E: command not found
configure: error: clang version 3.0 or later is required
You need to install the Developer Tools command-line tools in order to build Ruby. As one option, you can install Xcode from the App Store, and Xcode will let you install the command line tools if they aren't automatically installed with your version.
You can install developer command line tools without installing Xcode. Just type the following in the terminal:
xcode-select --install
I am trying to install Ruby on rails on my Mac for the first time.
I ran the following command on my terminal windows -
rvm install 2.0.0
But I keep getting this error.
Error running './configure --prefix=/Users/tusharmathur/.rvm/rubies/ruby-2.0.0-p0 --with-opt-dir=/usr/local/opt/libyaml:/usr/local/opt/readline:/usr/local/opt/libxml2:/usr/local/opt/libxslt:/usr/local/opt/libksba:/usr/local/opt/openssl:/usr/local/opt/sqlite --disable-install-doc --without-tcl --without-tk --enable-shared',
please read /Users/tusharmathur/.rvm/log/ruby-2.0.0-p0/configure.log
There has been an error while running configure. Halting the installation.
I saw the configure.log also, here is the information -
[2013-03-15 01:11:06] ./configure
configure: WARNING: unrecognized options: --without-tcl, --without-tk
checking build system type... i386-apple-darwin12.2.1
checking host system type... i386-apple-darwin12.2.1
checking target system type... i386-apple-darwin12.2.1
checking whether the C compiler works... no
configure: error: in `/Users/tusharmathur/.rvm/src/ruby-2.0.0-p0':
configure: error: C compiler cannot create executables
See `config.log' for more details
Here are some screenshots how to install command line tools for XCode (you can install XCode from Mac AppStore):
http://d.pr/i/YJJp
http://d.pr/i/ntLu
http://d.pr/i/cOFv
After installing command line tools you will have a C/C++ compiler on your machine.
I'm new to Terminal so please bear with me. Completed installing the following successfully (in this particular order):
xCode 4.5
RVM 1.16
GCC 4.2.1
Ruby 1.9.3
When trying to install Rails ("gem install rails") the installation starts but is then interrupted with an error: "Failed to build gem native extension". No idea what this refers to. Ideas? Something else I need to install beforehand?
On my first attempt to install Rails I accidentally ran it with sudo. Will this affect anything?
Edit: And the output -
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/Users/staffanestberg/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
creating Makefile
make
compiling generator.c
make: /usr/bin/gcc-4.2: No such file or directory
make: *** [generator.o] Error 1
Gem files will remain installed in /Users/staffanestberg/.rvm/gems/ruby-1.9.3-p194/gems/json-1.7.5 for inspection.
Results logged to /Users/staffanestberg/.rvm/gems/ruby-1.9.3-p194/gems/json-1.7.5/ext/json/ext/generator/gem_make.out
Edit: Solved using iouri's suggestion. Add export CC=gcc in .bash-profile then create a symlink for the correct compiler,
sudo ln -sf /usr/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2
Make sure you have command line tools for Xcode installed first, Xcode > Preferences > Downloads > Components. Then add this line to your .bash_profile file in your home folder ~/.bash_profile:
export CC=gcc
Double check that you have gcc (probably a symlink) in your /usr/bin (most likely), and that it is pointing to a valid gcc compiler, ex: gcc -> llvm-gcc-4.2
You might have to restart your terminal for this change to take affect.
Ruby is not fully ready for LLVM compilation, this includes clang, there is at least one known isue with Fibers, but depending on LLVM version other problems might appear.
The right way to fix it is to get gcc-4.2 there are many ways for it and the best ones are described in requirements:
rvm get stable
rvm reload
rvm requirements run
rvm reinstall 1.9.3
If I type xcodebuild -version it recognises that I have xcode installed:
Xcode 4.3.2
Build version 4E2002
But then when I try to check rvm requirements I get the following:
Notes for Mac OS X 10.7.3, No Xcode.
For JRuby: Install the JDK. See http://developer.apple.com/java/download/ # Current Java version "1.6.0_26"
For IronRuby: Install Mono >= 2.6
For Ruby 1.9.3: Install libksba # If using Homebrew, 'brew install libksba'
You can use & download osx-gcc-installer: https://github.com/kennethreitz/osx-gcc- installer
** NOTE: Currently, Node.js is having issues building with osx-gcc-installer. The only fix is to install Xcode over osx-gcc-installer.
We had reports of http://hpc.sourceforge.net/ making things work, but it looks like not easiest/safest to setup.
To use an RVM installed Ruby as default, instead of the system ruby:
rvm install 1.8.7 # installs patch 357: closest supported version
rvm system ; rvm gemset export system.gems ; rvm 1.8.7 ; rvm gemset import system.gems # migrate your gems
rvm alias create default 1.8.7
And reopen your terminal windows.
Xcode 4.2:
* is only supported by ruby 1.9.3+ using command line flag: --with-gcc=clang
* it breaks gems with native extensions, especially DB drivers.
It seems that it is not recognising my xcode and when I try to install rvm 1.9.3 I get:
Fetching yaml-0.1.4.tar.gz to /Users/sikandarshukla/.rvm/archives
Extracting yaml-0.1.4.tar.gz to /Users/sikandarshukla/.rvm/src
Configuring yaml in /Users/sikandarshukla/.rvm/src/yaml-0.1.4.
Error running ' ./configure --prefix="/Users/sikandarshukla/.rvm/usr" ', please read /Users/sikandarshukla/.rvm/log/ruby-1.9.3-p125/yaml/configure.log
Compiling yaml in /Users/sikandarshukla/.rvm/src/yaml-0.1.4.
Error running 'make ', please read /Users/sikandarshukla/.rvm/log/ruby-1.9.3- p125/yaml/make.log
Database file /Users/sikandarshukla/.rvm/config/packages does not exist.
/Users/sikandarshukla/.rvm/scripts/functions/build: line 28: --version: command not found
Installing Ruby from source to: /Users/sikandarshukla/.rvm/rubies/ruby-1.9.3-p125, this may take a while depending on your cpu(s)...
ruby-1.9.3-p125 - #fetching
ruby-1.9.3-p125 - #extracted to /Users/sikandarshukla/.rvm/src/ruby-1.9.3-p125 (already extracted)
ruby-1.9.3-p125 - #configuring
Error running ' ./configure --prefix=/Users/sikandarshukla/.rvm/rubies/ruby-1.9.3-p125 -- enable-shared --disable-install-doc --with-libyaml --with-opt- dir=/Users/sikandarshukla/.rvm/usr ', please read /Users/sikandarshukla/.rvm/log/ruby-1.9.3- p125/configure.log
There has been an error while running configure. Halting the installation.
Now if i read the log, the output of cat /Users/sikandarshukla/.rvm/log/ruby-1.9.3-p125/configure.log is the following:
./configure --prefix=/Users/sikandarshukla/.rvm/rubies/ruby-1.9.3-p125 --enable-shared -- disable-install-doc --with-libyaml --with-opt-dir=/Users/sikandarshukla/.rvm/usr
configure: WARNING: unrecognized options: --with-libyaml
checking build system type... i386-apple-darwin11.3.0
checking host system type... i386-apple-darwin11.3.0
checking target system type... i386-apple-darwin11.3.0
checking whether the C compiler works... no
configure: error: in `/Users/sikandarshukla/.rvm/src/ruby-1.9.3-p125':
configure: error: C compiler cannot create executables
See `config.log' for more details
and the output of cat /Users/sikandarshukla/.rvm/log/ruby-1.9.3-p125/yaml/configure.log is the following:
./configure --prefix="/Users/sikandarshukla/.rvm/usr"
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... config/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/Users/sikandarshukla/.rvm/src/yaml-0.1.4':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
Any ideas what to do, Thanks for your help
It's a bug in recognizing Xcode version, I have created a ticket and it should be solved shortly -> https://github.com/wayneeseguin/rvm/issues/846
All Xcode 4.2+ have the same issue:
4.2:
is only supported by ruby 1.9.3+ using command line flag: --with-gcc=clang
it breaks gems with native extensions, especially DB drivers.
To solve use osx-gcc-installer:
You can use & download osx-gcc-installer: https://github.com/kennethreitz/osx-gcc-installer