I am trying to install Ruby on my mac and that too the latest version but having trouble.
The pre-installed ruby on mac is of verion 2.0 however, I need to upgrade the same to latest.
I tried installing ruby with Homebrew like brew install ruby but whenever i check the version, it shows me the earlier version only. Refer Terminal screenshot:
Am trying to learn ruby but this thing got me stuck for long.
Have also tried another package manager rbenv and did rbenv install 2.5.1 but that failed with the following error I have no idea about
The Ruby zlib extension was not compiled.
ERROR: Ruby install aborted due to missing extensions
Configure options used:
--prefix=/Users/vshukla/.rbenv/versions/2.5.1
--with-openssl-dir=/usr/local/opt/openssl
CC=clang
CFLAGS= -O3 -Wno-error=shorten-64-to-32
LDFLAGS=-L/Users/vshukla/.rbenv/versions/2.5.1/lib
CPPFLAGS=-I/Users/vshukla/.rbenv/versions/2.5.1/include
Please guide.
Homebrew has correctly installed the last version of ruby in /usr/local/bin. You can check it with:
/usr/local/bin/ruby --version
The macOS version of ruby is installed in /usr/bin. You can check it with:
/usr/bin/ruby --version
If you want to always run the Homebrew versions of installed tools, you have to put /use/local/bin before /usr/bin in your PATH environment variable. You can do this by adding the following line in your ~/.bash_profile:
export PATH="/usr/local/bin:$PATH"
P.S.: According to your macos ruby version, you don't have the last macOS version.
The compile error log contains:
The Ruby zlib extension was not compiled.
ERROR: Ruby install aborted due to missing extensions
Try installing "zlib" and then try again, by running:
brew install zlib
Related
When I run
RUBY_CONFIGURE_OPTS=--with-openssl-dir=/usr/local/Cellar/openssl#3/3.0.1 rbenv install 3.1.0
I get this output:
Downloading ruby-3.1.0.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.0.tar.gz
Installing ruby-3.1.0...
ruby-build: using readline from homebrew
BUILD FAILED (macOS 11.6.2 using ruby-build 20211227-3-gcdc215e)
Inspect or clean up the working tree at /var/folders/ts/k_8jb10136s3zw9k2k08nz3c0000gn/T/ruby-build.20220113093111.65052.FVpqjp
Results logged to /var/folders/ts/k_8jb10136s3zw9k2k08nz3c0000gn/T/ruby-build.20220113093111.65052.log
Last 10 log lines:
The Ruby openssl extension was not compiled.
ERROR: Ruby install aborted due to missing extensions
Configure options used:
--prefix=/Users/jeremy/.rbenv/versions/3.1.0
--enable-shared
--with-readline-dir=/usr/local/opt/readline
--with-openssl-dir=/usr/local/Cellar/openssl#3/3.0.1
CC=clang
LDFLAGS=-L/Users/jeremy/.rbenv/versions/3.1.0/lib
CPPFLAGS=-I/Users/jeremy/.rbenv/versions/3.1.0/include
I don't see any clues in the logs. I have tried lots of things like reinstalling rbenv and openssl, not specifying the configure opts, system updates, installing xcode, and more things from google. Maybe I am missing something.
Hi I also kept running into this on 'Mac OS X 10.15.7 using ruby-build' I had to set both of the following variables at the same time before the rbenv install 3.0.1 command:
OPENSSL_CFLAGS=-Wno-error=implicit-function-declaration RUBY_CONFIGURE_OPTS=--with-readline-dir="$(brew --prefix readline)" rbenv install 3.0.1
The first one tells the compiler to ignore where functions are implicitly declared rather than erroring out when this happens. And the second tells ruby which readline to use (in this case the one installed trough homebrew).
Ruby does not (yet) support OpenSSL 3.0. Implementing support for this newer version is tracked in https://github.com/ruby/openssl/issues/369
For now, you have to use Openssl 1.1 instead, which you can install with
brew install openssl#1.1
I was trying run gem install json and got the following error
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling generator.c
linking shared-object json/ext/generator.bundle
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [generator.bundle] Error 1
make failed, exit code 2
Gem files will remain installed in /opt/boxen/repo/.bundle/ruby/2.0.0/gems/json-1.8.0 for inspection.
Results logged to /opt/boxen/repo/.bundle/ruby/2.0.0/extensions/universal-darwin-13/2.0.0/json-1.8.0/gem_make.out
I'm using:
Os X: 10.9.2
Xcode: 5.1 Build version 5B130a
Command Line Tools (CLT): 5.1.0.0.1.1393561416
Ruby: ruby 2.0.0p247 (2013-06-27 revision 41674) [universal.x86_64-darwin13]
Ruby Gem: 2.2.2
GCC: 4.2.1 Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
I am encountering the exact same problem after updating Xcode to 5.1 and news from Apple aren't good. From Xcode 5.1 Release Notes:
The Apple LLVM compiler in Xcode 5.1 treats unrecognized command-line options as errors. This issue has been seen when building both Python native extensions and Ruby Gems, where some invalid compiler options are currently specified.
Projects using invalid compiler options will need to be changed to remove those options. To help ease that transition, the compiler will temporarily accept an option to downgrade the error to a warning:
-Wno-error=unused-command-line-argument-hard-error-in-future
To workaround this issue, set the ARCHFLAGS environment variable to downgrade the error to a warning.
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install GemName
It seems that all gems violating the compiler options must be updated to use valid options. It is explicitly stated that: This option [downgrading error to warning] will not be supported in the future.
The clang note we are seeing (this will be a hard error (cannot be downgraded to a warning) in the future) corresponds to the change announced in the release notes.
To answer your question specifically, use the following to install the json gem:
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install json
Note, however, that this is only a temporary fix.
One-liner to fix that
curl https://gist.githubusercontent.com/Paulche/9713531/raw/1e57fbb440d36ca5607d1739cc6151f373b234b6/gistfile1.txt | sudo patch /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/universal-darwin13/rbconfig.rb
To address the issue you can install the most recent version of ruby as described by #Sash. You can use the following commands to do so. In case you already have installed rvm, you don't need to reinstall it.
#Install rvm
\curl -sSL https://get.rvm.io | bash -s stable
#Install ruby version 2.0.0-p451
rvm install ruby-2.0.0-p451
#Print ruby version to verify that it was installed successfully
ruby -v
#Install json gem
sudo gem install json
Issue already addressed by Ruby:
https://bugs.ruby-lang.org/issues/9624
now we just need to wait for Apple to update their ruby version (2.0.0p247) to the one after the latest one (2.0.0p451) which hasn't come out yet ...
(or brew/macport it)
Update (2014-05-15): Mavericks 10.9.3 updates ruby to
ruby 2.0.0p451 (2014-02-24 revision 45167) [universal.x86_64-darwin13]
And this seems to resolves the issue.
#Muncken has already provided an answer to install gem one by one:
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install GemName
Base on Muncken's answer, I've tried that it also works when using bundle install
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future bundle install
In my case, I actually have similar problem, but not on the system ruby, but on rubies installed by rvm from OSX 10.8, and it has issues after upgrading to OSX 10.9.
A simple reinstall works: rvm reinstall ruby-2.1.1
On OSX 10.10, I had several issues when running rails new firstapp such as:
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
fatal error: 'ruby/config.h' file not found
I updated rvm with this configuration and all the errors are gone!:
rvm get stable --auto-dotfiles
You can tell from the app name that I just started fiddling with Ruby on Rails, so the above advice may or may not work for you.
Paul Chechetin's one-liner doesn't appear to work anymore (9/21/15). However, this reply to the post mentioned in Pete's reply solved the problem for me:
(a) Install Apple's XCode, then (b) launch it and accept the licensing terms (I had done (a), but not (b).)
sudo gem uninstall compass
sudo gem install compass
None of these worked for me.
What finally worked is running the command with a sudo -
gem install byebug -v '9.0.6'
It's been a while and I've got similar error. An alternative to folks using bundler is to add the flag to the build configuration like below example:
bundle config build.<gemname> --with-cflags="-Wno-error=implicit-function-declaration"
followed by
bundle install
Please note that you must replace <gemname> above with the name of the actual gem that is throwing the error while building native extensions.
I hope this becomes helpful to others that face similar issues in the future!
I used a simple solution... install through brew
brew install name
Yes, I know there's some questions posted regarding issues of installing Ruby 1.9.3 on Lion, mainly because of problems with later versions of Xcode (4.3.2 in my case).
However, I've tried all there is to try that's posted here on Stack regarding this manner, and nothing helps. It starts to compile, one minute or two passes and then suddenly halts.
As examples I've tried with the following (of course I have GCC installer installed):
rvm install 1.9.3
rvm install 1.9.3 --with-gcc=clang
rvm install 1.9.3 --with-gcc=gcc-4.2
If running rvm install 1.9.3 the following error shows during the compilation (which halts the installation):
Error running 'make', please read /Users/henrikpetersson81/.rvm/log/ruby-1.9.3-p374/make.log
There has been an error while running make. Halting the installation.
Here you can read the log file from the latest build fail:
http://jsfiddle.net/hyhrk/
Last thing I've tried was to follow the updated guide in this answer. Same problem.
What can be the problem here?
NOTE. I've the following installed:
Ruby 1.8.7
Homebrew 0.7.1
RVM 1.17.10
GCC installer 4.2.1
Xcode 4.3.2
Command Line Tools
RVM has an updated command to install all required libraries:
rvm get head
rvm requirements run
It might ask you for your password (for sudo).
After that run:
rvm install 1.9.3 --with-opt-dir=`brew --prefix readline` --without-tcl --without-tk
Update RVM 1.19+
RVM takes care of it all:
rvm get stable
rvm autolibs homebrew
rvm install 1.9.3
It looks like there are issues with readline. Since you're using Homebrew, you can try this:
brew install readline
rvm install 1.9.3 --with-readline=`brew --prefix readline`
I'm having a lot of trouble getting Ruby 1.8.7 installed on my clean install of Mountain Lion. I've looked around on Stack Overflow and don't see anything that specifically addresses this issue and hope that someone might have encountered this before.
I'm using the command line tools that can be downloaded with Xcode
I haven't had any problems installing Ruby 1.9.3 via RVM and HomeBrew. When I try to install 1.8.7 I get the following message after it tries to compile:
I first ran the command
rvm install 1.8.7
This gave me this error
The provided compiler '/usr/bin/gcc' is LLVM based, it is not yet fully supported by ruby and gems, please read `rvm requirements`.
After digging around a bit I tried
rvm install 1.8.7 --with-gcc=clang
Error running 'make ', please read /Users/paulzaich/.rvm/log/ruby-1.8.7-p370/make.log
There has been an error while running make. Halting the installation.
Ruby 'ruby-1.8.7-p370' was built using clang - but it's not (fully) supported, expect errors.
Please be aware that you just installed a ruby that requires 2 patches just to be compiled on up to date linux system.
This may have known and unaccounted for security vulnerabilities.
Please consider upgrading to Ruby 1.9.3-194 which will have all of the latest security patches.
At this point I did some more searching and found something about needing compile my own readline. RVM Does Not Install Ruby 1.9.2 on Snow Leopard: 'Error running 'make '
This unfortunately seemed to corrupt my entire rvm install including 1.9.3. I tried to reinstall 1.9.3 and got the same errors I as I was getting with 1.8.7. I completely deleted RVM at this point and reinstalled. Had no problem installing 1.9.3 again.
I also tried updating all versions of rvm based off of this post RVM issue with Mountain Lion. No luck there either.
Update: I also tried using this walkthrough for REE 1.8.7 which recommended installing gcc-4.2. No luck unfortunately.
Update 2: I reference rvm requirements and installed the following packages
brew update
brew tap homebrew/dupes
brew install autoconf automake apple-gcc42
rvm pkg install openssl
So far so good. Then I referenced this post on needing to reference the GCC compiler. I determined that the links referenced might not be correct because I'm using homebrew? I found the compiler in my Cellar folder and used the following command
CC=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 rvm install 1.8.7
No luck. Same error messages as before.
I just figured it out! Please reference this question on SO
rvm can no longer install 1.8.7-p352 on Mac OS X Mountain Lion
rvm reinstall 1.8.7 --without-tcl --without-tk
Alternatively, try this installation order if you have Homebrew.
brew install tcl-tk
rvm reinstall 1.8.7
Just to follow up to Paul's post. I'm running OSX 10.8.2, had 1.9.3 install without issues, but 1.8.7-p370 also failed. I symlinked gcc-4.2:
sudo ln -s /usr/local/bin/gcc-4.2 /usr/bin/gcc-4.2
...successfully ran:
brew install tcl
...but tk failed:
brewk install tk
If you're in the same spot, this command did the trick:
CC=/usr/local/bin/gcc-4.2 rvm reinstall 1.8.7 --without-tk
Latest Xcode provides only clang - not GNU gcc, you need to install gcc-4.2 to be able to compile Ruby 1.8.7 properly, following command will show available options:
rvm requirements
currently only ruby 1.9.3-p125 and later has limited support for clang, but this is limited support, and still errors can be found.
I am on ubuntu 11.10 and have had vim-gnome installed and working. Using vundle and have installed seeral packages all working.
I have installed command-t but it will not function until C extensions are compiled. Reading the manual this is the solution.
rake make
For me the location is actually:
~/.vim/bundle/command-t
Anyway so I turned rvm off and installed the system 1.8 as advised in the command-t help guide.
I checked the documentation and the most common cause of command-t errors is compiling against the wrong ruby.
So I found this command to check the compiled version.
renshaw#renshaw-TravelMate-5740G:~/.vim/bundle/command-t$ ldd `which vim` | grep ruby
libruby1.8.so.1.8 => /usr/lib/libruby1.8.so.1.8 (0x00007f913932c000)
So I installed rake for the ruby 1.8 and compiled with rake make
renshaw#renshaw-TravelMate-5740G:~/.vim/bundle/command-t$ sudo rake make
/usr/bin/ruby1.8 extconf.rb
checking for ruby.h... yes
and off it goes and compiles.
however start gvim and run \t for command-t and
Vim: Caught deadly signal SEGV
Vim: Finished.
Segmentation fault
How can I get command-t going on ubuntu 11.10?
Update.
Built Gvim from sources using
hg clone https://vim.googlecode.com/hg/ vim
cd vim
sudo ./configure --enable-rubyinterp=yes --enable-pythoninterp=yes --enable-gui=gtk2
make
make install
vim --version | grep ruby
The vim version command returns correct that ruby support is built against my installed system 1.8 but it still SEGV when using command T.
So found and tried this
cd ~/.vim/ruby/command-t
/usr/bin/ruby extconf.rb
make
This failed as well.
I then add this to bashrc from a previous support ticket.
vim() {
(unset GEM_PATH GEM_HOME; command vim "$#")
}
I had similar problems when using the rake task. I solved it by compiling the extension myself.
From the command-t plugin directory:
rvm use system
cd ruby/command-t
ruby extconf.rb
make
sudo make install
Ubuntu 13.04 has the very same issue. After trying different combinations, here is what worked for me.
I don't like building from the source, so I used vim-nox package:
sudo apt-get install vim-nox
Now, when compiling command-t with Ruby 1.8.7 or Ruby 2.0.0 SEGV signals were caught. In order to experiment with different Ruby versions, I installed rvm:
curl -L https://get.rvm.io | bash
Then I used Ruby 1.9.1 to compile the command-t extension:
rvm install 1.9.1
rvm use 1.9.1
cd ~/.vim/bundle/command-t/ruby/command-t
ruby extconf.rb
make
To sum up: vim-nox + ruby 1.9.1 = vim command-t works well on Ubuntu 13.04.
I got it to work on Ubuntu 11.10 following these instructions and building Vim and Command-T with Ruby 1.9.2p290 -
sudo apt-get install python-dev ruby-dev mercurial ncurses-dev liblua5.1-0-dev lua5.1
rvm use 1.9.2
hg clone https://vim.googlecode.com/hg/ ~/vim
cd ~/vim
hg update -C v7-3-154
./configure --with-features=huge --disable-largefile \
--enable-perlinterp --enable-pythoninterp \
--enable-rubyinterp --enable-gui=gtk2 \
make
sudo make install
And then following the Command-T installation instructions for Pathogen, in my case.
This is how I fixed this problem (I believe it's caused by version missmatch):
I had an old version of vim installed (from apt using debian). The old version of vim was using old 1.9.x version of Ruby libraries. I compiled command-t according to the guide in https://github.com/wincent/Command-T. I used ruby 2.1.x during the compilation process. I got SEGV when i did t. I believe it was caused by the version missmatch between the Ruby I used when I compiled command-t and the Ruby vim is using. So the fix was to compile vim against the same Ruby libs that command-t was compiled against. When I upgraded my vim using "apt-get install vim" everything started to work. Now the new version of vim is using the same new Ruby libraries that come with the package manager.