1

After completing the Rails Tutorial I wanted to extend it into a personal app so I created another directory and moved/copied all the files from tutorialFolder to appFolder.

However I'm encountering some problems when I try to setup the gems again.

bundle install returns:

An error occurred while installing pg (0.17.1), and Bundler cannot continue. 
Make sure that `gem install pg -v '0.17.1'` succeeds before bundling.

So I try gem install pg -v '0.17.1 (or bundle update) and get:

You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

Searching StackOverflow I discover Installing gem or updating RubyGems fails with permissions error

Which explains that /Library/Ruby/Gems/2.0.0

That is the version of Ruby installed by Apple, for their own use. While it's OK to make minor modifications to that if you know what you're doing, because you are not sure about the permissions problem, I'd say it's not a good idea to continue along that track.

To avoid the above I try brew install ruby succesfully but get stuck on bundle install

I can't retrace where, but I also attempted to remove the Gemfile.lock but that didn't do anything.

Additional info: ruby -v >>> ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]

rails -v >>> bin/spring:10:in 'read': No such file or directory - /Gemfile.lock (Errno::ENOENT)

bundle install --path vendor/bundle >>> An error occurred while installing pg (0.17.1), and Bundler cannot continue.

Thanks,

Edit* I tried starting from scratch with rails new app however got this:

Bundle complete! 12 Gemfile dependencies, 54 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
run  bundle exec spring binstub --all
/Library/Ruby/Gems/2.0.0/gems/bundler-         1.10.5/lib/bundler/spec_set.rb:92:in `block in materialize': Could not find  i18n-0.7.0 in any of the sources (Bundler::GemNotFound)
from /Library/Ruby/Gems/2.0.0/gems/bundler-  1.10.5/lib/bundler/spec_set.rb:85:in `map!'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.10.5/lib/bundler/spec_set.rb:85:in `materialize'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.10.5/lib/bundler/definition.rb:140:in `specs'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.10.5/lib/bundler/definition.rb:185:in `specs_for'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.10.5/lib/bundler/definition.rb:174:in `requested_specs'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.10.5/lib/bundler/environment.rb:18:in `requested_specs'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.10.5/lib/bundler/runtime.rb:13:in `setup'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.10.5/lib/bundler.rb:127:in `setup'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.10.5/lib/bundler/setup.rb:18:in `<top (required)>'
from /usr/local/Cellar/ruby/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/Cellar/ruby/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'

The above block was fixed with rvm gemset empty and then I was able to setup a VANILLA rails app, still can't sync with end of tutorial

Community
  • 1
  • 1
Alexei Darmin
  • 2,079
  • 1
  • 18
  • 30

2 Answers2

0

It sounds like you tried to create a copy of a rails app by just copying over all of the files. I would do

rails new appFolder

To create a new directory with a rails setup, then just copy over all of your files from tutorialFolder to replace the files in appFolder.

Beartech
  • 6,173
  • 1
  • 18
  • 41
  • Just tried this, no luck. Got `Could not find pg-0.17.1 in any of the sources` and when I tried to install it I got my original error. – Alexei Darmin Jul 19 '15 at 14:29
  • I suspect this failed because I did a `hard reset` on git and deleted the local files (aka stuff generated by running `rails new appFolder` so i'm trying to find a way to pull/overwrite local files without deleting the necessary stuff – Alexei Darmin Jul 19 '15 at 14:50
0

From this section of the rails tutorial I had added the following code:

group :production do
  gem 'pg',             '0.17.1'
  gem 'rails_12factor', '0.0.2'
end

Which is explained with

Note also the addition of the rails_12factor gem, which is used by Heroku to serve static assets such as images and stylesheets. The resulting Gemfile appears as in Listing 1.14.

To prepare the system for deployment to production, we run bundle install with a special flag to prevent the local installation of any production gems (which in this case consists of pg and rails_12factor):

bundle install --without production

And everything works.

Alexei Darmin
  • 2,079
  • 1
  • 18
  • 30