Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

alexandermuhr
alexandermuhr
3,466 Points

Ruby Install

I am trying to install Ruby (& Ruby on Rails) on OSX 10.7.5

I think I botched the whole install. My computer is still functional, but I can't get past the bin/rails server command at the end of the installation video.

I've spent many hours searching for other examples of what I did wrong. I've tried installing and uninstalling git, rbenv, rvm, ruby, etc.

For instance now I always get this error message when I open my terminal, even though I thought I removed all possible rvm files: -bash: /etc/profile.d/rvm.sh: No such file or directory

Also, my attempt at updating git did not work the way I thought it would either. When I run "which git" I get: /usr/local/git/bin/git

I'm also pretty sure that I have multiple versions of ruby on my computer at the moment.

Would any coding rockstars be willing to help me resolve this? Maybe the best way would be to try and completely uninstall everything? I have tried doing that with rvm, but am wary with trying that for other applications because if I don't remove everything, then it probably wouldn't work.

I believe some of the problem might lie with the /.bash_profile - but am not completely sure.

At the moment I am going to move forward with the VM via Treehouse, but for any future potential projects that will be inadequate due to memory caps.

Thanks, Alex

6 Answers

Stone Preston
Stone Preston
42,016 Points

alright so you have all those installed. try setting the xcode path:

sudo xcode-select -switch /usr/bin 

then try running the rails install again

Stone Preston
Stone Preston
42,016 Points

have you looked in your .bash_profile and .bashrc?

nano ~/.bash_profile
nano ~/.bashrc

see if you have anything rvm related in those files. RVM will usually add some stuff in those files, so check to make sure you remove the things it added

Stone Preston
Stone Preston
42,016 Points

alright then it may be in /etc/profile then.

according to this stack overflow post you just need to comment out 2 lines in /etc/profile

open up /etc/profile

sudo nano /etc/profile

and comment out (put a # at the start of the line) these two lines:

source /etc/profile.d/sm.sh
source /etc/profile.d/rvm.sh
alexandermuhr
alexandermuhr
3,466 Points

Hi Stone,

That did work to resolve the alert when I open the terminal!

alexandermuhr
alexandermuhr
3,466 Points

When I run:

bin/rails server

I get:

-bash: bin/rails: No such file or directory

At the moment then, I am pretty sure that rbenv and rvm are both removed from my system... but git is still installed at:

/usr/local/git/bin/git

Isn't that where the problem lies you think?

Stone Preston
Stone Preston
42,016 Points

git wont affect anything. also if bin is in your path (it probably is) you dont have to type bin/rails. just rails will do the trick

first double check rails is installed:

rails --version

make sure rails is indeed installed first.

alexandermuhr
alexandermuhr
3,466 Points

Hi Stone,

Yes I actually removed everything from ~/.bash_profile - even so this still appears when I open my terminal:

-bash: /etc/profile.d/rvm.sh: No such file or directory
alexandermuhr
alexandermuhr
3,466 Points

So I checked that and it said I needed to install rails:

Rails is not currently installed on this system. To get the latest version, simply type:
    $ sudo gem install rails
You can then rerun your "rails" command.

I ran the command and got this... any idea why?

Building native extensions.  This could take a while...
ERROR:  Error installing rails:
    ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
creating Makefile
make
xcrun cc -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin11.0 -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin11.0 -I. -DJSON_GENERATOR  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -arch i386 -arch x86_64 -g -O3 -pipe -fno-common -DENABLE_DTRACE  -fno-common  -pipe -fno-common   -c generator.c
xcode-select: Error: No Xcode folder is set. Run xcode-select -switch <xcode_folder_path> to set the path to the Xcode folder.
Error: /usr/bin/xcode-select returned unexpected error.
make: *** [generator.o] Error 1
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/json-1.8.1 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
Stone Preston
Stone Preston
42,016 Points

you need to install xcode tools. try running this command first:

xcode-select --install
alexandermuhr
alexandermuhr
3,466 Points

OK... when I run that I get:

Usage: xcode-select -print-path
   or: xcode-select -switch <xcode_folder_path>
   or: xcode-select -version
Arguments:
   -print-path                     Prints the path of the current Xcode folder
   -switch <xcode_folder_path>     Sets the path for the current Xcode folder
   -version                        Prints xcode-select version information
Stone Preston
Stone Preston
42,016 Points

you may already have them. try this command and see what it says:

xcode-select -p
alexandermuhr
alexandermuhr
3,466 Points

The same menu appears as before.

When I run -version:

xcode-select version 2003.
Stone Preston
Stone Preston
42,016 Points

what does the following command output

gcc --version
alexandermuhr
alexandermuhr
3,466 Points

See below:

i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
alexandermuhr
alexandermuhr
3,466 Points

Stone- thanks for being patient! Looks like the same error came back...

Building native extensions.  This could take a while...
ERROR:  Error installing rails:
    ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
creating Makefile
make
xcrun cc -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin11.0 -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin11.0 -I. -DJSON_GENERATOR  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -arch i386 -arch x86_64 -g -O3 -pipe -fno-common -DENABLE_DTRACE  -fno-common  -pipe -fno-common   -c generator.c
sh: /usr/bin/usr/bin/xcodebuild: No such file or directory
/usr/bin/usr/bin/xcodebuild fails with 32512 - Unknown error: 32512
make: *** [generator.o] Error 69
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/json-1.8.1 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
Stone Preston
Stone Preston
42,016 Points

run this command and tell me what you get:

xcode-select -print-path
Stone Preston
Stone Preston
42,016 Points

strange. for some reason its doubling up the path:

/usr/bin/usr/bin/xcodebuild

not quite sure why that is happening. do you have the ful Xcode app installed by chance?

alexandermuhr
alexandermuhr
3,466 Points

I think it's a similar problem to why git is installed where it is......

I don't have the full Xcode app, no.

Stone Preston
Stone Preston
42,016 Points

alright type

which xcodebuild

what does that give you

Stone Preston
Stone Preston
42,016 Points

alright, well lets try installing the tools one more time but using sudo

sudo xcode-select --install

see if that works

alexandermuhr
alexandermuhr
3,466 Points

I don't think it worked.... the same menu as before came up.

I am going to try and work through the Installing Ruby on Mac video again and see if anything changes there.

Stone Preston
Stone Preston
42,016 Points

well before you try that, try redownloading the tools. I definitely think its an issue with your xcode tools. you can download them here

https://developer.apple.com/downloads/index.action

alexandermuhr
alexandermuhr
3,466 Points

So that did not work... but did the steps again from the video. When I run rails server in the "testapp" folder I get this (and the localhost:3000 does not load correctly:

=> Booting WEBrick
=> Rails 3.2.12 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2014-12-07 23:04:14] INFO  WEBrick 1.3.1
[2014-12-07 23:04:14] INFO  ruby 2.0.0 (2014-11-13) [x86_64-darwin11.4.2]
[2014-12-07 23:04:14] WARN  TCPServer Error: Address already in use - bind(2)
Exiting
/Users/alexandermuhr/.rbenv/versions/2.0.0-p598/lib/ruby/2.0.0/webrick/utils.rb:85:in `initialize': Address already in use - bind(2) (Errno::EADDRINUSE)
    from /Users/alexandermuhr/.rbenv/versions/2.0.0-p598/lib/ruby/2.0.0/webrick/utils.rb:85:in `new'
    from /Users/alexandermuhr/.rbenv/versions/2.0.0-p598/lib/ruby/2.0.0/webrick/utils.rb:85:in `block in create_listeners'
    from /Users/alexandermuhr/.rbenv/versions/2.0.0-p598/lib/ruby/2.0.0/webrick/utils.rb:82:in `each'
    from /Users/alexandermuhr/.rbenv/versions/2.0.0-p598/lib/ruby/2.0.0/webrick/utils.rb:82:in `create_listeners'
    from /Users/alexandermuhr/.rbenv/versions/2.0.0-p598/lib/ruby/2.0.0/webrick/server.rb:132:in `listen'
    from /Users/alexandermuhr/.rbenv/versions/2.0.0-p598/lib/ruby/2.0.0/webrick/server.rb:113:in `initialize'
    from /Users/alexandermuhr/.rbenv/versions/2.0.0-p598/lib/ruby/2.0.0/webrick/httpserver.rb:45:in `initialize'
    from /Users/alexandermuhr/.rbenv/versions/2.0.0-p598/lib/ruby/gems/2.0.0/gems/rack-1.4.5/lib/rack/handler/webrick.rb:10:in `new'
    from /Users/alexandermuhr/.rbenv/versions/2.0.0-p598/lib/ruby/gems/2.0.0/gems/rack-1.4.5/lib/rack/handler/webrick.rb:10:in `run'
    from /Users/alexandermuhr/.rbenv/versions/2.0.0-p598/lib/ruby/gems/2.0.0/gems/rack-1.4.5/lib/rack/server.rb:268:in `start'
    from /Users/alexandermuhr/.rbenv/versions/2.0.0-p598/lib/ruby/gems/2.0.0/gems/railties-3.2.12/lib/rails/commands/server.rb:70:in `start'
    from /Users/alexandermuhr/.rbenv/versions/2.0.0-p598/lib/ruby/gems/2.0.0/gems/railties-3.2.12/lib/rails/commands.rb:55:in `block in <top (required)>'
    from /Users/alexandermuhr/.rbenv/versions/2.0.0-p598/lib/ruby/gems/2.0.0/gems/railties-3.2.12/lib/rails/commands.rb:50:in `tap'
    from /Users/alexandermuhr/.rbenv/versions/2.0.0-p598/lib/ruby/gems/2.0.0/gems/railties-3.2.12/lib/rails/commands.rb:50:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

Any idea as to what is going on here?

Stone Preston
Stone Preston
42,016 Points

alright there is a process using that port currently. you can look up which one is using it and then kill it

lsof -wni tcp:3000

will show you which one is using it.

to kill it use:

kill -9 <PID>

but replace <PID> with the PID of the process that is displayed by the first command

alexandermuhr
alexandermuhr
3,466 Points

BOOM! it's working.

Thank you so much for the help!!

Do you know maybe why this block was occurring?

crossing my fingers that it will stay functional!

Stone Preston
Stone Preston
42,016 Points

awesome glad its finally working. no not sure why this was happening