Whenever I run
sudo gem install rails
I get the following output:
ERROR: Loading command: install (LoadError)
cannot load such file -- openssl
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass
RVM version: rvm 1.18.14
and Ruby is 2.0.0p0
you need to reinstall your rubies:
rvm get head --autolibs=3
rvm pkg remove
rvm reinstall all --force
the new autolibs supporrt will take care of updating dependencies and including them in ruby
Do you have Homebrew installed on your system? If so, try
brew install openssl
in the command line.
hmm, you have rvm but why you need sudo?I thought rvm is in sandbox mode . Anyway, the error just means it can't find ssl path. First, make sure you have openssl installed. If not then you need to install it(brew, macport etc) or rvm pkg install openssl and let rvm manage its path(you have rvm already). After that, you will need to reinstall ruby. RVM guide is here
You don't use sudo. sudo is ONLY used for doing a multi-user install, and only then during the initial installation, and adding your user to the rvm group (if the installer did not do it for you which usually indicates you did the install wrong in the first place)
I figured it out!
So First I removed everything to do with RVM as suggested in some of the answers. Rebooted. Installed the latest Version of Xcode and the command line tools from Xcode (Xcode-prefereces-downloads). Then rebooted again, and finally used RailsInstaller. Once I used that rails was back on and all is good in the world. Thanks for the help everyone.
Related
I'm very new to RoR specially on Mac. I have installed it many times on Ubuntu with RVM and I'm very comfortable with that. Here is what happened on Mac:
I went through instructions as explained here http://goo.gl/zsHcCC then when I got to the point to install Rails with " gem install rails " I got this error:
Error installing rails:
ERROR: Failed to build gem native extension.
Now I want to roll-back everything and uninstall rbenv and it's ruby versions and reinstall the Ruby On Rails environment using RVM.
I tried to find how to uninstall Homebrew, RBENV and Ruby, but no success.
Thank you.
Sia
Homebrew or Rbenv are very good tools to have as a dev, I would think twice before removing either.
In this case I doubt they are at fault.
Can you confirm you have installed the GCC command line utils for OSX by running $ xcode-select --install in your terminal.
Here is a useful post explaining that process but I find that command generally works fine for me.
If this succeeds what does your $ gem install rails output next?
If you are very new you and you don't need specially the last version of Ruby. You can use Rails Installer http://railsinstaller.org/fr-FR.
To uninstall brew https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/FAQ.md
So I'm following this guide at http://railsapps.github.io/installrubyonrails-ubuntu.html
and I install RVM without a hitch. However, when I check for the version of ruby that I installed via:
ruby -v
I got the following:
The program 'ruby' can be found in the following packages:
* ruby1.8
* ruby1.9.1
Try: sudo apt-get install <selected package>
I tried to install ruby manually through RVM:
rvm install ruby
However, it merely told me that ruby had already been installed.
Has anyone encountered this same issue?
TIA
you can try with these urls these may help you for installing rvm and ruby installation and rails installation
https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm
This may help you
After installing rvm, if you installed it as root, try
source /etc/profile.d/rvm.sh
If you installed as user, try
source ~/.rvm/scripts/rvm
I've definitely been there. I created a script to help me install ruby on remote machines. This was made for new EC2 instances, but maybe it will work.
https://github.com/jubrad/install_ruby
If you do want to use it you'll likely have to remove rvm and your rubies first.
-https://rvm.io/rubies/removing
-sudo apt-get remove rvm
best of luck.
In OS X in rvm how do I check if openssl is configured properly?
I get the cannot load such file -- openssl (LoadError)
And I have tried everything in Rails 3 - no such file to load -- openssl with no success.
Check what rubies are installed:
rvm list
Then make sure to use one of the installed rubies:
rvm use 1.9.3-p327
And test if openssl is available:
ruby -ropenssl -e "puts :OK"
It will print OK if openssl is enabled, otherwise you will get exception
In case of exception =>
UPDATE:
new version of rvm has improved automation support:
rvm get stable
rvm autolibs enable
rvm reinstall all --force
OLD:
run:
rvm requirements run force
rvm pkg remove
Followed by:
rvm reinstall all --force
This instruction is not OSX specific, it will work on all platforms, although on OSX it will work best with HomeBrew, when it's not installed only list of required software will be shown and you need to install it manually.
Many years later, the solution is changed because of brew upgrading, this works now:
# pull full brew git repo
git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core" fetch --unshallow
# generate new brew tap repo
brew tap-new $USER/old-openssl
# extract openssl 1.0.2t forumlar to $USER/old-openssl
brew extract --version=1.0.2t openssl $USER/old-openssl
# install old openssl from $USER/old-openssl repo
brew install openssl#1.0.2t
# reinstall ruby
rvm reinstall 2.3.4 --with-openssl-dir=`brew --prefix openssl#1.0.2t`
Try this.
rvm install ruby-2.0.0-preview1 --with-openssl-dir=$HOME/.rvm/usr --verify-downloads 1
This help me :
https://gist.github.com/Irio/1496746
$ rvm pkg install openssl
$ rvm remove 1.9.3
$ rvm install 1.9.3 --with-openssl-dir=$rvm_path/usr
I uninstalled everything (rvm, rails, ruby, etc) on my macbook.
Installed homebrew
Installed rvm
Ran rvm requirements run force
Ran rvm install rails
rails new sample_app
cd sample_app
Note: source 'https://rubygems.org' is present in Gemfile, openssl is required!
bundle install and it worked!
No need to specify: --with-openssl-dir=$HOME/.rvm/usr
To resolve this, install openssl (preferably using brew).
Update Xcode to the latest version and enable command line installations using it.
Reinstall rvm using
rvm reinstall all
Note that rvm reinstall all --force
will delete all your previous installations of binaries/pkgs done using rvm.
Assuming ruby is already installed, do the following:
rvm cleanup all
rvm reinstall all --force
I got the same error, and the error was fixed by opening new terminal session.
I am using frum ruby version manager.
gem install openssl
worked for me, but nothing has declared depending on the openssl, its weired
Following command solved my issue
note 2.3.4 is the ruby version I am using, change as per your requirements
rvm reinstall 2.3.4 --with-openssl-dir=$rvm_path/usr
Make sure that $rvm_path is properly set, with command echo $rvm_path. If this path is empty, check if your home folder has .rvm folder.
In this case use
rvm reinstall 2.3.4 --with-openssl-dir=~/.rvm/usr
I'm running into issues trying to install Rails on OS X Lion using RVM.
So far, I have done the following:
Installed Mac OS X Lion Version 10.7 (Build 11A459e).
Installed XCode 4.1 Developer Preview 5.
Installed RVM.
Installed a 1.8.7 version of Ruby via RVM using the command rvm install 1.8.7. Note: I need to be using 1.8.7 and not 1.9.2.
Switched to the 1.8.7 version of Ruby using the command rvm 1.8.7.
Created a new gemset using the command rvm gemset create rails3.
Switched to the new gemset using the command rvm use 1.8.7#rails3.
To install Rails I ran the command gem install rails but I got the following error:
/Users/m/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/timeout.rb:60: [BUG] Segmentation fault
The same error happens when trying to run any gem command so I don't think it's really a problem with Rails.
Judging by the links below, I don't seem to be the only person having this issue:
http://twitter.com/#!/pingles/status/66261101351927809
and https://github.com/carlhuda/bundler/issues/1058
Fixed it!
The answer was actually on one of the links I posted above. Before installing a version of ruby (rvm install 1.8.7) I needed to run "export CC=/usr/bin/gcc-4.2". With that in place, everything ran smoothly.
If you don't want to have CC permanently exported, you can do CC=/usr/bin/gcc-4.2 rvm install 1.8.7
If you have already installed ruby 1.8.7. Just do CC=/usr/bin/gcc-4.2 rvm reinstall 1.8.7
If you have installed Xcode 4.2, it actually doesn't install non-LLVM gcc anymore, so you have to add it. For some reason downgrading to 4.1 after you've installed 4.2 doesn't work correctly (at least it didn't for me and others have had similar issues).
After quite a bit of thrashing, this is what finally worked for me:
Install Xcode 4.2 from App Store
Install darwin gcc using the OSX gcc installer
Install REE making sure you remove any vestiges of previous attempts:
Close any open terminal windows, open a fresh one and
rvm remove ree
export CC=/usr/bin/gcc-4.2
rvm install ree
This worked for me with rvm 1.8.6, OS X 10.7.2 and gcc-4.2 version 4.2.1 (Apple build 5666).
If you have already installed Xcode 4.1, resist the urge to upgrade to 4.2 and you should be okay.
If that still doesn't work add --force.
So this becomes:
CC=/usr/bin/gcc-4.2 rvm install ruby-1.8.7 --force
Make sure that you remove 1.8.7 if you already installed it before using "export CC=/usr/bin/gcc-4.2" by doing "rvm remove 1.8.7"
I had the same issue on my system. I installed the Xcode command line tools from Apple which ships with LLVM compiler and without an LLVM free one.
Ruby 1.8.7 won't work with an LLVM compiler not even with CC=clang, so installing an LLVM free gcc solves the problem.
There are multiple options listed here:
https://github.com/mxcl/homebrew/wiki/Custom-GCC-and-cross-compilers
Long story short, install GCC v4.2 with Homebrew:
brew install https://raw.github.com/Homebrew/homebrew-dupes/master/apple-gcc42.rb
and then install ruby 1.8.7:
CC=gcc-4.2 rvm install 1.8.7
Instead of "export CC=/usr/bin/gcc-4.2" do "export CC=gcc" (xCode 4.2.x should be installed).
Check which version of gcc you have like this:
ls -Al `which gcc-4.2`
I followed the instructions here:
http://robots.thoughtbot.com/post/27985816073/the-hitchhikers-guide-to-riding-a-mountain-lion
brew update
brew tap homebrew/dupes
brew install apple-gcc42
Then reinstall:
Check again what your path to gcc is (to use for CC=):
ls -Al `which gcc-4.2`
(optional) You can set this in your .bashrc for example:
export CC=/usr/bin/gcc-4.2
(optional) remove any old version of ruby
rvm remove 1.8.7
Then:
CC=/usr/local/bin/gcc-4.2 rvm --verify-downloads 1 reinstall 1.8.7-p357 --without-tcl --without-tk
or if you have set CC in your profile
rvm --verify-downloads 1 reinstall 1.8.7-p357 --without-tcl --without-tk
Note the flags on the rvm install. I had trouble verifying the checksum on the ftp server and some problems with tck and what not. You may be able to omit those flags.
Also: you might need to remove an old version of your gemset:
rvm gemset delete <gemset>
Then
gem install bundler
bundle install
Hope this helps.
Using macport and ruby-1.9.x version.
I did successfully install rails with ruby gem.
I have same problem only for arch x86_64, when I comment line in my ~/.rvmrc
rvm_archflags="-arch x86_64"
Open a new terminal and tried to install ruby-1.8.7 again
rvm install 1.8.7
It was successful.
If you're using RVM in a development workflow, I added a fix in an .rvmrc file for OS X Lion.
https://gist.github.com/1112962
(updated file name)
This is not related to RVM, but if what you are looking for is a local development environment for Lion you may want to give a try to RubyStack It is a free, open source all-in-one installer for Apache, MySQL, Ruby, Rails, etc. It does not require compilation and it is self-contained so if you do not like it you can simply remove the installation directory and you are done. Disclaimer: I'm one of the RubyStack developers :)
CC=/usr/bin/gcc-4.2 rvm install 1.8.7 did not work for me, I used CC=/usr/bin/gcc rvm install 1.8.7 and it did (checking with "which gcc")
Even with all the other suggestions on this page I was still getting segfaults and getting frustrated, so I said "screw it!" and use the system-provided Ruby 1.8.7:
rvm use system
You need to use sudo for installing gems, but still waay less headache.
My solution was to override the /usr/bin/gcc symlink in the terminal. Here's how I did it:
https://plus.google.com/101970693023462019144/posts/eYVLvMCqTmc
This not only fixed my RVM installation, but also made sure that installing gems with native extensions (like rmagick) work.
I am getting the following error:
$script/console
Loading development environment (Rails 2.2.2)
/opt/ruby-enterprise-1.8.6-20080709/lib/ruby/1.8/irb/completion.rb:10:in `require': no such file to load -- readline (LoadError)
Where can i get the file and what directory should it go in?
Thanks!
The readline module is normally part of the Ruby package itself.
Did you manually build your Ruby install? If so, you want to make sure libreadline and its headers are installed, and build again.
On Debian/Ubuntu:
apt-get install libreadline-dev
Or on RHEL/CentOS, try
yum install readline-devel
Update:
You are using a very old release of Ubuntu. If you want to keep using it, open /etc/apt/sources.list in a text editor, and change all occurrences of archive.ubuntu.com to old-releases.ubuntu.com. Then, run apt-get update and try the above again.
I urge you to consider updating your installation, though. Ubuntu 7.10 hasn't seen security updates in quite a while, and using it in production is not recommended. Even if it's not a production machine, there's a good chance you'll run into further problems because of old versions of certain libraries/dependencies.
You need to install the ncurses and readline libraries.
On Ubunutu you could do
sudo apt-get install libreadline5-dev libncurses5-dev
and then you will have to recompile readline which comes with your ruby source
cd <ruby-src-dir>/ext/readline
ruby extconf.rb
make
sudo make install
If you are using RVM you could simply do
rvm package install readline
EDIT:
On newer RVM versions, this last command is
rvm pkg install readline
Add the following line to your Gemfile and run bundle update
gem 'rb-readline'
credits to similar question/answer at install ruby 1.9.3 using rvm on ubuntu
This easiest way to get relief from this problem,
just add to your Gemfile:
gem 'rb-readline'
And then run bundle install
Run the command
rvm requirements
It shows the requirements and dependencies. Install those and reinstall the ruby on rvm
rvm remove 1.9.2
rvm install 1.9.2
It works!
EDIT
If you can't find the requirements option update your rvm.
rvm update --head # older rvm
or use rvm upgrade
Maybe this is a bullshit answer, but I ran into this problem today after upgrading postgres from 9.5.3 to 9.6, along with which homebrew upgraded readline from 6.something to 7. I ended up rolling back my postgres to 9.5.3 and that resolved the issue.