New Rails application bundler/setup (LoadError) - ruby-on-rails

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

Related

No such file to load / Missing these required gems

I have an issue with a "missing gem".
After executing rake gems:install
>> rake gems:install
(in /some/path)
gem install google-api-client --version "= 0.7.1"
Successfully installed uuidtools-2.1.5
Successfully installed google-api-client-0.7.1
2 gems installed
Installing ri documentation for uuidtools-2.1.5...
Installing ri documentation for google-api-client-0.7.1...
Installing RDoc documentation for uuidtools-2.1.5...
Installing RDoc documentation for google-api-client-0.7.1...
Where we can see with a gem list the presence of the gem
>> gem list | grep google
google-api-client (0.7.1)
When starting my rail app I get a :
Missing these required gems:
google-api-client
You're running:
ruby 1.8.7.302 at /usr/bin/ruby1.8
rubygems 1.3.7 at /some/path/.gem/ruby/1.8, /usr/lib/ruby/gems/1.8
and then Rails advices me to execute a "rake gems:install" to solve the issue..
I only have a single version of ruby installed : ruby 1.8.7-p302
>> which ruby
/usr/bin/ruby
>> ls -l /usr/bin/ruby
lrwxrwxrwx 1 root root 7 Aug 26 2013 /usr/bin/ruby -> ruby1.8
>> ruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux]
>> gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/lib/ruby/gems/1.8
- /root/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
I don't know where does the issue come from.
(Similarly, if I just make a ruby test file
require "rubygems"
require "google-api-client"
It outputs the same error :
>> ruby test.rb
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- google-api-client (LoadError)
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from test.rb:2
)
EDIT : I don't use bundle on this app.
Do you have some clue to solve this ?
Thanks !
Well, it was just the require that was erroneous
require "google/api_client"
instead of
require "google-api-client"
Thanks for the help.
You will update bundle version and then update gem.

Using PG in ruby on rails on windows [duplicate]

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/

bundler/setup (LoadError)

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

Can't bundle gems with capistrano and rbenv

I use capistrano to deploy rails app. I have set up rbenv and using capistrano-rbenv in my deploy.rbfile
Error message when deploying:
Could not find rake-10.1.0 in any of the sources
Run `bundle install` to install missing gems.
On server when I run bundle install I get Could not locate Gemfile
$ gem env returns
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23
- RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [x86_64-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.9.1
- RUBY EXECUTABLE: /usr/bin/ruby1.9.1
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/1.9.1
- /home/deployer/.gem/ruby/1.9.1
- /usr/share/rubygems-integration/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
You should confirm that rake 10.1 is on the server through ssh login. It is a dependency to your process.
Rake is a gem like any other, so on the server run
gem install rake -v=10.1.0
if gem which returns nothing, then you need to first install rubygems, e.g.
apt-get install rubygems
Ensure that apt-get properly configures your PATH. You may need to re-source your .bash_profile (or whichever for your shell — or login again to get a new shell
I will update this answer if more details emerge.
I ended up removing the capistrano-rbenvgem and it finally worked out.
If you are requiring capistrano/bundler in your Capfile, be sure to specify the gemfile location in your deploy.rb:
# setup bundler
set :bundle_gemfile, -> { release_path.join('Gemfile') }
See: https://github.com/capistrano/bundler

Ruby/PgSQL error on Rails start : cannot load such file -- pg_ext (LoadError)

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/

Resources