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...
Related
I am having an issue where images on my Heroku production site are not being found. I have tracked it down to the digest being different in the file system from what it is looking for in the app. For example, in the logs I see the following errors:
app[web.1]: Started GET "/assets/nfl_teams/nfcn/chi-6317d0375db3876a5057f2da59bab1dc.jpeg" for 24.55.52.101 at 2016-09-08 23:10:18 +0000
app[web.1]: ActionController::RoutingError (No route matches [GET] "/assets/nfl_teams/nfcn/chi-6317d0375db3876a5057f2da59bab1dc.jpeg"):
app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
app[web.1]: vendor/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/rack/logger.rb:38:in `call_app'
And when I go to the Heroku console and look up the asset using asset_path() I get the following:
$ heroku run rails console
Running rails console on ⬢ fbpm... up, run.7463
Loading production environment (Rails 4.2.5)
irb(main):001:0> puts helper.asset_path("nfl_teams/nfcn/chi.jpg")
/assets/nfl_teams/nfcn/chi-93d8c8c53ac98c60f7f3fee1fade067dfa9489b24b8fa4bb9fedd4b12da129de.jpg
=> nil
irb(main):002:0>
and finally looking at the heroku bash and checking the file in the directory I get:
$ heroku run bash
Running bash on ⬢ fbpm... up, run.7321
cd public~ $ cd public/assets/nfl_teams/nfcn
~/public/assets/nfl_teams/nfcn $ ls chi*.jpg
chi-93d8c8c53ac98c60f7f3fee1fade067dfa9489b24b8fa4bb9fedd4b12da129de.jpg
~/public/assets/nfl_teams/nfcn $
So, in the console looking at the asset path I get the following file:
/assets/nfl_teams/nfcn/chi-93d8c8c53ac98c60f7f3fee1fade067dfa9489b24b8fa4bb9fedd4b12da129de.jpg
And I get the same file when I look in the directory structure. Yet for some reason the application is looking for this file:
/assets/nfl_teams/nfcn/chi-6317d0375db3876a5057f2da59bab1dc.jpeg
Which doesn't exist and throws a routing error.
Here is my Gemfile:
source 'https://rubygems.org'
ruby '2.2.4'
#ruby-gemset=Rails_fb
gem 'rails','4.2.5'
gem 'bcrypt', '3.1.11'
gem 'annotate'
gem 'faker', '1.6.3'
gem 'select2-rails'
gem 'simple_form', '3.1.1'
gem 'cocoon'
#
# Bootstrap support gems
#
gem 'bootstrap-sass'
gem 'bootstrap-will_paginate', '0.0.10'
gem 'font-awesome-sass', '4.6.2'
gem 'font-awesome-rails'
gem 'sass-rails', '~> 5.0.4'
#gem 'select2-sass-bootstrap-rails'
# The following Gem is used to parse the NFL page for schedules to build
# a season.
gem 'nokogiri'
# Database. Using the same database for production/development
gem 'pg'
group :development, :test do
gem 'rspec-rails', '~>3.0'
gem 'factory_girl_rails', '4.7.0'
gem 'capybara', '2.7.1'
gem 'database_cleaner'
gem 'guard-rspec', '~> 4.2'
gem 'spork-rails'
gem 'guard-spork'
gem 'childprocess', '0.5.8'
gem 'letter_opener_web', '~>1.2.0'
end
group :test do
gem 'pry'
gem 'selenium-webdriver', '2.53.0'
gem 'libnotify', '0.9.1'
end
gem 'uglifier', '2.7.2'
gem 'coffee-rails', '4.1.1'
gem 'jquery-rails', '3.1.4'
gem 'jquery-turbolinks', '2.1.0'
gem 'turbolinks', '2.5.3'
gem 'jbuilder', '2.4.1'
group :doc do
gem 'sdoc', '0.4.1', require: false
end
group :production do
gem 'rails_12factor'
end
# To use debugger
# gem 'debugger'
gem 'execjs'
gem 'therubyracer', :platforms => :ruby
And here is the code I'm using to access the images in my views(I've tried it both with and without the asset_path() call):
<%= image_tag(asset_path(team.imagePath), size: "40") %>
Can anyone tell me why the app is looking for the wrong file? Obviously there is some disconnect in the asset pipeline but I can't figure where?
And this problem started after I upgraded from Ruby 2.0.0 to Ruby 2.2.4 which caused me to update a number of my Gems.
Hopefully this helps. In order to force a new precompile of assets on Heroku in Rails 4 you need to do the following:
rake assets:clobber
Rake assets:precompile
Then git commit/push to master and push to Heroku and it should do a new precompile that hopefully will sync up the asset pipeline. Don't use rake assets:clean as it doesn't force a new compile.
I am having a problem with pushing my rails project back up to heroku. I was able to do this a few days ago. I made a few changes to my files and tried to re push using git push heroku. It starts the process then gives me these errors.
> Counting objects: 56, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (35/35), done.
Writing objects: 100% (37/37), 3.96 KiB, done.
Total 37 (delta 18), reused 0 (delta 0)
`-----> Heroku receiving push
-----> Ruby/Rails app detected
-----> Detected Rails is not set to serve static_assets
Installing rails3_serve_static_assets... done
-----> Configure Rails 3 to disable x-sendfile
Installing rails3_disable_x_sendfile... done
-----> Configure Rails to log to stdout
Installing rails_log_stdout... done
-----> Gemfile detected, running Bundler version 1.0.7
Unresolved dependencies detected; Installing...
Using --without development:test
Fetching source index for https://rubygems.org/
Installing rake (0.9.2.2)
Installing ZenTest (4.7.0) /usr/ruby1.9.2/lib/ruby/1.9.1/rubygems/installer.rb:170:in `install': ZenTest requires RubyG
ems version ~> 1.8. Try 'gem update --system' to update RubyGems itself. (Gem::InstallError)
from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/source.rb:95:in `install'
from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/installer.rb:55:in `block in run'
from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/spec_set.rb:12:in `block in each'
from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/spec_set.rb:12:in `each'
from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/spec_set.rb:12:in `each'
from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/installer.rb:44:in `run'
from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/installer.rb:8:in `install'
from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/cli.rb:225:in `install'
from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/vendor/thor/task.rb:22:in `run'
from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/vendor/thor.rb:246:in `dispatch'
from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/vendor/thor/base.rb:389:in `start'
from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/bin/bundle:13:in `<top (required)>'
from /usr/ruby1.9.2/bin/bundle:19:in `load'
from /usr/ruby1.9.2/bin/bundle:19:in `<main>'
FAILED: http://devcenter.heroku.com/articles/bundler
! Heroku push rejected, failed to install gems via Bundler
`To git#heroku.com:mbartonsampleapp.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#heroku.com:mbartonsampleapp.git'
My Gem fils has
source 'https://rubygems.org'
gem 'rails', '3.2.3'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'heroku'
group :development do
gem "ZenTest", "~> 4.7.0"
gem 'sqlite3'
gem 'autotest', '4.4.6'
gem 'rspec-rails', '2.9.0'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
group :production do
# gems specifically for Heroku go here
gem 'pg'
end
group :test do
gem 'autotest', '4.4.6'
gem 'rspec-rails', '2.9.0'
gem 'webrat', '0.7.3'
gem "spork", '0.9.0'
end
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer', :platform => :ruby
gem 'execjs'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
Your Gemfile looks a bit messed up: the assets group isn’t closed (it’s missing an end), so your production and test groups are nested in it (there’s an extra end after gem 'uglifier' that eventually closes it).
This could be confusing Bundler, so that it doesn’t see ZenTest as being in the development group and tries to install it on Heroku.
.rvm/gems/ruby-1.9.3-head/gems/bundler-1.0.21/lib/bundler/runtime.rb:31:in `block in setup': You have already activated rack 1.4.0,
but your Gemfile requires rack 1.2.5. Using bundle exec may solve this. (Gem::LoadError)
Is the error that I get when I try to run thin start , bundle exec thin, rails s on any of my apps. I have tried running system level and app level bundle updates/ installs, removing gemfile.lock and updating again. Sudo level installs. Nothing.
Any advice?
This is my gemfile:
source 'http://rubygems.org'
gem 'rails', '3.0.10'
gem 'rake', '0.8.7'
gem 'jquery-rails', '0.2.6'
gem 'pg', :require => 'pg'
gem 'devise'
gem 'nifty-generators'
gem 'mocha'
gem 'thin'
gem 'omniauth'
require 'oauth2'
gem 'fb_graph'
gem 'nokogiri'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'gravatar_image_tag', '1.0.0.pre2'
gem 'will_paginate', '3.0.pre2'
group :development do
gem 'rspec-rails', '2.5.0'
gem 'faker', '0.9.5'
end
group :test do
gem 'rspec', '2.5.0'
gem 'webrat', '0.7.1'
gem 'spork', '0.9.0.rc5'
gem 'factory_girl_rails', '1.0'
end
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
# gem 'ruby-debug'
# gem 'ruby-debug19', :require => 'ruby-debug'
# Bundle the extra gems:
# gem 'bj'
# gem 'nokogiri'
# gem 'aws-s3', :require => 'aws/s3'
# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
# group :development, :test do
# gem 'webrat'
# end
You can try adding an .rvmrc in your project root with this content:
rvm ruby-1.9.3-head#your-project-name
After that, restart your console session. RVM will ask for permission to use the file. After that, your project will run under it's own gemspace. Run bundle again, and it will install only the required gems.
After my upgrade to Rails 3.1.3 and Ruby 1.9.3 (via RVM) i can't normally run autotest. I don't know what has happened, but when i print:
$ autotest
It shows strange error
loading autotest/rails_rspec2
/Users/serg/.rvm/rubies/ruby-1.9.3-head/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require': cannot load such file -- autotest/fsevent (LoadError)
from /Users/serg/.rvm/rubies/ruby-1.9.3-head/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from /Users/serg/rails_projects_terminal/sample_app/.autotest:2:in `<top (required)>'
from /Users/serg/.rvm/gems/ruby-1.9.3-head#global/gems/ZenTest-4.6.2/lib/autotest.rb:315:in `load'
from /Users/serg/.rvm/gems/ruby-1.9.3-head#global/gems/ZenTest-4.6.2/lib/autotest.rb:315:in `block in initialize'
from /Users/serg/.rvm/gems/ruby-1.9.3-head#global/gems/ZenTest-4.6.2/lib/autotest.rb:314:in `each'
from /Users/serg/.rvm/gems/ruby-1.9.3-head#global/gems/ZenTest-4.6.2/lib/autotest.rb:314:in `initialize'
from /Users/serg/.rvm/gems/ruby-1.9.3-head/gems/rspec-core-2.8.0/lib/autotest/rspec2.rb:13:in `initialize'
from /Users/serg/.rvm/gems/ruby-1.9.3-head/gems/rspec-rails-2.8.0/lib/autotest/rails_rspec2.rb:31:in `initialize'
from /Users/serg/.rvm/gems/ruby-1.9.3-head#global/gems/ZenTest-4.6.2/lib/autotest.rb:244:in `new'
from /Users/serg/.rvm/gems/ruby-1.9.3-head#global/gems/ZenTest-4.6.2/lib/autotest.rb:244:in `run'
from /Users/serg/.rvm/gems/ruby-1.9.3-head#global/gems/ZenTest-4.6.2/bin/autotest:6:in `<top (required)>'
from /Users/serg/.rvm/gems/ruby-1.9.3-head#global/bin/autotest:19:in `load'
from /Users/serg/.rvm/gems/ruby-1.9.3-head#global/bin/autotest:19:in `<main>'
But when i try:
bundle exec autotest
It works. How can i fix it?
My gemfile:
source 'http://rubygems.org'
gem 'rails', '3.1.3'
gem 'gravatar_image_tag'
gem 'will_paginate'
gem 'rack'
gem 'texticle', "2.0", :require => 'texticle/rails'
group :assets do
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier'
end
gem 'jquery-rails'
group :development do
gem 'rspec-rails'
gem 'therubyracer-heroku'
gem 'pg'
gem 'annotate', :git => 'git://github.com/ctran/annotate_models.git'
gem 'faker'
end
group :test do
gem 'rspec-rails'
gem 'webrat'
gem 'spork'
gem 'autotest'
gem 'autotest-rails-pure'
gem 'autotest-fsevent'
gem 'autotest-growl'
gem 'factory_girl_rails'
end
group :production do
gem 'pg'
end
I had that issue as well, and to fix it I had to do what you did :
$ gem update ZenTest
$ gem cleanup ZenTest
$ gem install autotest-fsevent
But I also had to add 'autotest-growl' and 'autotest-fsevent' to my gemfile, which now looks like this:
group :development do
gem 'sqlite3'
gem 'rspec-rails'
gem 'autotest'
gem 'ZenTest'
gem 'autotest-growl'
gem 'autotest-fsevent'
end
Then
$ Bundle install
And now
$ autotest
works just fine :)
I solved it. I found this page: http://www.viget.com/extend/how-why-to-run-autotest-on-your-mac/
and then i printed in the Terminal:
$ gem update ZenTest
$ gem cleanup ZenTest
$ gem install autotest-fsevent
After that autotest started to work fine.
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.