I'm new to Ruby (coming from a Java background) and was given access to a RoR project from a Git repository. I was able to get Ruby built with rbenv and Postgres installed via homebrew, installed the "pg" gem using the correct flags. Any ways I did "bundle install" on the project and it created a bundle, when I went to start the server:... any help will be definitely appreciated!
$ rails s
/Users//Projects/The /vendor/bundle/gems/pg-0.14.1/lib/pg.rb:4:in require': cannot load such file -- pg_ext (LoadError)
from /Users//Projects/The Usic/vendor/bundle/gems/pg-0.14.1/lib/pg.rb:4:in <top (required)>'
from /Users//.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/runtime.rb:72:in require'
from /Users//.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/runtime.rb:72:in block (2 levels) in require'
from /Users//.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/runtime.rb:70:in each'
from /Users//.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/runtime.rb:70:in block in require'
from /Users//.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/runtime.rb:59:in each'
from /Users//.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/runtime.rb:59:in require'
from /Users//.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler.rb:132:in require'
Issue also appears in Fedora 17.
Uninstall "pg" gem:
gem uninstall pg
Run bundle (assuming Gemfile contains "pg" gem):
bundle
Add the pg gem to your Gemfile. Then run:
bundle install
bundle update
If during the installation of the gem the pq installation is not in path so it could not be found by the gem. Than the gem would not work correct.
Check the path (try to start psql from commandline).
uninstall the pg-gem: gem unistall pg
and reinstall it: bundle install or gem install pg
I'm curious if you installed the pg gem before or after installing postgres via brew?
If pg was installed before you installed Postgres via brew, you may need to remove it and install it again so that it's compiled against your current version of Postgres.
Side note: postgresapp is a much better alternative to installing postgres via homebrew: http://postgresapp.com/
I've already installed the pg
gem list pg
I also encountered this problem and I made it work.
First, you run the command:
$ gem install pg --pre
Successfully installed pg-0.21.0-x64-mingw32
Next, you update your Gemfile: gem 'pg', '~> 0.21.0'. That's it.
My rubygems environment are as follow:
RubyGems Environment:
- RUBYGEMS VERSION: 2.6.12
- RUBY VERSION: 2.3.3 (2016-11-21 patchlevel 222) [x64-mingw32]
- INSTALLATION DIRECTORY: C:/Ruby23-x64/lib/ruby/gems/2.3.0
- USER INSTALLATION DIRECTORY: C:/Users/armano/.gem/ruby/2.3.0
- RUBY EXECUTABLE: C:/Ruby23-x64/bin/ruby.exe
- EXECUTABLE DIRECTORY: C:/Ruby23-x64/bin
- SPEC CACHE DIRECTORY: C:/Users/armano/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: C:/ProgramData
- RUBYGEMS PLATFORMS:
- ruby
- x64-mingw32
- GEM PATHS:
- C:/Ruby23-x64/lib/ruby/gems/2.3.0
- C:/Users/armano/.gem/ruby/2.3.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-ri --no-rdoc"
- REMOTE SOURCES:
- https://rubygems.org/
Related
I'm getting this error when trying to create a new Rails project:
/Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:126:in require: cannot load such file -- bundler (LoadError)
from /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:126:in rescue in require
from /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in require
from /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.2/lib/rails/generators/app_base.rb:319:in bundle_command
from /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.2/lib/rails/generators/app_base.rb:335:in run_bundle
from (eval):1:in run_bundle
from /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/command.rb:27:in run
from /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in invoke_command
from /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in block in invoke_all
from /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in each
from /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in map
from /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in invoke_all
from /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/group.rb:232:in dispatch
from /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/base.rb:440:in start
from /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.2/lib/rails/commands/application.rb:17:in <top (required)>
from /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:67:in require
from /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:67:in require
from /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.2/lib/rails/cli.rb:14:in <top (required)>
from /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:67:in require
from /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:67:in require
from /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/railties-4.2.2/bin/rails:9:in <top (required)>
from /Users/jameslett/.rbenv/versions/2.2.2/bin/rails:23:in load
from /Users/jameslett/.rbenv/versions/2.2.2/bin/rails:23:in `<main>'
I cd'd into my project and ran bundle install and I got this error:
Errno::EACCES: Permission denied # rb_sysopen - /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.7.1/.autotest
An error occurred while installing nokogiri (1.6.7.1), and Bundler cannot continue. Make sure that gem install nokogiri -v 1.6.7.1 succeeds before bundling.
If I run gem install nokogirl I get the "Errno::EACCES" error again.
I'm not sure what to do to solve this. I read the Bundler and Nokogirl documentation but that hasn't helped.
Just in case, I'm running:
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
My Gem ENV is:
RubyGems Environment:
- RUBYGEMS VERSION: 2.5.1
- RUBY VERSION: 2.2.2 (2015-04-13 patchlevel 95) [x86_64-darwin14]
- INSTALLATION DIRECTORY: /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0
- USER INSTALLATION DIRECTORY: /Users/jameslett/.gem/ruby/2.2.0
- RUBY EXECUTABLE: /Users/jameslett/.rbenv/versions/2.2.2/bin/ruby
- EXECUTABLE DIRECTORY: /Users/jameslett/.rbenv/versions/2.2.2/bin
- SPEC CACHE DIRECTORY: /Users/jameslett/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/jameslett/.rbenv/versions/2.2.2/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-14
- GEM PATHS:
- /Users/jameslett/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0
- /Users/jameslett/.gem/ruby/2.2.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
Is my gem path causing this error?
Make sure you own all the files in the .rbenv folder.
$ sudo chown -R $(whoami) /Users/jameslett/.rbenv
In addition all files should be readable and writable.
$ chmod -R u+rw /Users/jameslett/.rbenv
Permissions may be messed up when combining sudo with the actual user's environment.
You can try this
sudo gem update --system
I cloned a repository and tried to run rails s. However, I received the following error:
/Users/me/.rbenv/versions/1.9.3-p547/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- bundler/setup (LoadError)
from /Users/me/.rbenv/versions/1.9.3-p547/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/me/workspace/bindo/config/boot.rb:7:in `<top (required)>'
from /Users/me/.rbenv/versions/1.9.3-p547/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/me/.rbenv/versions/1.9.3-p547/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from bin/rails:9:in `<main>'
My ruby version is:
ruby 1.9.3p547 (2014-05-14 revision 45962) [x86_64-darwin13.3.0]
My gem env command run from this project directory:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23.2
- RUBY VERSION: 1.9.3 (2014-05-14 patchlevel 547) [x86_64-darwin13.3.0]
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/2.0.0
- RUBY EXECUTABLE: /Users/me/.rbenv/versions/1.9.3-p547/bin/ruby
- EXECUTABLE DIRECTORY: /usr/lib/ruby/gems/2.0.0/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-13
- GEM PATHS:
- /usr/lib/ruby/gems/2.0.0
- /Users/me/.gem/ruby/1.9.1
- /Users/me/.rbenv/versions/1.9.3-p547/lib/ruby/gems/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
I read on Stack Overflow that this is a path error, however, I am not familiar enough to figure out what to trace or change to make this work. I'm looking but I feel I need some direction.
You likely have bundler gem missing.
To get it to work run (first command may need be executed with sudo, depending on your environment):
[sudo] gem install bundler
bundle install
On the mac, it is possible that you installed gems to ./vendor/bundle
in order to avoid to use SUDO.
You can find it if you run gem install bundler and at the end of the output you see the following:
Using turbolinks-source 5.1.0
Using turbolinks 5.1.0
Using uglifier 4.1.4
Bundle complete! 13 Gemfile dependencies, 68 gems now installed.
Bundled gems are installed into `./vendor/bundle`
If this is the case than in your app root directory delete the bundle directory.
After this run the following commands:
[sudo] gem install bundler
bundle install
It solved the problem for me
I'm new to Ruby (coming from a Java background) and was given access to a RoR project from a Git repository. I was able to get Ruby built with rbenv and Postgres installed via homebrew, installed the "pg" gem using the correct flags. Any ways I did "bundle install" on the project and it created a bundle, when I went to start the server:... any help will be definitely appreciated!
$ rails s
/Users//Projects/The /vendor/bundle/gems/pg-0.14.1/lib/pg.rb:4:in require': cannot load such file -- pg_ext (LoadError)
from /Users//Projects/The Usic/vendor/bundle/gems/pg-0.14.1/lib/pg.rb:4:in <top (required)>'
from /Users//.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/runtime.rb:72:in require'
from /Users//.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/runtime.rb:72:in block (2 levels) in require'
from /Users//.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/runtime.rb:70:in each'
from /Users//.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/runtime.rb:70:in block in require'
from /Users//.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/runtime.rb:59:in each'
from /Users//.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/runtime.rb:59:in require'
from /Users//.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler.rb:132:in require'
Issue also appears in Fedora 17.
Uninstall "pg" gem:
gem uninstall pg
Run bundle (assuming Gemfile contains "pg" gem):
bundle
Add the pg gem to your Gemfile. Then run:
bundle install
bundle update
If during the installation of the gem the pq installation is not in path so it could not be found by the gem. Than the gem would not work correct.
Check the path (try to start psql from commandline).
uninstall the pg-gem: gem unistall pg
and reinstall it: bundle install or gem install pg
I'm curious if you installed the pg gem before or after installing postgres via brew?
If pg was installed before you installed Postgres via brew, you may need to remove it and install it again so that it's compiled against your current version of Postgres.
Side note: postgresapp is a much better alternative to installing postgres via homebrew: http://postgresapp.com/
I've already installed the pg
gem list pg
I also encountered this problem and I made it work.
First, you run the command:
$ gem install pg --pre
Successfully installed pg-0.21.0-x64-mingw32
Next, you update your Gemfile: gem 'pg', '~> 0.21.0'. That's it.
My rubygems environment are as follow:
RubyGems Environment:
- RUBYGEMS VERSION: 2.6.12
- RUBY VERSION: 2.3.3 (2016-11-21 patchlevel 222) [x64-mingw32]
- INSTALLATION DIRECTORY: C:/Ruby23-x64/lib/ruby/gems/2.3.0
- USER INSTALLATION DIRECTORY: C:/Users/armano/.gem/ruby/2.3.0
- RUBY EXECUTABLE: C:/Ruby23-x64/bin/ruby.exe
- EXECUTABLE DIRECTORY: C:/Ruby23-x64/bin
- SPEC CACHE DIRECTORY: C:/Users/armano/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: C:/ProgramData
- RUBYGEMS PLATFORMS:
- ruby
- x64-mingw32
- GEM PATHS:
- C:/Ruby23-x64/lib/ruby/gems/2.3.0
- C:/Users/armano/.gem/ruby/2.3.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-ri --no-rdoc"
- REMOTE SOURCES:
- https://rubygems.org/
My problem is summarized in the following lines:
Joses-MacBook-Pro:~ jose$ cd Estate/
Using /Users/jose/.rvm/gems/ruby-1.9.2-p290 with gemset realstate
Joses-MacBook-Pro:Estate jose$ bundle
ERROR: Gem bundler is not installed, run `gem install bundler` first.
Joses-MacBook-Pro:Estate jose$ gem install bundler
Successfully installed bundler-1.2.1
1 gem installed
Installing ri documentation for bundler-1.2.1...
Installing RDoc documentation for bundler-1.2.1...
Joses-MacBook-Pro:Estate jose$ bundle
ERROR: Gem bundler is not installed, run `gem install bundler` first.
Joses-MacBook-Pro:Estate jose$
Here's the output for my Gem Env:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.24
- RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [x86_64-darwin12.1.0]
- INSTALLATION DIRECTORY: /Users/jose/.rvm/gems/ruby-1.9.3-p194
- RUBY EXECUTABLE: /Users/jose/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
- EXECUTABLE DIRECTORY: /Users/jose/.rvm/gems/ruby-1.9.3-p194/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-12
- GEM PATHS:
- /Users/jose/.rvm/gems/ruby-1.9.3-p194
- /Users/jose/.rvm/gems/ruby-1.9.3-p194#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
I've tried to solve this problem by using many answers I've seen around here, like:
Ruby: "gem install bundler" not installing bundler
But unfortunately so far I've not been able to solve the problem, I hope somebody can help me out figuring this out. I'm a Mac OS X newcomer.
Thanks in advance !
EDIT:
which bundle:
Joses-MacBook-Pro:Estate jose$ which bundle
/Users/jose/.rvm/bin/bundle
$(which bundle)
which gem, etc
Joses-MacBook-Pro:Estate jose$ which gem || type gem | head -n 1
/Users/jose/.rvm/bin/gem
Joses-MacBook-ProEstate jose$ hash -r
Joses-MacBook-Pro:Estate jose$
you need to explicitly use ruby:
rvm use 1.9.3
When I tries to install rails:
root#li44-48:/# gem install rails
Successfully installed rails-3.2.1
1 gem installed
Installing ri documentation for rails-3.2.1...
Installing RDoc documentation for rails-3.2.1...
But when I do:
root#li44-48:/# rails
-bash: rails: command not found
I checked gem env and it displays:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.15
- RUBY VERSION: 1.9.3 (2011-10-30 patchlevel 0) [i686-linux]
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /usr/lib/ruby/gems/1.9.1
- /root/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Also the folder root#li44-48:/usr/lib/ruby/gems/1.9.1/gems/rails-3.2.1# is empty.
Any ideas on how to fix this?
I had the same issue after switching to an older version of Rails (3.2.16) from 4.0.2.
In my case it looks like railties need to be uninstalled as well - not just the rails gem.
Here's what I've done:
gem uninstall rails # choose to remove all
gem uninstall railties # choose to remove all
gem install rails -v 3.2.16
This happened to me after I uninstalled an old version of rails, and it asked me if I wanted to remove the binary too (which I did).
The newer rails binary is hidden under
/var/lib/gems/1.9.1/gems/railties-3.2.13/bin/rails
(on Ubuntu)
So I just created the symlink (not sure if this has negative side affects but it seems to work):
sudo ln -s /var/lib/gems/1.9.1/gems/railties-3.2.13/bin/rails /usr/local/bin
In an effort of rage quit, I:
removed ruby
removed gem
and recompiled both from source, and now gem install rails is fully working again.
I had the same issue and ended up using the RVM installer. This post http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/ shows you how and why use this tool.
check that rvm is a function type rvm | head -1
Try installing with:
sudo gem install rails
If you are running RVM you may not have it configured properly.