Gitlab project - failed to run "rails generate" - ruby-on-rails

Introduction:
I have an installation of gitlab on a local lxc container running ubuntu 13.10 - saucy.
I have installed RVM as a as a multi-user installation - in /usr/local/rvm
In order to run gitlab with RVM I have created a wrapper for the bundle command as specified here
The gitlab application is running correctly but I have a problem running rails generate function
The steps I followed :
$ sudo su git - to login as the git user
$ cd /home/git/gitlab
$ source /etc/profile/
$ rvm use gemset ruby-2.1.1#gitlab - a custom gemset I created
$ gem list - lists all the gems that appear in the Gemfile for gitlab, so I know I am on the right gemset
$ rails -v -> Rails 4.0.3
$ rails generate --help will output
/usr/local/rvm/gems/ruby-2.1.1#global/gems/bundler-1.5.3/lib/bundler/runtime.rb:76:in `require': cannot load such file -- rb-inotify (LoadError)
from /usr/local/rvm/gems/ruby-2.1.1#global/gems/bundler-1.5.3/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /usr/local/rvm/gems/ruby-2.1.1#global/gems/bundler-1.5.3/lib/bundler/runtime.rb:72:in `each'
from /usr/local/rvm/gems/ruby-2.1.1#global/gems/bundler-1.5.3/lib/bundler/runtime.rb:72:in `block in require'
from /usr/local/rvm/gems/ruby-2.1.1#global/gems/bundler-1.5.3/lib/bundler/runtime.rb:61:in `each'
from /usr/local/rvm/gems/ruby-2.1.1#global/gems/bundler-1.5.3/lib/bundler/runtime.rb:61:in `require'
from /usr/local/rvm/gems/ruby-2.1.1#global/gems/bundler-1.5.3/lib/bundler.rb:131:in `require'
from /home/git/gitlab/config/application.rb:6:in `<top (required)>'
from /home/git/gitlab/vendor/bundle/ruby/2.1.0/gems/railties-4.0.3/lib/rails/commands.rb:43:in `require'
from /home/git/gitlab/vendor/bundle/ruby/2.1.0/gems/railties-4.0.3/lib/rails/commands.rb:43:in `<top (required)>'
from bin/rails:8:in `require'
from bin/rails:8:in `<main>'
What I gathered from this output is that it is in some way trying to use the ruby-2.1.1#global gemset.
If I switch to that gemset $ rvm use gemset ruby-2.1.1#global, $ gem list will output
*** LOCAL GEMS ***
bigdecimal (1.2.4)
bundler (1.5.3)
bundler-unload (1.0.2)
executable-hooks (1.3.1)
gem-wrappers (1.2.4)
io-console (0.4.2)
json (1.8.1)
minitest (4.7.5)
psych (2.0.3)
rake (10.1.0)
rdoc (4.1.0)
rubygems-bundler (1.4.2)
rvm (1.11.3.9)
test-unit (2.1.1.0)
And if I run bundle install or the wrapper bundle install it says that all the gems are installed.
What am I missing here?
--------------------edit------------------
found a way to make it work
I followed the trouble shooting guide and tried
RAILS_ENV=production bundle exec rails generate --help and it worked
Apparently as stated here in the last comment, rb-inotify is "marked as development dependency" therefore forcing the environment to be production, it won't try to use it

To resolve
'require': cannot load such file -- rb-inotify
You need to install rb-inotify gem. Use the below command to install it:
gem install rb-inotify

Put this line in Gemfile
gem 'rb-inotify'
and give bundle install then
please give gem list in terminal.
if it is there means to fix this problem require this gem in application.rb like,
require "rb-inotify"
this problem will solve.

Related

"bundle exec spring binstub -all" fails

When I make a new rails project:
rails new test_app
it fails with the following:
run bundle exec spring binstub --all
bundler: failed to load command: spring (/Users/npresco/.rbenv/versions/2.5.0/bin/spring)
LoadError: cannot load such file -- spring-commands-rspec
/Users/npresco/.spring.rb:1:in `require'
/Users/npresco/.spring.rb:1:in `<top (required)>'
/Users/npresco/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/commands.rb:29:in `require'
/Users/npresco/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/commands.rb:29:in `<module:Spring>'
/Users/npresco/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/commands.rb:4:in `<top (required)>'
/Users/npresco/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/client/binstub.rb:138:in `require'
/Users/npresco/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/client/binstub.rb:138:in `call'
/Users/npresco/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
/Users/npresco/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
/Users/npresco/.rbenv/versions/2.5.0/bin/spring:23:in `load'
/Users/npresco/.rbenv/versions/2.5.0/bin/spring:23:in `<top (required)>'
I am using:
rbenv 1.1.1
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin16]
rails 5.1.4
bundler 1.16.1
I suspect there is something going on with bundler but I am not sure what. I am able to run spring binstubs --all inside the project directory but not bundle exec spring binstubs --all
Top of bundle env
Bundler 1.16.1
Platforms ruby, x86_64-darwin-16
Ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin16]
Full Path /Users/npresco/.rbenv/versions/2.5.0/bin/ruby
Config Dir /Users/npresco/.rbenv/versions/2.5.0/etc
RubyGems 2.7.3
Gem Home /Users/npresco/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0
Gem Path /Users/npresco/.gem/ruby/2.5.0:/Users/npresco/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0
User Path /Users/npresco/.gem/ruby/2.5.0
Bin Dir /Users/npresco/.rbenv/versions/2.5.0/bin
Tools
Git 2.11.0 (Apple Git-81)
RVM not installed
rbenv rbenv 1.1.1
chruby not install
I think you can try this, just replace bundle to bundler
$ gem install bundler
$ bundler exec spring binstub --all

Ruby on Rails: cannot load rack/handler/

I had a fully working Rails server last night. However, on accessing my computer this morning, I found it had crashed. I booted back up, then SSHed on to my remote server, and attempted to restart the server process, first querying:
rails server -h
Which resulted in:
/usr/local/lib/site_ruby/2.3.0/rubygems.rb:270:in `find_spec_for_exe': can't find gem railties (>= 0.a) (Gem::GemNotFoundException)
from /usr/local/lib/site_ruby/2.3.0/rubygems.rb:298:in `activate_bin_path'
from /usr/local/bin/rails:22:in `<main>'
I then attempted a bundle install, which threw the following error:
enter code here/usr/local/lib/site_ruby/2.3.0/rubygems.rb:270:in `find_spec_for_exe': can't find gem bundler (>= 0.a) (Gem::GemNotFoundException)
from /usr/local/lib/site_ruby/2.3.0/rubygems.rb:298:in `activate_bin_path'
from /usr/local/bin/bundle:22:in `<main>'
I then reinstalled Rails with rvm use ruby-2.3.1#rails5.0 --create followed by gem install rails. rails -v now reports:
Rails 5.0.1
However, when I attempt to start a server process ( rails server -p 80 - b 139.162.246.138 ) I get:
Exiting
/home/peter/.rvm/gems/ruby-2.3.1#rails5.0/gems/rack-2.0.1/lib/rack/handler.rb:74:in `require': cannot load such file -- rack/handler/- (LoadError)
from /home/peter/.rvm/gems/ruby-2.3.1#rails5.0/gems/rack-2.0.1/lib/rack/handler.rb:74:in `try_require'
from /home/peter/.rvm/gems/ruby-2.3.1#rails5.0/gems/rack-2.0.1/lib/rack/handler.rb:16:in `get'
from /home/peter/.rvm/gems/ruby-2.3.1#rails5.0/gems/rack-2.0.1/lib/rack/server.rb:300:in `server'
from /home/peter/.rvm/gems/ruby-2.3.1#rails5.0/gems/railties-5.0.1/lib/rails/commands/server.rb:112:in `print_boot_information'
from /home/peter/.rvm/gems/ruby-2.3.1#rails5.0/gems/railties-5.0.1/lib/rails/commands/server.rb:73:in `start'
from /home/peter/.rvm/gems/ruby-2.3.1#rails5.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:90:in `block in server'
from /home/peter/.rvm/gems/ruby-2.3.1#rails5.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:85:in `tap'
from /home/peter/.rvm/gems/ruby-2.3.1#rails5.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:85:in `server'
from /home/peter/.rvm/gems/ruby-2.3.1#rails5.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /home/peter/.rvm/gems/ruby-2.3.1#rails5.0/gems/railties-5.0.1/lib/rails/commands.rb:18:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
I have tried uninstalling and reinstalling both ruby and rails, and running a new bundle install. Not getting basically the same error:
/home/peter/.rvm/gems/ruby-2.4.0-rc1/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:51: warning: constant ::Fixnum is deprecated
/home/peter/.rvm/gems/ruby-2.4.0-rc1/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:52: warning: constant ::Bignum is deprecated
Exiting
/home/peter/.rvm/gems/ruby-2.4.0-rc1/gems/rack-2.0.1/lib/rack/handler.rb:74:in `require': cannot load such file -- rack/handler/- (LoadError)
from /home/peter/.rvm/gems/ruby-2.4.0-rc1/gems/rack-2.0.1/lib/rack/handler.rb:74:in `try_require'
from /home/peter/.rvm/gems/ruby-2.4.0-rc1/gems/rack-2.0.1/lib/rack/handler.rb:16:in `get'
from /home/peter/.rvm/gems/ruby-2.4.0-rc1/gems/rack-2.0.1/lib/rack/server.rb:300:in `server'
from /home/peter/.rvm/gems/ruby-2.4.0-rc1/gems/railties-5.0.1/lib/rails/commands/server.rb:112:in `print_boot_information'
from /home/peter/.rvm/gems/ruby-2.4.0-rc1/gems/railties-5.0.1/lib/rails/commands/server.rb:73:in `start'
from /home/peter/.rvm/gems/ruby-2.4.0-rc1/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:90:in `block in server'
from /home/peter/.rvm/gems/ruby-2.4.0-rc1/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:85:in `tap'
from /home/peter/.rvm/gems/ruby-2.4.0-rc1/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:85:in `server'
from /home/peter/.rvm/gems/ruby-2.4.0-rc1/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /home/peter/.rvm/gems/ruby-2.4.0-rc1/gems/railties-5.0.1/lib/rails/commands.rb:18:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
I have also tried completely uninstalling rails and railties with:
gem uninstall rails -v 5.0.1
gem uninstall railties -v 5.0.1
gem install rails -v 5.0.1
gen install railties -v 5.0.1
Same error.
Attempted to locate problem call with:
sudo grep -rnw './' -e "/var/lib/gems/2.3.0/"
From source directory outputs nothing to console.
Attempting to access the directory listed in the error message results in:
cd /var/lib/gems/
-bash: /home/peter/.rvm/scripts/initialize: No such file or directory
-bash: /home/peter/.rvm/scripts/hook: No such file or directory
Running sudo gem uninstall --all to remove all gems results in:
You have requested to uninstall the gem:
actioncable-5.0.1
rails-5.0.1 depends on actioncable (= 5.0.1)
If you remove this gem, these dependencies will not be met.
Continue with Uninstall? [yN] ERROR: While executing gem ... (Gem::DependencyRemovalException)
Uninstallation aborted due to dependent gem(s)
Although removing the rails-5.0.1 gem before running the command fixed this... However, after running this command which is supposed to remove all gems, rails -v now outputs:
Rails 4.2.7.1
And running gem uninstall rails-4.2.7.1 does not remove this version.
gem uninstall -v rails-4.2.7.1 results in:
ERROR: While executing gem ... (Gem::Requirement::BadRequirementError)
Illformed requirement ["rails-4.2.7.1"]
Update: finally managed to remove rails and ruby. Reinstalled them. Same problem.
Tried creating a rew rails project and the new project does exactly the same thing.
After all that work, the solution was simple. I was typing:
rails server -p 80 - b 139.162.246.138
Instead of:
rails server -p 80 -b 139.162.246.138
have you rehashed after installing gems using => rbenv ? if not check in the => gemfile to make sure you have the matching ruby versions as well as your => gemfile.lock (in the directory your working in)
The moral of this story is that if you mangle something on the command line while invoking rails server, you'll get:
bootsnap-1.3.2/lib/bootsnap/load_path_cache/
core_ext/kernel_require.rb:32:in `require': cannot
load such file -- rack/handler/--some-wrong-option (LoadError)
This is a little ambiguous. It's not that bootsnap can't load rack, it's that it can't load the rack "some wrong option" handler, because your option is wrong, probably a typo.

Ruby on rails bundle install - json error

I have a lot of difficulties to run Ruby on Rails. Maybe you can tell me where I'm wrong ?
I'm on Linux Mint 17.2, with LAMP local server.
To install Ruby :
$ sudo apt-get install ruby
$ ruby -v
ruby 1.9.3p484
$
I didn't have to install gem, it works as shown here :
$ gem help commands
GEM commands are:
build Build a gem from a gemspec
cert Manage RubyGems certificates and signing settings
(...)
update Update the named gems (or all installed gems) in the local
repository
which Find the location of a library file you can require
For help on a particular command, use 'gem help COMMAND'.
Commands may be abbreviated, so long as they are unambiguous.
e.g. 'gem i rake' is short for 'gem install rake'.
Then I installed rails, I dont remember which of those two ways :
$ sudo gem install rails
or
$ sudo apt-get install ruby-railties-4.0
I dont find how to uninstall, so I can't test other ways to install.
Then, I made an application :
$ rails new (path)/second_app
create
create README.rdoc
create Rakefile
create config.ru
create .gitignore
create Gemfile
create app
create app/assets/javascripts/application.js
(...)
create vendor/assets/javascripts
create vendor/assets/javascripts/.keep
create vendor/assets/stylesheets
create vendor/assets/stylesheets/.keep
run bundle install
/usr/lib/ruby/1.9.1/rubygems.rb:308:in `bin_path': can't find gem bundler (>= 0) (Gem::GemNotFoundException)
from /var/lib/gems/1.9.1/gems/railties-4.0.2/lib/rails/generators/app_base.rb:268:in `bundle_command'
from /var/lib/gems/1.9.1/gems/railties-4.0.2/lib/rails/generators/app_base.rb:277:in `run_bundle'
from (eval):1:in `run_bundle'
from /var/lib/gems/1.9.1/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
from /var/lib/gems/1.9.1/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
from /var/lib/gems/1.9.1/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `block in invoke_all'
from /var/lib/gems/1.9.1/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `each'
from /var/lib/gems/1.9.1/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `map'
from /var/lib/gems/1.9.1/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `invoke_all'
from /var/lib/gems/1.9.1/gems/thor-0.19.1/lib/thor/group.rb:232:in `dispatch'
from /var/lib/gems/1.9.1/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
from /var/lib/gems/1.9.1/gems/railties-4.0.2/lib/rails/commands/application.rb:43:in `<top (required)>'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /var/lib/gems/1.9.1/gems/railties-4.0.2/lib/rails/cli.rb:15:in `<top (required)>'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /var/lib/gems/1.9.1/gems/railties-4.0.2/bin/rails:9:in `<top (required)>'
from /usr/local/bin/rails:23:in `load'
from /usr/local/bin/rails:23:in `<main>'
It looks like it was a problem running bundle install. According to tutorials, I run the command
$ bundle install
And I got
Fetching gem metadata from https://rubygems.org/............
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.4.2)
Using i18n (0.7.0)
Using minitest (4.7.5)
…
Using jbuilder (1.5.3)
Using jquery-rails (3.1.3)
Installing json (1.8.3)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:1:in `<main>'
Gem files will remain installed in /home/alejandro/.bundler/tmp/9377/gems/json-1.8.3 for inspection.
Results logged to /home/alejandro/.bundler/tmp/9377/gems/json-1.8.3/ext/json/ext/generator/gem_make.out
An error occurred while installing json (1.8.3), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.3'` succeeds before bundling.
I tryed to install json in several ways :
$ sudo gem install json -v '1.8.3'
$ sudo apt-get install json -v '1.8.3'
$ sudo gem install json
But it don't work. I tryed to to run de server :
$ rails server
Could not find gem 'rails (= 4.0.2) ruby' in the gems available on this machine.
Run `bundle install` to install missing gems.
I have tryed to install rvm and rbenv, but nothing works in the way tutorials says it should. My feeling is that I missed something in the begynning, but I dont know what.
Could you please help me ?
Thanks
Alex
You need to update gem lock and all dependency
For that please execute below command,
gem update --system
Now You can install json gem using ,
gem install json
Try above command and let me know if you still face same thing. Above things works fine for me:D

Ruby on Rails - Lynda - Generating a Controller and View, Error on 'Rails Generate' Command

I'm new to Ruby on Rails and was following Lynda's Ruby on Rails essential training guide videos.
In the getting started set of videos, we are shown how the 'rails generator' command works. I have followed all the steps, but every time I type in '$ rails generate' I get the following error:
Warning: You're using Rubygems 2.0.14 with Spring. Upgrade to at least Rubygems 2.1.0 and run `gem pristine --all` for better startup performance.
/Users/waleedrahamtullah/.rbenv/versions/2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- bundler/setup (LoadError)
from /Users/waleedrahamtullah/.rbenv/versions/2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/commands.rb:33:in `<module:Spring>'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/commands.rb:4:in `<top (required)>'
from /Users/waleedrahamtullah/.rbenv/versions/2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/waleedrahamtullah/.rbenv/versions/2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application.rb:77:in `preload'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application.rb:140:in `serve'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application.rb:128:in `block in run'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application.rb:122:in `loop'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application.rb:122:in `run'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.1.3/lib/spring/application/boot.rb:18:in `<top (required)>'
from /Users/waleedrahamtullah/.rbenv/versions/2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/waleedrahamtullah/.rbenv/versions/2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
How do you suppose I get around this?
The answer is in the Error:
You're using Rubygems 2.0.14 with Spring. Upgrade to at least Rubygems 2.1.0 and run `gem pristine --all`
Update with this:
gem install rubygems-update
Then run:
gem pristine --all
All should be well.
When I update
gem install rubygems-update
and then
gem pristine --all
it didn't work for me.
But answer from How to upgrade rubygems helped to fix issue, but after that for some reason I had to install rails again and install all gems.
Install rubygems-update
gem install rubygems-update
update_rubygems
gem update --system
run this commands as root or use sudo.
I am using ruby with rbenv so I could run those as normal user.
However, generating new rails site
rails new blog
Shows warning about old rubygems.
Warning: You're using Rubygems 2.0.14 with Spring.
Hmm. Checking the environment:
gem env
shows
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.14
which is no good. As suggested on the internets I run:
gem install rubygems-update
gem pristine --all
update_rubygems
I am not sure if gem pristine --all was needed, but it can't harm anything. Checking the update status now
gem env
shows
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.6
which is good. Calling
rails new blog
and everything went ok. No warning at all.

Error installing pg gem on osx

I am on osx 10.6.7 trying to run bundle install on a new rails 3.0.7 app and it keeps failing when trying to build the pg gem. It keeps telling me that I have need the developer tools. But as far as I can tell I have the developer tools installed.
Here is the output of xcodebuild -version
Xcode 3.2.6
Component versions: DevToolsCore-1809.0; DevToolsSupport-1806.0
BuildVersion: 10M2518
Here is the output of the failed pg gem build
/Users/bm/.rvm/rubies/ruby-1.9.2-head/bin/ruby extconf.rb --with-pg-config=/Library/PostgreSQL/8.4/bin/pg_config
Using config values from /Library/PostgreSQL/8.4/bin/pg_config
checking for libpq-fe.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/bm/.rvm/rubies/ruby-1.9.2-head/bin/ruby
--with-pg
--without-pg
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pg-config
/Users/bm/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/mkmf.rb:368:in `try_do': The complier failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/bm/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/mkmf.rb:452:in `try_cpp'
from /Users/bm/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/mkmf.rb:853:in `block in find_header'
from /Users/bm/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/mkmf.rb:693:in `block in checking_for'
from /Users/bm/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/mkmf.rb:280:in `block (2 levels) in postpone'
from /Users/bm/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/bm/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone'
from /Users/bm/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/bm/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/mkmf.rb:276:in `postpone'
from /Users/bm/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/mkmf.rb:692:in `checking_for'
from /Users/bm/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/mkmf.rb:852:in `find_header'
from extconf.rb:31:in `<main>'
Gem files will remain installed in /Users/bm/.rvm/gems/ruby-1.9.2-head#rc_search/gems/pg-0.11.0 for inspection.
Results logged to /Users/bm/.rvm/gems/ruby-1.9.2-head#rc_search/gems/pg-0.11.0/ext/gem_make.out
from /Users/bm/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/rubygems/installer.rb:486:in `block in build_extensions'
from /Users/bm/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/rubygems/installer.rb:446:in `each'
from /Users/bm/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/rubygems/installer.rb:446:in `build_extensions'
from /Users/bm/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/rubygems/installer.rb:198:in `install'
from /Users/bm/.rvm/gems/ruby-1.9.2-head#global/gems/bundler-1.0.0/lib/bundler/source.rb:100:in `install'
from /Users/bm/.rvm/gems/ruby-1.9.2-head#global/gems/bundler-1.0.0/lib/bundler/installer.rb:55:in `block in run'
from /Users/bm/.rvm/gems/ruby-1.9.2-head#global/gems/bundler-1.0.0/lib/bundler/spec_set.rb:12:in `block in each'
from /Users/bm/.rvm/gems/ruby-1.9.2-head#global/gems/bundler-1.0.0/lib/bundler/spec_set.rb:12:in `each'
from /Users/bm/.rvm/gems/ruby-1.9.2-head#global/gems/bundler-1.0.0/lib/bundler/spec_set.rb:12:in `each'
from /Users/bm/.rvm/gems/ruby-1.9.2-head#global/gems/bundler-1.0.0/lib/bundler/installer.rb:44:in `run'
from /Users/bm/.rvm/gems/ruby-1.9.2-head#global/gems/bundler-1.0.0/lib/bundler/installer.rb:8:in `install'
from /Users/bm/.rvm/gems/ruby-1.9.2-head#global/gems/bundler-1.0.0/lib/bundler/cli.rb:217:in `install'
from /Users/bm/.rvm/gems/ruby-1.9.2-head#global/gems/bundler-1.0.0/lib/bundler/vendor/thor/task.rb:22:in `run'
from /Users/bm/.rvm/gems/ruby-1.9.2-head#global/gems/bundler-1.0.0/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
from /Users/bm/.rvm/gems/ruby-1.9.2-head#global/gems/bundler-1.0.0/lib/bundler/vendor/thor.rb:246:in `dispatch'
from /Users/bm/.rvm/gems/ruby-1.9.2-head#global/gems/bundler-1.0.0/lib/bundler/vendor/thor/base.rb:389:in `start'
from /Users/bm/.rvm/gems/ruby-1.9.2-head#global/gems/bundler-1.0.0/bin/bundle:13:in `<top (required)>'
from /Users/bm/.rvm/gems/ruby-1.9.2-head#global/bin/bundle:19:in `load'
from /Users/bm/.rvm/gems/ruby-1.9.2-head#global/bin/bundle:19:in `<main>'
Any help would be immensely appreciated. FYI I also tried building the app with a mysql and essentially got the same stack. So I'm pretty sure I'm missing some sort of developer build tools, but I just don't know which ones. :(
I had the exact same problem when running bundle install in a Rails app. I installed homebrew and then ran
brew install postgresql.
That finally installed postgres correctly and the issue was fixed for me.
export ARCHFLAGS='-arch x86_64'
export PATH=/Library/PostgreSQL/9.1/bin:${PATH}
gem install pg
If you are using the PostgreSQL app on osx, you may need to change path the following (as the location of the binaries and config files changes) instead of the path shown in lesyk's answer:
export PATH=/Applications/Postgres.app/Contents/MacOS/bin:${PATH}
What worked for me was Zag Zag's comment:
~/projects/foo$ env ARCHFLAGS="-arch x86_64" gem install pg
Building native extensions. This could take a while...
Successfully installed pg-0.11.0
1 gem installed
Building YARD (yri) index for pg-0.11.0...
~/projects/foo$ bundle
...
Using pg (0.11.0)
...
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
I had the same issue. For me the fix was:
sudo ln -s gcc /usr/bin/gcc-4.2
I also ran into this issue, for me the answer was updating RVM of all things.
rvm get head
rvm install 1.9.2
I'm on the same OSX and XCode version as you are: bundle install with pg 0.11.0 works fine to me.
However, I found this article that might be able to help you
fixing-the-you-have-to-install-development-tools-first-error-with-nokogiri
If you're using rvm, you can try:
rvm update head
rvm --force install
1.9.2 gem install bundle
Here my stack:
[ 08:36:26 ] > bundle install
Fetching source index for http://rubygems.org/
Enter your password to install the bundled RubyGems to your system:
Using rake (0.8.7)
Using abstract (1.0.0)
Installing activesupport (3.0.7)
Installing builder (2.1.2)
Installing i18n (0.5.0)
Installing activemodel (3.0.7)
Using erubis (2.6.6)
Using rack (1.2.2)
Installing rack-mount (0.6.14)
Installing rack-test (0.5.7)
Installing tzinfo (0.3.27)
Installing actionpack (3.0.7)
Using mime-types (1.16)
Installing polyglot (0.3.1)
Installing treetop (1.4.9)
Installing mail (2.2.19)
Installing actionmailer (3.0.7)
Installing arel (2.0.9)
Installing activerecord (3.0.7)
Installing activeresource (3.0.7)
Using bundler (1.0.10)
Installing pg (0.11.0) with native extensions
Using thor (0.14.6)
Installing railties (3.0.7)
Installing rails (3.0.7)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
[ ronda#MacBook ~/Projects/rails_projects/first_app ]
[ 08:42:57 ] > rails server
=> Booting WEBrick
=> Rails 3.0.7 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-04-27 20:45:27] INFO WEBrick 1.3.1
[2011-04-27 20:45:27] INFO ruby 1.9.2 (2011-02-18) [x86_64-darwin10]
[2011-04-27 20:45:27] INFO WEBrick::HTTPServer#start: pid=4757 port=3000
The simple solution:
run brew install postgresql
install the gem with sudo permissions: like so:
sudo gem install pg -v '0.17.1'
I was stuck on my bundle install for 3 days. Tried Everything like adding env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/usr/local/Cellar/postgresql/9.3.5_1/bin/pg_config
I was able to see pg gem getting installed after this command but still it was not installing from bundle install, which was a pain because I dint know what to write in Gemfile except gem 'pg'
The thing which finally worked for me was to find that my pg_config was in /Library/PostgreSQL/9.3/bin/pg_config and by default the Gemfile bundle install looks in /usr/local/bin/pg_config
I just ran the following command and magic happened. bundle config build.pg --with-pg-config=/Library/PostgreSQL/9.3/bin/pg_config
Some correction. For those who have installed postgres using homebrew.
1) write the following line in your ~/.bash_profile
export ARCHFLAGS="-arch x86_64"
2) restart console
3) execute following command
bundle config build.pg --with-pg-config=/usr/local/Cellar/postgresql/9.3.5_1/bin/pg_config (this has to be your pg config address, can differ for each depending on versions of postgres)
4) Install pg once locally by running this command
sudo env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/usr/local/Cellar/postgresql/9.3.5_1/bin/pg_config
5) bundle install

Resources