The Background
I am somewhat new to Unix coming from a .NET environment but I know enough now to get me in trouble.
I got an existing code I am working with that uses Cocoapods so I tried to install Cocoapods.
Initially when I installed it it failed saying it requires a newer version of Ruby.
To install Ruby I used an installer called rvm. With some effort I got RVM installed and got Ruby Version 2.1.0.
When I go to directory where the app is and i type pod install it responds with pod: command not found. The assumption is that there must be something wrong with the install of cocoa pods. If I try any command to install or uninstall Cocoapods
gem install cocoapods or gem uninstall cocoa pods
it returns the same response which is:
/Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_gem.rb:59:in `gem': uninitialized constant Gem::LOADED_SPECS_MUTEX (NameError)
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:46:in `require'
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems.rb:601:in `load_yaml'
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/config_file.rb:328:in `load_file'
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/config_file.rb:197:in `initialize'
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/gem_runner.rb:74:in `new'
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/gem_runner.rb:74:in `do_configuration'
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/gem_runner.rb:39:in `run'
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/bin/gem:21:in `<main>'
I am thinking that perhaps the failed attempts to install cocoa pods may have either corrupted something, put something in the wrong place. I want to completely uninstall cocoapods and reinstall it but install and uninstall are not doing anything.
UPDATE: Using gem list --local | grep cocoa pods just to see what version of CocoaPods I have installed gives me the same exact output.
The Question:
Does anyone know a way to either fix this issue or completely rip and rebuild CocoaPods?
I was brilliantly assisted with help from #Pedros (the currently accepted answer) but because there were so many comments back and forth I decided to clean up the answer that worked for me. I will keep his as the accepted answer since he really helped me tremendously on this one. If this is helpful to you and you choose to up vote, please also up vote the accepted answer since this is derived almost completely from his answer.
Here is what I found out :
In my case it was that RVM was not installed correctly so RubyGems wasn't installed correctly. That in turn made CocoaPods not install correctly.
To completely uninstall and remove RVM: try sudo rvm implode or you can do sudo rm -rf ~/.rvm
I did some checks to see if I had the correct versions. I will post what they should be right now but this can be different as versions keep getting updated.
ruby --version should be 2.1.2
which ruby should be the RVM ruby. (To see if there is no conflict with OSX`s ruby)
gem --version should be 2.2.2
Reinstall RVM by doing this: \curl -sSL https://get.rvm.io | bash -s stable --ruby
Reinstall CocoaPods like this: gem install cocoapods
I hope this saves someone some development hours and hair loss :)
gem env will tell you the installation path of your gems.
By the error you got on the first time you installed the gem it could be a PATH error. Maybe your gems folder is not properly set in the PATH and shell is not finding Cocoapods.
Try to print your PATH with echo $PATH and see if the - EXECUTABLE DIRECTORY: from gem env is there.
Also try gem pristine --all
If that doesn't work try to change to ruby 2.1.2 and reinstall cocoapods.
Try bundle install first, then you can run pod install again.
Related
So when I try running bundle install --without production it tells me that I am getting an error and that I need to Make sure that gem install unf_ext -v 0.0.7.2 succeeds before bundling. I have not gotten this error before while installing other gems, but only when I try and install gem stripe(which is used for receiving user payments and such).
Could someone explain what could be causing this kind of problem. All help is greatly appreciated.
Thanks,
-Aaron
EDIT
What I did to solve my problems was updating all of my gems to their current and latest version. Then when I ran bundle install --without production everything seemed to install perfectly fine after that.
This error can come across due to various reasons, so it's not easy to tell what might have really caused, preventing you from bundle install, so try the following fixes, if not worked please give more details on errors that appears :)
If the error was because of missing gmkdir, then run the following command:
brew install coreutils
If the error was due to missing C++ headers related then run the bellow command:
yum install gcc-c++
Also have a look at the developer's home page given below to check you meet all dependencies required:
unf_ext 0.0.7.2 : Unicode Normalization Form support library for CRuby
After updating to Mojave MacOS version, the ruby 'lost' the reference.
To solve
$ rvm list
In my case, the version listed was:
ruby-2.5.1 [ x86_64 ]
$ rvm use ruby-2.5.1
to change to 'current' version used
$ rvm list again
to see the current version
=> ruby-2.5.1 [ x86_64 ]
After that everything are okay running bundle install or bundle update or gem install or gem update
I just have the same problem when i try to install vagrant plugin, you need to install ruby-devel before.
Hope this help you.
I ran into this deploying to a remote box. As suggested in comments, I was able to fix it by opening a console session on the affected box and running:
gem update rails
gem install unf_ext -v '0.0.7.2'
And I was then able to deploy successfully.
I resolved this issue by upgrading bundler. Simply run:
gem install bundler
which fetches the latest bundler. Then, try running:
bundle install
I got same problem. It happens after I upgrading my macOS to newer version.
Somehows, upgrading mess up /usr/local/include. So that I removed it and run install. It worked
sudo mv /usr/local/include/ /usr/local/include.delete_me
Similar to the comment of Luke, xcode-select did the job for me. But instead of switching it to a different location, I just reverted the selected version to default, although I cannot remember to ever have changed it.
sudo xcode-select -r
After that bundle install and bundle update worked fine for me again.
I was having the exact same issue trying to install this specific gem and version as well. Turns out my VPS would run out of RAM while compiling and quit. I just killed off a few processes I could live without for a few minutes and it worked...
I solved this issue by running
sudo xcodebuild -license
I was working with docker and docker compose. similar issue arised to me. I deleted the image, removed all associated containers with the application and rebuilt the image with docker build . created the container with docker-compose up inside the working directory and it started working. this solution is specific to those using docker and docker-compose. Hope it helps someone. I am still not sure about the reason why is this happening.
this can be solved installing ruby-dev
and then gem install unf_ext -v 0.0.7.2
I ran into this issue getting
Installing unf_ext 0.0.8 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/jfn0296/.rvm/gems/ruby-3.0.0/gems/unf_ext-0.0.8/ext/unf_ext
/Users/jfn0296/.rvm/rubies/ruby-3.0.0/bin/ruby -I /Users/jfn0296/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0 -r
./siteconf20220120-59736-elnfu0.rb extconf.rb
checking for -lstdc++... yes
creating Makefile
current directory: /Users/jfn0296/.rvm/gems/ruby-3.0.0/gems/unf_ext-0.0.8/ext/unf_ext
make "DESTDIR=" clean
current directory: /Users/jfn0296/.rvm/gems/ruby-3.0.0/gems/unf_ext-0.0.8/ext/unf_ext
make "DESTDIR="
compiling unf.cc
make: *** [unf.o] Error 1
make failed, exit code 2
After trying many of these listed, using rvm I uninstalled and reinstalled my ruby-3.0.0 and tried bundling again and this time it worked. Did not see a solution like that here so I thought I'd share.
I removed cocoa pods because it claimed it had installed, but kept saying the command pod wasn't found afterward. When trying to reinstall cocoapods (sudo gem install cocoa pods -v) I get this error:
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/pod
Any ideas?
As it has been pointed out below by Ramesh Ramchandaran, this is a cleaner way of doing it, instead of getting around the Security features of OS X.
sudo gem install -n /usr/local/bin cocoapods
Original Answer
I'm assuming you're running OS X 10.11.
This is happening because Apple has enabled rootless on the new install.
If you type:
sudo nvram boot-args="rootless=0"; sudo reboot
in terminal.app, your computer will reboot with it disabled.
Once that is done, type:
sudo gem install cocoapods -V
the -V is for verbose and will spit out any errors if they happen.
As rootless does not affect /usr/local/bin, the following succeeds:
sudo gem install -n /usr/local/bin cocoapods
Any caveats?
Using home-brew or custom $GEM_HOME can help resolving the issue.
I did clean installation of ruby with brew:
brew install ruby
Now the gem stuff seem to happen relative to my /usr/local/bin*, which is exactly what I needed.
I recommend installing all your gems into your .gem folder in your home folder to avoid using sudo or a ruby version manager as other people suggest.
All you have to do is update your .bash_profile by adding these 2 lines. (Don‘t forget to restart your terminal after applying these changes)
export GEM_HOME=~/.gem
export PATH="$GEM_HOME/bin:$PATH"
After updgrading from Yosemite to El Capitan ( 10.11.4), I kept getting the below error message while trying to 'reinstall' Cocoapods ( after trying out pretty much all the solutions under different Stackoverflow threads and the Cocoapods issue-page itself, for the same issue)
"Could not find a valid gem 'cocoapods' (>= 0) in any repository"
However, quit terminal, restarted system, created new Xcode project from the scratch and then when i did 'pod install', it worked.
Note: I was trying to use Alamofire and SwiftyJson cocoapods
I just upgraded to Rails 3 and had a bit of a mess with MacPorts, gems and databases to sort out. I threw out all the gems and installed them fresh. Everything seems to be OK except for the requirement of the pg gem.
After creating a new Rails 3 project, prepared for PostgreSQL, the server would not start, complaining about the missing pg gem. Doing bundle install, it chugged along for a while and, of course, fails on the pg gem.
Installing pg (0.10.0) with native extensions /Library/Ruby/Site/1.8/rubygems/installer.rb:483:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/pg-0.10.0 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/pg-0.10.0/ext/gem_make.out
from /Library/Ruby/Site/1.8/rubygems/installer.rb:446:in `each'
from /Library/Ruby/Site/1.8/rubygems/installer.rb:446:in `build_extensions'
from /Library/Ruby/Site/1.8/rubygems/installer.rb:198:in `install'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/source.rb:95:in `install'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/installer.rb:55:in `run'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/spec_set.rb:12:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/spec_set.rb:12:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/installer.rb:44:in `run'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/installer.rb:8:in `install'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/cli.rb:225:in `install'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/vendor/thor/task.rb:22:in `send'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/vendor/thor/task.rb:22:in `run'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/vendor/thor.rb:246:in `dispatch'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/vendor/thor/base.rb:389:in `start'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/bin/bundle:13
from /usr/bin/bundle:19:in `load'
from /usr/bin/bundle:19
The most common suggestion I have found on forums and blogs is to (re)install the XCode developer tools. They were already there, but I reinstalled them anyway, with no better outcome than the above.
which ruby says /usr/bin/ruby, and ruby -v says ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0], if there's any clue there.
Pointers are welcome. Any missing information that would help figuring this out, I'll gladly and promptly provide!
I downloaded XCode since the DVD version is said to be broken and things went better for a while. bundle install started talking about "archflags" instead, so I did:
sudo env ARCHFLAGS="-arch i386" bundle install
and things seemed to go fine, until starting Rails barfed, saying:
/Library/Ruby/Gems/1.8/gems/pg-0.10.0/lib/pg_ext.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/pg-0.10.0/lib/pg_ext.bundle, 9): no suitable image found. Did find: (LoadError)
/Library/Ruby/Gems/1.8/gems/pg-0.10.0/lib/pg_ext.bundle: mach-o, but wrong architecture - /Library/Ruby/Gems/1.8/gems/pg-0.10.0/lib/pg_ext.bundle
Grappling for anything, I tried bundle install with archflags set to -arch x86_64, but it didn't go well:
*** Your PostgreSQL installation doesn't seem to have an architecture in common with the running ruby interpreter ([] vs. ["x86_64"])
I'll continue anyway, but if it fails, try setting ARCHFLAGS.
[...]
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
Is libpq something I now have to supply a path to via some flags? Or am I completely out to lunch?
I encountered this error when I tried to install rails by gem on CentOS 6.3.
After googling a bit, I found a quick fix: installing the ruby-devel package.
sudo yum install ruby-devel
After that, everything worked fine.
Generally the gem bundles for Postgres want to know where pg_config is hiding so they can ask about the Postgres installation.
Use locate pg_config to see if your Mac knows where it's hiding.
I installed a copy of Postgres using mappstack, so my Mac says there's a copy at:
/Applications/mappstack-1.2-3/postgresql/bin/pg_config
and another at:
/Library/PostgreSQL/9.0/bin/pg_config
I don't remember installing the one at /Library/PostgreSQL/9.0, so it might have been preinstalled by Snow Leopard, or I did it when under the influence of too much work, possibly using the Postgres installer from EnterpriseDB.
Once you've found the location of pg_config try adding that directory to the start of your PATH and then rerun the gem install.
Or use:
export SQL_PATH=/Library/PostgreSQL/9.0
gem install pg -- --with-pg-config=$SQL_PATH/bin/pg_config
and try installing. If either of those work you're done. Otherwise...
The next thing the installers might want are access to the Postgres headers, so you look in the parent of the bin directories, and see if you can find an include directory.
After that, look in that directory for a lib directory. Once you know those locations you should have all you need to set your environment variables to let the installer complete. You'll need to read the README or INSTALL file of the installer and see what needs to be set up. You'll be configuring:
export include_dir=$SQL_PATH/include/
export lib_dir=$SQL_PATH/lib/
gem install pg -- --with-pgsql-include-dir=$include_dir --with-pgsql-lib-dir=$lib_dir
Hopefully that'll all help. I have Rails 3 and my Postgres running fine, using the mappstack Postgres and the EnterpriseDB versions, so the above info should get you there.
This worked for me on OS X 10.6.6, with PostgreSQL 9.0.1 installed from the source code:
export PATH=/usr/local/psql/bin:$PATH
export ARCHFLAGS='-arch x86_64'
gem install pg
You'll likely need to edit that PATH to match your postgres install location.
I've got postgres 1.9.0 installed via macports. OS X 10.5 PPC
This worked for me:
gem install pg -- --with-pg-lib=/opt/local/lib/postgresql90 --with-pg-include=/opt/local/include/postgresql90
Good luck!
Generally the gem bundles for Postgres want to know where pg_config is hiding . . .
Right - this could be the trick. If you just installed PostgreSQL and added it to your path, and did "bundle install" in an old shell, it won't be able to find pg_config. If that's the case, just get a new shell and try again. Otherwise, follow the steps above to find it and get it seen by bundler.
The macports install for postgresql83 works fine and plays nicely with rails right out of the box - that's another way to do it.
I just spent a good deal of time getting this to work tonight. I saw a similar error to this:
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
I tried different gem install variations:
gem install pg -- --with-pg-config=/Library/PostgreSQL/9.1/bin/ --with-pg-lib=/Library/PostgreSQL/9.1/lib/ --with-pg-include=/Library/PostgreSQL/9.1/include/
But finally what worked for me was:
gem install pg -- --with-pg-dir=/Library/PostgreSQL/9.1/
Also, before that I updated rvm (rvm get head) and reinstalled ruby (rvm --force install 1.9.2). Not sure if this helped or not, but it might be worth trying if you still hit issues
You might want to try going with homebrew for installing postgres (brew install postgres) and Ruby Version Manager for installing and maintaining ruby and ruby gems.
It'll leave your default versions (installed with OSX) untouched and give you more flexibility. For example, you could have different rails apps using rails 2 or 3 with ruby 1.8.7 and 1.9.2 all installed on the same system without problems.
This worked for me:
sudo env ARCHFLAGS="-arch x86_64" gem install pg
All the suggestions here and around the Web were incomplete for me, until I run the following on CentOS 6.6:
wget -c ftp://mirror.switch.ch/pool/4/mirror/scientificlinux/6.3/x86_64/updates/security/kernel-devel-2.6.32-504.1.3.el6.x86_64.rpm && sudo yum install kernel-devel-2.6.32-504.1.3.el6.x86_64.rpm
wget -c ftp://mirror.switch.ch/pool/4/mirror/scientificlinux/6.6/x86_64/updates/security/kernel-headers-2.6.32-504.30.3.el6.x86_64.rpm && sudo yum install kernel-headers-2.6.32-504.30.3.el6.x86_64.rpm
sudo yum groupinstall "Development Tools" "Development Libraries"
sudo yum -y install gcc gcc-c++ git ruby ruby-devel rubygems libvirt-devel mysql-devel postgresql-devel openssl-devel libxml2-devel sqlite-devel libxslt-devel zlib-devel readline-devel tar make automake autoconf curl-devel openssl-devel zlib-devel httpd-devel apr-devel apr-util-devel sqlite-devel ruby193-ruby-doc ruby193-ruby-devel ruby193-build
curl -L get.rvm.io | bash -s stable && source $HOME/.rvm/scripts/rvm && rvm requirements
Install Postgres.app:
http://postgresapp.com/
Verify what version was installed:
$ ls /Library/PostgreSQL/
# 9.4
Export the SQL_PATH:
export SQL_PATH=/Library/PostgreSQL/9.4
Install pg:
gem install pg -- --with-pg-config=$SQL_PATH/bin/pg_config
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.
I tried to install the new beta on my system with the command:
sudo gem install rails --pre
but no matter what I tried, I still get this damn error:
Successfully installed
rails-3.0.0.beta3 1 gem
installed Installing ri
documentation for
rails-3.0.0.beta3... File not
found: lib
Since I'm very new to ruby, I really don't know what to do.
How can I finish installing this?
Is this installed already?
Why does it abort here?
All you need to run is gem install rdoc, follow its instructions, then run the install rails command again and you're good. The problem is due to rdoc failing to install when installed with rails, if installed manually it works fine.
Source: http://gist.github.com/565967
^ I had the same problem, and this worked for me.
If you're looking to do ruby/rails development on Mac, I'd strongly recommend not using the version of ruby/rubygems shipped with your mac. What I do recommend is:
Installing homebrew and using that to manage software packages on your mac.
Install brewbygems, which makes homebrew play nice with rubygems: gem install brewbygems
Install rvm and learn to love the different versions of ruby and rvm's gemsets feature: gem install rvm
Once you've done that you'll have a pretty robust development environment and you should be able to install any version of rails without a problem. Just keep in mind rails 3 works best using ruby 1.9.2 (install with rvm by running rvm install ruby-head) and is still in beta, meaning it isn't terribly stable and should not be used for anything production grade (yet).
I found the same error message, while after some google I've successfully installed it by manually 'sudo mkdir lib' in the .../gems/rails-3.0.0.beta3. Though it hasn't raised further problem, I hope someone could tell what should be in the missing lib directory.
You don't really need to do this sudo gem install rails --pre, simply sudo gem install rails. Rails3 is the default package now and out of beta.
It should work fine.
Might be a different solution on your OS, but I got the same exact error in Ubuntu and creating a ¨lib¨ folder under the rails gem folder solved my problem. I have explained the solution in the following post:
Installing Rails: "File not found: lib"
For convenience I will copy it here as well. The solution:
mkdir /lib/ruby/gems/1.8/gems/rails-{whatever your version is}/lib
Explanation: The ¨[sudo] gem install rails¨ command expects the /lib folder (at the end) but for some reason it hasn´t been created yet.
The original source of this solution was the following URL. Hope it helps!
http://www.spritle.com/blogs/?p=915
Same problem with beta 4.
The workaround is sudo gem install rails --pre --no-ri --no-rdoc though I don't know why.