Need help even generating a new app

I'm having trouble even installing new rails apps. I get to the Bundle
run, and it errors on Json, here's what my error says. I'm new to ALL of
this, including Terminal commands, etc. Hope someone can help me out.
Runs the Bundler.... then I error out at this:

"Installing json (1.7.6) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native
extension.

        /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
extconf.rb
mkmf.rb can't find header files for ruby at
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h

Gem files will remain installed in
/Users/aronoff/.bundler/tmp/8712/gems/json-1.7.6 for inspection.
Results logged to
/Users/aronoff/.bundler/tmp/8712/gems/json-1.7.6/ext/json/ext/generator/gem_make.out
An error occured while installing json (1.7.6), and Bundler cannot
continue.
Make sure that `gem install json -v '1.7.6'` succeeds before bundling."

I was hoping you guys could help me.

Thanks!

Josh Aronoff wrote in post #1092274:

I'm having trouble even installing new rails apps. I get to the Bundle
run, and it errors on Json, here's what my error says. I'm new to ALL of
this, including Terminal commands, etc. Hope someone can help me out.
Runs the Bundler.... then I error out at this:

"Installing json (1.7.6) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native
extension.

        /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
extconf.rb
mkmf.rb can't find header files for ruby at
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h

Gem files will remain installed in
/Users/aronoff/.bundler/tmp/8712/gems/json-1.7.6 for inspection.
Results logged to

/Users/aronoff/.bundler/tmp/8712/gems/json-1.7.6/ext/json/ext/generator/gem_make.out

An error occured while installing json (1.7.6), and Bundler cannot
continue.
Make sure that `gem install json -v '1.7.6'` succeeds before bundling."

I was hoping you guys could help me.

I see from those paths that you appear to be on a Mac. Here are my
recommendations for getting started with the latest versions of Ruby and
Rails.

Step 1: Install Homebrew.

http://mxcl.github.com/homebrew/

Step 2: Install and configure rbenv and ruby-build using Homebrew.

$ brew install rbenv
$ brew install ruby-build

https://github.com/sstephenson/rbenv

Step 3: Install Ruby 1.9.3

$ rbenv install 1.9.3-p327

Step 4: Install Rails

$ gem install rails

Step 5: Create a new Rails app:

$ rails new my_first_app

Step 6: Profit!

Robert Walker wrote in post #1092320:

Step 2: Install and configure rbenv and ruby-build using Homebrew.

$ brew install rbenv
$ brew install ruby-build

Oh! And, don't forget to set the newly installed Ruby as your default
Ruby version:

$ rbenv global 1.9.3-p237

or

$ rbenv local 1.9.3-p237 (from inside your Rails project folder)

thank you! I'll try this and let you know how it went!! Thanks for
responding!

Ok..... got to Step 3:

and then ran into this::

Installing yaml-0.1.4...

BUILD FAILED

Inspect or clean up the working tree at
/var/folders/3r/hdtty71s32bd26yrzyq4m5lr0000gn/T/ruby-build.20130114234238.25080
Results logged to
/var/folders/3r/hdtty71s32bd26yrzyq4m5lr0000gn/T/ruby-build.20130114234238.25080.log

Last 10 log lines:
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in
`/var/folders/3r/hdtty71s32bd26yrzyq4m5lr0000gn/T/ruby-build.20130114234238.25080/yaml-0.1.4':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

OK.... I went the Homebrew route, after some googling and tried to
update my 1.8.7 Ruby to 1.9.3 like you mentioned and I'm STILL running
into a permissions thing with my Library and that Gems directory.

After running $ gem install rails bundler unicorn pg ....

I get this:

Permission denied -
/Users/aronoff/.rvm/gems/ruby-1.9.3-p194/cache/activesupport-3.2.11.gem

Hey,

This is because you installed rvm, which is my preference but I have no qualms about you using rbenv. For some reason the permissions on something in your rvm directory got changed.

sudo chown -r $USER:/$USER $HOME/.rvm

That will help there. I can help you continue to use rvm if you want. If ~/.rvm/scripts/rvm is sourced in your shell, you likely just need to set a new default ruby.

rvm list # lists locally installed rubies

You might want to make sure you have the one you want. I suggest rvm install 1.9.3, which gets you the latest patch set rvm knows about.

After that, you do this

rvm use --default

Whichever system you use, for simplicity, I’d suggest removing the other.

~Spaceghost

Johnneylee Rollins wrote in post #1092374:

This is because you installed rvm, which is my preference but I have no
qualms about you using rbenv.

Just to be clear, I was not exactly recommending rbenv over RVM. I used
to use RVM myself and it's a wonderful tool. I recently switched to
rbenv preferring a more modular and lighter weight tool.

What I was suggesting was to use something other than the build-in Ruby
that OS X provides, given that was the version listed in the error
message in the OP.

As to Josh's problem, it really does sound like your system has some
permission setting issues. I would suggest making sure you own all the
files and directories in your home folder and to use "Disk Utilities"
to try to repair the permissions of your system. Maybe something was
installed to your home folder using the sudo command. That might have
installed files to your home, but owned by "root" user instead of
yourself.

Ok cool... Ugh, this permissions thing is driving me nuts. Can I just
uninstall everything by deleting all the directories and re running the
ruby and rails instals using either homebrow or rvm? to be clear, I'm
only saying delete the ruby directory in my Library.

Josh Aronoff wrote in post #1092595:

Ok cool... Ugh, this permissions thing is driving me nuts. Can I just
uninstall everything by deleting all the directories and re running the
ruby and rails instals using either homebrow or rvm? to be clear, I'm
only saying delete the ruby directory in my Library.

What exactly do you mean by "Library". There are several of those on OS
X.

/System/Library
System owned library. Definitely DO NOT delete, or otherwise touch
anything here.

/Library
Global library for third-party application use, not user specific.
Slightly less dangerous to mess with this stuff, but you shouldn't have
to.

~/Library
This is you're library where you're user specific Preferences,
Application Support, Caches, etc. are kept. You're free to do whatever
you wish with this stuff.

With that out of the way I'll see if I can flesh this out a bit more...

Whether you choose RVM or rbenv, both (by default) create a hidden
directory that is maintained by those tools. The tools are designed to
be as unobtrusive to the normal operation of the operating system as
possible (rbenv even more so than RVM).

You should see something like this:

$ cd ~
$ ls -la

-rw-r--r--@ 1 robertwalker staff 15364 Jan 14 16:42 .DS_Store
drwx------ 3 robertwalker staff 102 Apr 5 2011 .MacOSX
drwxrwxrwt@ 3 robertwalker staff 102 Apr 13 2011 .TemporaryItems
drwx------ 2 robertwalker staff 68 Jan 17 09:14 .Trash
...
drwxr-xr-x 5 robertwalker staff 170 Jul 19 13:56 .rbenv

If you notice that .rbenv (or .rvm) have a user other than yourself
(e.g. root) your can fix that with:

$ chown -R robertwalker:staff .rbenv

Changes ownership of .rbenv and all it's contents recursively to user
"robertwalker" and group "staff".

You must also make sure your PATH is configured properly for rbenv or
RVM to work properly.

$ echo $PATH

/Users/robertwalker/.rbenv/shims:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/opt/local/bin:/usr/local/git/bin

Notice here that /Users/robertwalker/.rbenv/shims is the first path in
the PATH environment variable. In the case of rbenv this is added by
inserting this line...

# Enable rbenv shims and autocompletion
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi

somewhere in your .profile (or similar) file. RVM has a similar setup.
Read their docs for more.

Once you verify these things make sure to tell rbenv (or RVM) which
version of your installed Rubies to use:

$ rbenv global 1.9.3-p327

That should be all that's necessary to get going with rbenv or RVM. I
would recommend against messing with your system's built-in Ruby, or
anything inside /System/Library or /Library.