Rbenv/bundle issue - gems not found in Rack - ruby

I made the switch from RVM to rbenv and it's plugins. My Gemfile is fine, but when I do bundle install, rbenv rehash etc. and run rack <whatever> it doesn't find any of the gems. See below. Anyone have any thoughts?
Vanessas-MacBook-Pro:my-app vanessa$ rbenv versions
* 1.8.7-p352 (set by RBENV_VERSION environment variable)
1.9.2-p290
1.9.3-rc1
rbx-1.2.4
Vanessas-MacBook-Pro:my-app vanessa$ rbenv version
1.8.7-p352 (set by RBENV_VERSION environment variable)
Vanessas-MacBook-Pro:my-app vanessa$ more Gemfile
source 'http://rubygems.org'
gem "sinatra"
gem "god"
gem "rack", '1.2.3'
gem "activemodel", "~>3.0"
group :test do
gem "rake"
end
Vanessas-MacBook-Pro:my-app vanessa$ gem list
*** LOCAL GEMS ***
bundler (1.0.21)
rake (0.9.2.2)
redgreen (1.2.2)
rubygems-update (1.8.11)
Vanessas-MacBook-Pro:my-app vanessa$ rake test
/Users/vanessa/.rbenv/versions/1.8.7-p352/bin/ruby -I"lib:lib:test" -I"/Users/vanessa/.rbenv/versions/1.8.7-p352/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib" "/Users/vanessa/.rbenv/versions/1.8.7-p352/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb" "test/**/test_*.rb"
/Users/vanessa/.rbenv/versions/1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require': no such file to load -- rack/test (LoadError)
from /Users/vanessa/.rbenv/versions/1.8.7-p352/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
...
...
rake aborted!
Command failed with status (1): [/Users/vanessa/.rbenv/versions/1.8.7-p352/bin/...]
Tasks: TOP => test
(See full trace by running task with --trace)
Vanessas-MacBook-Pro:my-app vanessa$

use bundle exec
bundle exec rake test

Try adding 'rack-test' to your Gemfile.

Related

Requiring pry gem into ruby script causes error

I am using ruby version 2.3.3p222
Here is my Gemfile:
# Gemfile
source 'https://rubygems.org'
gem 'pry'
I run bundle and here is the resulting Gemfile.lock
Gemfile.lock
GEM
remote: https://rubygems.org/
specs:
coderay (1.1.2)
method_source (0.9.2)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
PLATFORMS
ruby
DEPENDENCIES
pry
BUNDLED WITH
1.15.1
I then simply run a ruby script via ruby my_report.rb (this script is located in the same directory as Gemfile and Gemfile.lock). my_report.rb only has this in the file:
require 'pry'
Here is the error:
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
/Users/<user>/.rvm/gems/ruby-2.3.3/gems/pry-rescue-1.4.5/lib/pry-rescue.rb:15: warning: method BaseHelpers#windows? is deprecated. Use Pry:Helpers::Platform.windows? instead
/Users/<user>/.rvm/gems/ruby-2.3.3/gems/pry-stack_explorer-0.4.9.2/lib/pry-stack_explorer.rb:128:in `<top (required)>': undefined method `before_command' for #<Pry::CommandSet:0x007fccdcf0b1e8> (NoMethodError)
Question: What am I missing? How can I properly require in pry into my ruby script so that I can set breakpoints?
What eventually worked for me is I just uninstalled all of the pry versions I had installed via gem uninstall. Then: in my gemfile I specified a previous version of 0.11.3:
# Gemfile
source 'https://rubygems.org'
gem 'pry', '0.11.3'
I did bundle install and then ran my ruby script, and that worked for me.

Sinatra Error: Unable to activate sinatra-contrib-1.4.2

Trying to run a Sinatra app and I keep getting this error:
/Users/matthewsmith/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/specification.rb:2064:in `raise_if_conflicts':
Unable to activate sinatra-contrib-1.4.2, because tilt-2.0.1 conflicts with tilt (~> 1.3) (Gem::LoadError)
from /Users/matthewsmith/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/specification.rb:1262:in `activate'
from /Users/matthewsmith/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems.rb:196:in `rescue in try_activate'
from /Users/matthewsmith/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems.rb:193:in `try_activate'
from /Users/matthewsmith/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:132:in `rescue in require'
from /Users/matthewsmith/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in `require'
from app.rb:3:in `<main>'
This is my Gemfile:
gem 'sinatra', '~> 1.4.5'
gem 'activerecord'
gem 'pg'
I tried including
gem 'tilt', '~> 1.3'
in the Gemfile as well but that didn't work.
Any ideas?
I had the same problem. I removed Tilt 2.0.1 and my application works as expected.
Remove gem:
$ gem uninstall tilt -v 2.0.1
Successfully uninstalled tilt-2.0.1
$ bundle install
Resolving dependencies...
...
Bundle complete! 9 Gemfile dependencies, 17 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
Restarted application (via Pow):
~/app-dir$ touch tmp/restart.txt
Specifying this in my Gemfile:
gem 'sinatra-contrib', github: 'sinatra/sinatra-contrib'
and running
bundle update
fixed it for me.

custom_require.rb load error in eventmachine installation

I'm having a problem with my gems dependencies: the content of the Gemfile is
source :gemcutter
gem "sinatra"
gem "koala"
gem "json", "1.5.5"
gem "httparty"
gem "thin"
gem "rack", "1.3.10"
And a bundle install hit me with this error
$ sudo bundle install
The source :gemcutter is deprecated because HTTP requests are insecure.
Please change your source to 'https://rubygems.org' if possible, or 'http://rubygems.org' if not.
Fetching gem metadata from http://rubygems.org/.......
Fetching gem metadata from http://rubygems.org/..
Using addressable (2.2.7)
Using crack (0.1.8)
Using daemons (1.1.3)
Installing eventmachine (0.12.10)
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 /var/lib/gems/1.9.1/gems/eventmachine-0.12.10 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/eventmachine-0.12.10/ext/gem_make.out
An error occurred while installing eventmachine (0.12.10), and Bundler cannot continue.
Make sure that `gem install eventmachine -v '0.12.10'` succeeds before bundling.
However, I do have eventmachine installed!:
$ gem list
*** LOCAL GEMS ***
eventmachine (1.0.3, 1.0.0.rc.4, 0.12.10)
Help me, you're my only hope! Thank you.
ruby 1.9.1 had some issues with C extensions. Try to check if you have mkmf:
locate mkmf
or install dev version of ruby 1.9.1:
sudo apt-get install ruby1.9.1-dev
I recommend to use RVM for installing rubies: https://rvm.io/
You can also try to change source in your Gemfile
source 'https://rubygems.org'
instead of :gemcutter

rake aborted! undefined method `setup' for ActiveAdmin:Module

I have installed active admin on my development machine and it works fine.
But when i run heroku run rake db:migrate it gives me following error
rake aborted! undefined method `setup' for ActiveAdmin:Module
here is my gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.6'
gem 'pg'
gem 'haml'
gem 'haml-rails'
gem 'sorcery'#, "~> 0.7.12"
gem 'jquery-rails'
gem 'localeapp'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem "activeadmin", :git => "git://github.com/gregbell/active_admin.git"
gem 'sass-rails'#, '~> 3.2.5'
gem 'coffee-rails'#, '~> 3.2.2'
gem 'twitter-bootstrap-rails'
gem 'uglifier'
end
group :production do
gem 'thin'
end
gem "activeadmin", :git => "git://github.com/gregbell/active_admin.git"
Don't declare active admin under any group.
Atleast it wont work in production environment.
For the record, I wanted to try activeadmin-cms 0.1.0 and I had the same problem.
The gem activeadmin-cms is not compatible with activeadmin 0.6.0 (I have not tested other version of activeadmin)

Ruby Bundler Permission issue

So, I'm positive I once did a sudo bundle install out of desperation, which I now understand is a no-no. But now, when i try to run bundle install, I get the following error:
Installing culerity (0.2.12) /Library/Ruby/Site/1.8/rubygems/installer.rb:294:in `generate_bin': You don't have write permissions into the /Library/Ruby/Gems/1.8/bin directory. (Gem::FilePermissionError)
from /Library/Ruby/Site/1.8/rubygems/installer.rb:196:in `install'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0.rc.6/lib/bundler/source.rb:100:in `install'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0.rc.6/lib/bundler/installer.rb:55:in `run'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0.rc.6/lib/bundler/spec_set.rb:12:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0.rc.6/lib/bundler/spec_set.rb:12:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0.rc.6/lib/bundler/installer.rb:44:in `run'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0.rc.6/lib/bundler/installer.rb:8:in `install'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0.rc.6/lib/bundler/cli.rb:217:in `install'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0.rc.6/lib/bundler/vendor/thor/task.rb:22:in `send'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0.rc.6/lib/bundler/vendor/thor/task.rb:22:in `run'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0.rc.6/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0.rc.6/lib/bundler/vendor/thor.rb:246:in `dispatch'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0.rc.6/lib/bundler/vendor/thor/base.rb:389:in `start'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0.rc.6/bin/bundle:13
from /usr/bin/bundle:19:in `load'
from /usr/bin/bundle:19
I've tried removeing everything in ~/.bundle ~/.gem .bundle Gemfile.lock as well as any reference to culerity or capybara in /Library/Ruby (OSX 10.6). I also checked to make sure permissions were set correctly (not root) on all my files in this project. I also cleared the gem cache.
My Gemfile:
source 'http://rubygems.org'
gem 'rails', '3.0.0.rc2'
# Bundle edge Rails instead:
#gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'pg'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
gem 'ruby-debug'
# Bundle the extra gems:
# gem 'bj'
# gem 'nokogiri', '1.4.1'
# gem 'sqlite3-ruby', :require => 'sqlite3'
# gem 'aws-s3', :require => 'aws/s3'
# Bundle gems for certain environments:
# gem 'rspec', :group => :test
# group :test do
# gem 'webrat'
# end
gem 'haml', '3.0.15'
gem 'mogli', '0.0.13' #, :path => "~/Sites/mogli"
gem 'facebooker2', '0.0.4'
gem 'geokit'
gem 'acts_as_restful_list'
gem 'hoptoad_notifier'
group :development, :test do
gem "rspec-rails", '2.0.0.beta.19'
gem 'factory_girl_rails'
gem 'capybara', '0.3.9'
gem 'database_cleaner'
gem 'cucumber-rails', '0.3.2'
gem 'cucumber', '0.8.5'
gem 'spork'
gem 'launchy' # So you can do Then show me the page
end
Also, I have rvm on my system, but I'm using the system ruby for this project.
Any ideas on what's causing the permission issue? Surely, I'm not stuck using sudo bundle install.
Thanks.
It look like you are using the system's ruby. You have a few options:
use sudo to install your bundle system wide. it could be a problem with conflicting gems from different applications.
use bundle install --path bundle_dir, which is going to install the gems in bundle_dir
use rvm (http://rvm.beginrescueend.com), this program will allow you to use different ruby versions, and different gem sets.
Try to touch a file in the particular path. I guess OS X is protecting these directories a bit more than just the normal way? I think OS X supports ACL's with their filesystem, maybe you have to look there?
maybe try using chmod on everything, but looks like you'll need to run it as sudo...not sure why that's not an option...

Resources